From 2fe8f7d44e7452b210f3a10a24dfe88e53e29637 Mon Sep 17 00:00:00 2001 From: David L Parkhurst Date: Mon, 27 Feb 2006 21:17:46 +0000 Subject: [PATCH] Working on saving state. I think there is a compiler bug with map iterators in template definitions. git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@796 1feff8c3-07ed-0310-ac33-dd36852eb9cd --- Makefile | 7 +++++++ Parser.cxx | 10 +++++++--- Parser.h | 16 +++++++++++----- Solution.cxx | 20 ++++++++++++++++++-- Utils.h | 21 +++++++++++++++++++++ 5 files changed, 64 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 89e054c3..fb90ded5 100644 --- a/Makefile +++ b/Makefile @@ -158,6 +158,7 @@ COMMON_CXXOBJS = \ ISolutionComp.o \ SSassemblage.o \ SSassemblageSS.o \ + StorageBin.o \ Surface.o \ SurfCharge.o \ SurfComp.o \ @@ -178,6 +179,9 @@ ${PROGRAM} : ${OBJECT_FILES} # # CXX files # +EntityMap.o: ../EntityMap.cxx ../Utils.h ../EntityMap.h \ + ../phreeqc/global.h ../phreeqc/phrqtype.h ../char_star.h ../Parser.h \ + ../char_star.h ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h Exchange.o: ../Exchange.cxx ../Utils.h ../Exchange.h ../NumKeyword.h \ ../Parser.h ../char_star.h ../phreeqc/global.h ../phreeqc/phrqtype.h \ ../char_star.h ../ExchComp.h ../NameDouble.h ../char_star.h ../Parser.h \ @@ -281,6 +285,9 @@ SSassemblageSS.o: ../SSassemblageSS.cxx ../Utils.h ../SSassemblageSS.h \ ../NameDouble.h ../phreeqc/global.h ../phreeqc/phrqtype.h \ ../char_star.h ../Parser.h ../char_star.h ../char_star.h \ ../NameDouble.h ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h +StorageBin.o: ../StorageBin.cxx ../Utils.h ../StorageBin.h \ + ../phreeqc/global.h ../phreeqc/phrqtype.h ../phreeqc/phqalloc.h \ + ../phreeqc/phrqproto.h Surface.o: ../Surface.cxx ../Utils.h ../Surface.h ../NumKeyword.h \ ../Parser.h ../char_star.h ../phreeqc/global.h ../phreeqc/phrqtype.h \ ../char_star.h ../SurfComp.h ../NameDouble.h ../char_star.h ../Parser.h \ diff --git a/Parser.cxx b/Parser.cxx index 48f78c22..af9a95f1 100644 --- a/Parser.cxx +++ b/Parser.cxx @@ -233,9 +233,13 @@ bool CParser::check_key(std::string::iterator begin, std::string::iterator end) static std::map s_keyword_map; if (s_keyword_map.size() == 0) { - s_keyword_map.insert(std::map::value_type("solution", KT_SOLUTION)); - s_keyword_map.insert(std::map::value_type("solution_raw", KT_SOLUTION_RAW)); - s_keyword_map.insert(std::map::value_type("end", KT_END)); + s_keyword_map.insert(std::map::value_type("solution_raw", KT_SOLUTION_RAW)); + s_keyword_map.insert(std::map::value_type("exchange_raw", KT_EXCHANGE_RAW)); + s_keyword_map.insert(std::map::value_type("gas_phase_raw", KT_GASPHASE_RAW)); + s_keyword_map.insert(std::map::value_type("kinetics_raw", KT_KINETICS_RAW)); + s_keyword_map.insert(std::map::value_type("equilibrium_phases_raw", KT_PPASSEMBLAGE_RAW)); + s_keyword_map.insert(std::map::value_type("solid_solutions_raw", KT_SSASSEMBLAGE_RAW)); + s_keyword_map.insert(std::map::value_type("surface_raw", KT_SURFACE_RAW)); } std::string lowercase; diff --git a/Parser.h b/Parser.h index feafabbe..b28ccce0 100644 --- a/Parser.h +++ b/Parser.h @@ -40,11 +40,17 @@ public: }; enum KEY_TYPE { - KT_NONE = -1, - KT_END = 0, - KT_EOF = 1, - KT_SOLUTION = 4, - KT_SOLUTION_RAW = 5 + KT_NONE = -1, + KT_END = 0, + KT_EOF = 1, + KT_SOLUTION_RAW = 5, + KT_EXCHANGE_RAW = 6, + KT_GASPHASE_RAW = 7, + KT_KINETICS_RAW = 8, + KT_PPASSEMBLAGE_RAW = 9, + KT_SSASSEMBLAGE_RAW = 10, + KT_SURFACE_RAW = 11 + }; enum OPT_TYPE { diff --git a/Solution.cxx b/Solution.cxx index f13f3515..5ae7438b 100644 --- a/Solution.cxx +++ b/Solution.cxx @@ -809,6 +809,8 @@ cxxSolution& cxxSolution::read(CParser& parser) #include "Reaction.h" #include "Mix.h" #include "Temperature.h" +#include "StorageBin.h" +#include "NumKeyword.h" #include // std::cout std::cerr //#include #include @@ -816,8 +818,22 @@ cxxSolution& cxxSolution::read(CParser& parser) void test_classes(void) { int i; - bool b(true); - i = (int) b; + + + + /* + std::map Solutions; + cxxSolution soln(solution[0]); + Solutions[solution[0]->n_user] = soln; + bool b = Utilities::exists(Solutions, 1); + */ + /* + cxxEntityMap x; + cxxSolution soln(solution[0]); + cxxNumKeyword nk; + x[solution[0]->n_user] = soln; + */ + for (i=0; i < count_solution; i++) { if (solution[i]->new_def == TRUE) { cxxISolution sol(solution[i]); diff --git a/Utils.h b/Utils.h index 0c1bba6c..714a5bae 100644 --- a/Utils.h +++ b/Utils.h @@ -2,6 +2,11 @@ #define UTILITIES_H_INCLUDED #include +#include // std::istringstream std::ostringstream +#include // std::ostream +#include // std::istream +#include // std::map +#include "char_star.h" namespace Utilities { @@ -26,6 +31,22 @@ namespace Utilities { void error_msg(const std::string&, const int stopflag); + // operations on maps of entities (Solution, Exchange, ...) + template + bool exists (std::map b, int i){ + return (b.find(i) != b.end());} + + /* + template + void dump_raw ( std::map b, std::ostream& s_oss, unsigned int indent ) + { + std :: map < int, T > :: iterator it; + for (it = b.begin(); it != b.end(); ++it) { + it->second.dump_raw(s_oss, indent); + } + return; + } + */ } #endif // UTILITIES_H_INCLUDED