Added class SolutionIsotopeList

Working through using C++ structures in transport




git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@855 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2006-04-11 23:41:57 +00:00
parent 957551d0a7
commit 3261c99891
13 changed files with 417 additions and 38 deletions

View File

@ -143,7 +143,7 @@ COMMON_CXXOBJS = \
ExchComp.o \
GasPhase.o \
ISolution.o \
SolutionIsotope.o \
ISolutionComp.o \
KineticsComp.o \
KineticsCxx.o \
Mix.o \
@ -155,7 +155,8 @@ COMMON_CXXOBJS = \
Reaction.o \
ReadClass.o \
Solution.o \
ISolutionComp.o \
SolutionIsotope.o \
SolutionIsotopelist.o \
SSassemblage.o \
SSassemblageSS.o \
StorageBin.o \
@ -255,27 +256,36 @@ ReadClass.o: ../ReadClass.cxx ../Parser.h ../char_star.h ../Solution.h \
../NumKeyword.h ../NameDouble.h ../char_star.h ../Mix.h ../NumKeyword.h \
../char_star.h ../Temperature.h ../NumKeyword.h ../char_star.h \
../phreeqc/phqalloc.h ../phreeqc/output.h ../phreeqc/phrqproto.h
Solution.o: ../Solution.cxx ../Utils.h ../Solution.h ../NumKeyword.h \
../Parser.h ../char_star.h ../SolutionIsotope.h ../Parser.h \
../NameDouble.h ../phreeqc/global.h ../phreeqc/phrqtype.h \
../char_star.h ../Parser.h ../char_star.h ../phreeqc/phqalloc.h \
../phreeqc/phrqproto.h ../ISolution.h ../ISolutionComp.h ../Utils.h \
../char_star.h ../NumKeyword.h ../Solution.h ../Exchange.h \
../NumKeyword.h ../char_star.h ../ExchComp.h ../NameDouble.h \
../char_star.h ../Surface.h ../NumKeyword.h ../char_star.h \
../SurfComp.h ../NameDouble.h ../char_star.h ../SurfCharge.h \
../NameDouble.h ../char_star.h ../PPassemblage.h ../NumKeyword.h \
../char_star.h ../PPassemblageComp.h ../NameDouble.h ../char_star.h \
../KineticsCxx.h ../NumKeyword.h ../char_star.h ../KineticsComp.h \
../NameDouble.h ../char_star.h ../SSassemblage.h ../NumKeyword.h \
../char_star.h ../SSassemblageSS.h ../NameDouble.h ../char_star.h \
../GasPhase.h ../NumKeyword.h ../NameDouble.h ../char_star.h \
../Reaction.h ../NumKeyword.h ../NameDouble.h ../char_star.h ../Mix.h \
../NumKeyword.h ../char_star.h ../Temperature.h ../NumKeyword.h \
../char_star.h
Solution.o: ../Solution.cxx ../Utils.h ../char_star.h ../Solution.h \
../NumKeyword.h ../Parser.h ../char_star.h ../SolutionIsotopeList.h \
../SolutionIsotope.h ../Parser.h ../phreeqc/global.h \
../phreeqc/phrqtype.h ../char_star.h ../Parser.h ../NameDouble.h \
../char_star.h ../Parser.h ../Mix.h ../NumKeyword.h ../char_star.h \
../char_star.h ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h \
../ISolution.h ../ISolutionComp.h ../Utils.h ../char_star.h \
../NumKeyword.h ../Solution.h ../Exchange.h ../NumKeyword.h \
../char_star.h ../ExchComp.h ../NameDouble.h ../char_star.h \
../Surface.h ../NumKeyword.h ../char_star.h ../SurfComp.h \
../NameDouble.h ../char_star.h ../SurfCharge.h ../NameDouble.h \
../char_star.h ../PPassemblage.h ../NumKeyword.h ../char_star.h \
../PPassemblageComp.h ../NameDouble.h ../char_star.h ../KineticsCxx.h \
../NumKeyword.h ../char_star.h ../KineticsComp.h ../NameDouble.h \
../char_star.h ../SSassemblage.h ../NumKeyword.h ../char_star.h \
../SSassemblageSS.h ../NameDouble.h ../char_star.h ../GasPhase.h \
../NumKeyword.h ../NameDouble.h ../char_star.h ../Reaction.h \
../NumKeyword.h ../NameDouble.h ../char_star.h ../Mix.h \
../Temperature.h ../NumKeyword.h ../char_star.h ../StorageBin.h \
../Utils.h ../Parser.h ../Solution.h ../Exchange.h ../GasPhase.h \
../KineticsCxx.h ../PPassemblage.h ../SSassemblage.h ../Surface.h \
../Mix.h ../Reaction.h ../Temperature.h ../NumKeyword.h
SolutionIsotope.o: ../SolutionIsotope.cxx ../SolutionIsotope.h \
../Parser.h ../char_star.h ../Utils.h ../Parser.h ../phreeqc/global.h \
../phreeqc/phrqtype.h ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h
../Parser.h ../char_star.h ../Utils.h ../char_star.h ../Parser.h \
../phreeqc/global.h ../phreeqc/phrqtype.h ../phreeqc/phqalloc.h \
../phreeqc/phrqproto.h
SolutionIsotopeList.o: ../SolutionIsotopeList.cxx ../Utils.h \
../char_star.h ../SolutionIsotopeList.h ../SolutionIsotope.h \
../Parser.h ../char_star.h ../phreeqc/global.h ../phreeqc/phrqtype.h \
../char_star.h ../Parser.h ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h
SSassemblage.o: ../SSassemblage.cxx ../Utils.h ../SSassemblage.h \
../NumKeyword.h ../Parser.h ../char_star.h ../phreeqc/global.h \
../phreeqc/phrqtype.h ../char_star.h ../SSassemblageSS.h \
@ -418,7 +428,7 @@ clean:
dependencies:
mkdir -p $(DEBUG_DIR)
cd Debug; gcc -MM -I../phreeqc ../*.cxx
cd $(DEBUG_DIR); gcc -MM -I../phreeqc ../*.cxx
# =============================================================================

2
Mix.h
View File

@ -28,6 +28,8 @@ public:
void read_raw(CParser& parser);
std::map<int, double> comps() {return mixComps;}
protected:
std::map<int, double> mixComps;

View File

@ -39,6 +39,22 @@ cxxNameDouble::cxxNameDouble(struct elt_list *elt_list_ptr)
}
this->type = ND_ELT_MOLES;
}
cxxNameDouble::cxxNameDouble(const cxxNameDouble &old, double factor)
//
// constructor for cxxNameDouble from list of elt_list
//
{
for (cxxNameDouble::const_iterator it = old.begin(); it != old.end(); it++) {
if (old.type == ND_ELT_MOLES) {
if (it->second * factor > 0) {
(*this)[(it->first)] = it->second * factor;
}
} else {
(*this)[(it->first)] = it->second * factor;
}
}
this->type = old.type;
}
cxxNameDouble::cxxNameDouble(struct conc *tots)
//
// constructor for cxxNameDouble from list of elt_list
@ -256,3 +272,19 @@ CParser::STATUS_TYPE cxxNameDouble::read_raw(CParser& parser, std::istream::pos_
(*this)[ctoken] = d;
return CParser::PARSER_OK;
}
void cxxNameDouble::add(const cxxNameDouble &old, double factor)
//
// constructor for cxxNameDouble from list of elt_list
//
{
for (cxxNameDouble::const_iterator it = old.begin(); it != old.end(); it++) {
cxxNameDouble::iterator current = (*this).find(it->first);
if (current != (*this).end()) {
(*this)[it->first] = current->second + it->second * factor;
} else {
(*this)[it->first] = it->second * factor;
}
}
}

View File

@ -27,6 +27,7 @@ public:
cxxNameDouble(struct conc *);
cxxNameDouble(struct master_activity *ma, int count, ND_TYPE);
cxxNameDouble(struct name_coef *nc, int count, ND_TYPE);
cxxNameDouble(const cxxNameDouble &old, double factor);
~cxxNameDouble();
struct elt_list *elt_list();
@ -43,9 +44,12 @@ public:
CParser::STATUS_TYPE read_raw(CParser& parser, std::istream::pos_type& pos);
enum ND_TYPE type;
void add(const cxxNameDouble &old, double factor);
enum ND_TYPE type;
protected:
//std::map <char *, double, CHARSTAR_LESS> totals;

View File

@ -19,6 +19,7 @@
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
cxxSolution::cxxSolution()
//
// default constructor for cxxSolution
@ -39,7 +40,27 @@ cxxSolution::cxxSolution()
master_activity.type = cxxNameDouble::ND_SPECIES_LA;
species_gamma.type = cxxNameDouble::ND_SPECIES_GAMMA;
}
cxxSolution::cxxSolution(double zero)
//
// empty cxxSolution constructor
//
: cxxNumKeyword()
{
assert (zero == 0.0);
tc = 0.0;
ph = 0.0;
pe = 0.0;
mu = 0.0;
ah2o = 0.0;
total_h = 0.0;
total_o = 0.0;
cb = 0.0;
mass_water = 0.0;
total_alkalinity = 0.0;
totals.type = cxxNameDouble::ND_ELT_MOLES;
master_activity.type = cxxNameDouble::ND_SPECIES_LA;
species_gamma.type = cxxNameDouble::ND_SPECIES_GAMMA;
}
cxxSolution::cxxSolution(struct solution *solution_ptr)
//
// constructor for cxxSolution from struct solution
@ -48,9 +69,9 @@ cxxSolution::cxxSolution(struct solution *solution_ptr)
cxxNumKeyword(),
totals(solution_ptr->totals),
master_activity(solution_ptr->master_activity, solution_ptr->count_master_activity, cxxNameDouble::ND_SPECIES_LA),
species_gamma(solution_ptr->species_gamma, solution_ptr->count_species_gamma, cxxNameDouble::ND_SPECIES_GAMMA)
species_gamma(solution_ptr->species_gamma, solution_ptr->count_species_gamma, cxxNameDouble::ND_SPECIES_GAMMA),
isotopes(solution_ptr)
{
int i;
this->set_description(solution_ptr->description);
n_user = solution_ptr->n_user;
@ -69,19 +90,58 @@ species_gamma(solution_ptr->species_gamma, solution_ptr->count_species_gamma, cx
// Totals filled in constructor, just save description and moles
// Isotopes
/*
for (i = 0; i < solution_ptr->count_isotopes; i++) {
cxxSolutionIsotope iso(&solution_ptr->isotopes[i]);
isotopes.push_back(iso);
}
*/
// Master_activity in constructor
// Species_gamma in constructor
}
#ifdef SKIP
cxxSolution::cxxSolution(const cxxSolution &old, double intensive, double extensive)
//
// constructor for cxxSolution from struct solution
//
:
cxxNumKeyword(),
totals(old.totals, extensive),
master_activity(old.master_activity, intensive),
species_gamma(old.species_gamma, intensive)
{
this->set_description(old.description);
this->n_user = old.n_user;
this->n_user_end = old.n_user_end;
this->tc = old.tc * intensive;
this->ph = old.ph * intensive;
this->pe = old.pe * intensive;
this->mu = old.mu * intensive;
this->ah2o = old.ah2o * intensive;
this->total_h = old.total_h * extensive;
this->total_o = old.total_o * extensive;
this->cb = old.cb * extensive;
this->mass_water = old.mass_water * extensive;
this->total_alkalinity = old.total_alkalinity * extensive;
/*
cxxNameDouble totals;
std::list<cxxSolutionIsotope> isotopes;
cxxNameDouble master_activity;
cxxNameDouble species_gamma;
*/
for (std::list<cxxSolutionIsotope>::const_iterator it = old.isotopes.begin(); it != old.isotopes.end(); it++) {
this->isotopes.push_back(cxxSolutionIsotope((*it), intensive, extensive));
}
}
#endif
cxxSolution::~cxxSolution()
{
}
struct solution *cxxSolution::cxxSolution2solution()
//
// Builds a solution structure from instance of cxxSolution
@ -124,7 +184,8 @@ struct solution *cxxSolution::cxxSolution2solution()
// isotopes
solution_ptr->isotopes = (struct isotope *) free_check_null(solution_ptr->isotopes);
solution_ptr->isotopes = cxxSolutionIsotope::list2isotope(this->isotopes);
//solution_ptr->isotopes = cxxSolutionIsotope::list2isotope(this->isotopes);
solution_ptr->isotopes = this->isotopes.cxxSolutionIsotopeList2isotope();
solution_ptr->count_isotopes = this->isotopes.size();
return(solution_ptr);
@ -607,6 +668,70 @@ void cxxSolution::read_raw(CParser& parser)
return;
}
void cxxSolution::add(const cxxSolution &old, double intensive, double extensive)
//
// Add existing solution to "this" solution
//
{
this->tc += old.tc * intensive;
this->ph += old.ph * intensive;
this->pe += old.pe * intensive;
this->mu += old.mu * intensive;
this->ah2o += old.ah2o * intensive;
this->total_h += old.total_h * extensive;
this->total_o += old.total_o * extensive;
this->cb += old.cb * extensive;
this->mass_water += old.mass_water * extensive;
this->total_alkalinity += old.total_alkalinity * extensive;
this->totals.add(old.totals, extensive);
this->master_activity.add(old.master_activity, intensive);
this->species_gamma.add(old.species_gamma, intensive);
this->isotopes.add(old.isotopes, intensive, extensive);
#ifdef SKIP
//
// isotopes
// go through old list, update or add to current list
//
for (std::list <cxxSolutionIsotope>::const_iterator itold = old.isotopes.begin(); itold != old.isotopes.end(); ++itold) {
bool found = false;
for (std::list <cxxSolutionIsotope>::iterator it = this->isotopes.begin(); it != this->isotopes.end(); ++it) {
if ((it->isotope_number == itold->isotope_number) &&
(it->elt_name == itold->elt_name) &&
(it->isotope_name == itold->isotope_name)) {
it->total += itold->total * extensive;
it->ratio += itold->ratio * intensive;
it->ratio_uncertainty += itold->ratio_uncertainty * intensive;
it->ratio_uncertainty_defined = (it->ratio_uncertainty_defined || itold->ratio_uncertainty_defined);
found = true;
break;
}
}
if (!found) {
this->isotopes.push_back(*itold);
}
}
#endif
/*
cxxNameDouble totals;
std::list<cxxSolutionIsotope> isotopes;
cxxNameDouble master_activity;
cxxNameDouble species_gamma;
*/
}
double cxxSolution::get_total(char *string)const
{
cxxNameDouble::const_iterator it = this->totals.find(string);
if (it == this->totals.end()) {
return(0.0);
} else {
return(it->second);
}
}
#ifdef SKIP
cxxSolution& cxxSolution::read(CParser& parser)
{
@ -1145,3 +1270,4 @@ void test_classes(void)
// read it back
}
}

View File

@ -2,8 +2,10 @@
#define SOLUTION_H_INCLUDED
#include "NumKeyword.h"
#include "SolutionIsotope.h"
#include "SolutionIsotopeList.h"
#include "NameDouble.h"
#include "Mix.h"
#define EXTERNAL extern
#include "global.h"
#include <cassert> // assert
@ -19,7 +21,11 @@ class cxxSolution : public cxxNumKeyword
public:
cxxSolution();
cxxSolution(double zero);
cxxSolution(struct solution *);
cxxSolution(const std::map<int, cxxSolution> &solution_map, cxxMix &mx);
cxxSolution(const cxxSolution &old, double intensive, double extensive);
//cxxSolution(const cxxSolution&);
~cxxSolution();
@ -41,17 +47,21 @@ public:
void set_ah2o(double ah2o) {this->pe = ah2o;}
double get_total_h()const {return this->total_h;}
void set_total_h(double total_h) {this->pe = mu;}
void set_total_h(double total_h) {this->pe = total_h;}
double get_total_o()const {return this->total_o;}
void set_total_o(double total_o) {this->pe = mu;}
void set_total_o(double total_o) {this->pe = total_o;}
double get_mass_water()const {return this->mass_water;};
void set_mass_water(long double mass_water) {this->mass_water = mass_water;};
double get_mass_water()const {return this->mass_water;}
void set_mass_water(long double mass_water) {this->mass_water = mass_water;}
double get_total_alkalinity()const {return this->total_alkalinity;}
void set_total_alkalinity(double total_alkalinity) {this->pe = total_alkalinity;}
double get_cb()const {return this->cb;}
void set_cb(double cb) {this->cb = cb;}
double get_total(char *string)const;
//char * get_pe_reaction()const {return this->pe_reaction;}
//void set_pe_reaction(char * pe_reaction) {this->pe_reaction = pe_reaction;}
@ -63,6 +73,7 @@ public:
void read_raw(CParser& parser);
void add(const cxxSolution &sol, double intensive, double extensive);
protected:
double tc;
@ -76,9 +87,10 @@ protected:
double mass_water;
double total_alkalinity;
cxxNameDouble totals;
std::list<cxxSolutionIsotope> isotopes;
//std::list<cxxSolutionIsotope> isotopes;
cxxNameDouble master_activity;
cxxNameDouble species_gamma;
cxxSolutionIsotopeList isotopes;
public:
//static std::map<int, cxxSolution>& map;

View File

@ -26,6 +26,7 @@ cxxSolutionIsotope::cxxSolutionIsotope(struct isotope *isotope_ptr)
ratio_uncertainty = isotope_ptr->ratio_uncertainty;
}
cxxSolutionIsotope::~cxxSolutionIsotope(void)
{
}
@ -185,6 +186,18 @@ struct master *cxxSolutionIsotope::primary(void)
return (master_bsearch_primary(this->elt_name));
}
void cxxSolutionIsotope::add(const cxxSolutionIsotope &isotope_ptr, double intensive, double extensive)
{
if ((this->isotope_number == isotope_ptr.isotope_number) &&
(this->elt_name == isotope_ptr.elt_name) &&
(this->isotope_name == isotope_ptr.isotope_name)) {
this->total += isotope_ptr.total * extensive;
this->ratio += isotope_ptr.ratio * intensive;
this->ratio_uncertainty += isotope_ptr.ratio_uncertainty * intensive;
this->ratio_uncertainty_defined = (this->ratio_uncertainty_defined || isotope_ptr.ratio_uncertainty_defined);
}
}
#ifdef SKIP
cxxSolutionIsotope::STATUS cxxSolutionIsotope::read(CParser& parser)
{

View File

@ -42,7 +42,10 @@ public:
struct master *master(void);
struct master *primary(void);
private:
void add(const cxxSolutionIsotope &isotope_ptr, double intensive, double extensive);
protected:
friend class cxxSolutionIsotopeList;
double isotope_number;
char * elt_name;
char * isotope_name;

78
SolutionIsotopeList.cxx Normal file
View File

@ -0,0 +1,78 @@
#include "Utils.h" // define first
#include "SolutionIsotopeList.h"
#define EXTERNAL extern
#include "global.h"
#include "phqalloc.h"
#include "phrqproto.h"
#include <cassert> // assert
#include <algorithm> // std::sort
cxxSolutionIsotopeList::cxxSolutionIsotopeList(void)
//
// default constructor for cxxSolution
//
{
}
cxxSolutionIsotopeList::cxxSolutionIsotopeList(struct solution *solution_ptr)
{
int i;
// Isotopes
for (i = 0; i < solution_ptr->count_isotopes; i++) {
//cxxSolutionIsotope iso(&solution_ptr->isotopes[i]);
(*this).push_back(&solution_ptr->isotopes[i]);
}
}
void cxxSolutionIsotopeList::add(cxxSolutionIsotopeList old, double intensive, double extensive)
{
for (cxxSolutionIsotopeList::const_iterator itold = old.begin(); itold != old.end(); ++itold) {
//for (std::list <cxxSolutionIsotope>::const_iterator itold = old.isotopes.begin(); itold != old.isotopes.end(); ++itold) {
bool found = false;
for (cxxSolutionIsotopeList::iterator it = this->begin(); it != this->end(); ++it) {
//for (std::list <cxxSolutionIsotope>::iterator it = this->isotopes.begin(); it != this->isotopes.end(); ++it) {
if ((it->isotope_number == itold->isotope_number) &&
(it->elt_name == itold->elt_name) &&
(it->isotope_name == itold->isotope_name)) {
it->total += itold->total * extensive;
it->ratio += itold->ratio * intensive;
it->ratio_uncertainty += itold->ratio_uncertainty * intensive;
it->ratio_uncertainty_defined = (it->ratio_uncertainty_defined || itold->ratio_uncertainty_defined);
found = true;
break;
}
}
if (!found) {
cxxSolutionIsotope iso;
iso.total = itold->total * extensive;
iso.ratio = itold->ratio * intensive;
iso.ratio_uncertainty = itold->ratio_uncertainty * intensive;
iso.ratio_uncertainty_defined = itold->ratio_uncertainty_defined;
this->push_back(iso);
}
}
}
struct isotope * cxxSolutionIsotopeList::cxxSolutionIsotopeList2isotope()
{
struct isotope *iso;
if (this->size() <= 0) {
return NULL;
} else {
iso = (struct isotope *) PHRQ_malloc((size_t) ((this->size()) * sizeof(struct isotope)));
if (iso == NULL) malloc_error();
int i = 0;
for (cxxSolutionIsotopeList::iterator it = this->begin(); it != this->end(); ++it) {
iso[i].isotope_number = it->isotope_number;
iso[i].elt_name = it->elt_name;
iso[i].total = it->total;
iso[i].ratio = it->ratio;
iso[i].ratio_uncertainty = it->ratio_uncertainty;
iso[i].master = it->master();
iso[i].primary = it->primary();
i++;
}
}
return(iso);
}

35
SolutionIsotopeList.h Normal file
View File

@ -0,0 +1,35 @@
#if !defined(SOLUTIONISOTOPELIST_H_INCLUDED)
#define SOLUTIONISOTOPELIST_H_INCLUDED
#define EXTERNAL extern
#include "SolutionIsotope.h"
#include "global.h"
#include <cassert> // assert
#include <string> // std::string
#include <list> // std::list
#include "char_star.h"
#include "Parser.h"
class cxxSolutionIsotopeList : public std::list <cxxSolutionIsotope>
{
public:
cxxSolutionIsotopeList();
cxxSolutionIsotopeList(struct solution *solution_ptr);
~cxxSolutionIsotopeList();
struct isotope *cxxSolutionIsotopeList2isotope();
void add(cxxSolutionIsotopeList oldlist, double intensive, double extensive);
protected:
public:
};
#endif // !defined(SOLUTIONISOTOPELIST_H_INCLUDED)

View File

@ -20,11 +20,11 @@
//////////////////////////////////////////////////////////////////////
cxxStorageBin::cxxStorageBin()
{
// default constructor for cxxStorageBin
}
cxxStorageBin::cxxStorageBin(cxxStorageBin::SB_CONSTRUCTOR flag)
//
// default constructor for cxxStorageBin
// pull data out of c storage
//
{
@ -233,3 +233,44 @@ END_OF_SIMULATION_INPUT:
return; //CParser::LT_OK;
}
void cxxStorageBin::add(struct system * system_ptr)
//
// add data from a system structure
//
{
// Solutions
if (system_ptr->solution != NULL) {
this->Solutions[system_ptr->solution->n_user] = cxxSolution(system_ptr->solution);
}
// Exchangers
if (system_ptr->exchange != NULL) {
this->Exchangers[system_ptr->exchange->n_user] = cxxExchange(system_ptr->exchange);
}
// GasPhases
if (system_ptr->gas_phase != NULL) {
this->GasPhases[system_ptr->gas_phase->n_user] = cxxGasPhase(system_ptr->gas_phase);
}
// Kinetics
if (system_ptr->kinetics != NULL) {
this->Kinetics[system_ptr->kinetics->n_user] = cxxKinetics(system_ptr->kinetics);
}
// PPassemblages
if (system_ptr->pp_assemblage != NULL) {
this->PPassemblages[system_ptr->pp_assemblage->n_user] = cxxPPassemblage(system_ptr->pp_assemblage);
}
// SSassemblages
if (system_ptr->s_s_assemblage != NULL) {
this->SSassemblages[system_ptr->s_s_assemblage->n_user] = cxxSSassemblage(system_ptr->s_s_assemblage);
}
// Surfaces
if (system_ptr->surface != NULL) {
this->Surfaces[system_ptr->surface->n_user] = cxxSurface(system_ptr->surface);
}
}

View File

@ -1,6 +1,7 @@
#if !defined(STORAGEBIN_H_INCLUDED)
#define STORAGEBIN_H_INCLUDED
#include "Utils.h"
#include "Parser.h"
#include "Solution.h"
#include "Exchange.h"
@ -9,7 +10,6 @@
#include "PPassemblage.h"
#include "SSassemblage.h"
#include "Surface.h"
#include "Mix.h"
#include "Reaction.h"
#include "Temperature.h"
@ -34,10 +34,22 @@ public:
//void dump_xml(std::ostream& os, unsigned int indent = 0)const;
struct cxxSolution *get_solution(int i) {
//cxxSolution *solution_ptr = Utilities::get_entity(this->Solutions, i);
return(Utilities::get_entity(this->Solutions, i));
//if (this->Solutions.find(i) != this->Solutions.end()) {
//return(&(this->Solutions.find(i)->second));
//} else {
//return(NULL);
//}
}
void dump_raw(std::ostream& s_oss, unsigned int indent)const;
void read_raw(CParser& parser);
void add(struct system *sys_ptr);
protected:
// Tidied classes
std::map<int, cxxSolution> Solutions;

11
Utils.h
View File

@ -45,6 +45,17 @@ namespace Utilities {
template<typename T>
bool exists (const T &b, int i){
return (b.find(i) != b.end());}
template<typename T>
T *get_entity(std::map<int, T> b, int i) {
if (b.find(i) != b.end()) {
return(&(b.find(i)->second));
} else {
return (NULL);
}
}
/*
template<class T>
bool exists (std::map<int, T> b, int i){