Slowly adding arguments and qualifiers to pass phreeqc class instance to routines that need it.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@3873 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2009-12-08 00:56:50 +00:00
parent 6859605bc2
commit 157e5cc729
27 changed files with 612 additions and 573 deletions

View File

@ -70,7 +70,7 @@ struct conc *cxxISolutionComp::concarray(std::map <char *, double, CHARSTAR_LESS
}
*/
struct conc *
cxxISolutionComp::cxxISolutionComp2conc(const std::map < std::string,
cxxISolutionComp::cxxISolutionComp2conc(PHREEQC_PTR_ARG_COMMA const std::map < std::string,
cxxISolutionComp > &totals)
// for ISolutions
// takes a std::vector cxxISolutionComp structures
@ -80,25 +80,25 @@ struct conc *
c = (struct conc *)
PHRQ_malloc((size_t) ((totals.size() + 1) * sizeof(struct conc)));
if (c == NULL)
malloc_error();
P_INSTANCE_POINTER malloc_error();
int i = 0;
for (std::map < std::string, cxxISolutionComp >::const_iterator it = totals.begin();
it != totals.end(); ++it)
{
c[i].description = string_duplicate(it->second.description.c_str());
c[i].description = P_INSTANCE_POINTER string_duplicate(it->second.description.c_str());
c[i].moles = it->second.moles;
c[i].input_conc = it->second.input_conc;
if (it->second.units.size() == 0)
c[i].units = NULL;
else
c[i].units = string_hsave(it->second.units.c_str());
c[i].units = P_INSTANCE_POINTER string_hsave(it->second.units.c_str());
if (it->second.equation_name.size() == 0)
c[i].equation_name = NULL;
else
c[i].equation_name = string_hsave(it->second.equation_name.c_str());
c[i].equation_name = P_INSTANCE_POINTER string_hsave(it->second.equation_name.c_str());
c[i].phase_si = it->second.phase_si;
c[i].n_pe = it->second.n_pe;
c[i].as = string_hsave(it->second.as.c_str());
c[i].as = P_INSTANCE_POINTER string_hsave(it->second.as.c_str());
c[i].gfw = it->second.gfw;
//c[i].skip = 0;
c[i].phase = NULL;
@ -109,7 +109,7 @@ struct conc *
}
void
cxxISolutionComp::set_gfw()
cxxISolutionComp::set_gfw(PHREEQC_PTR_ARG)
{
// return gfw
if (this->gfw > 0.0)
@ -119,12 +119,12 @@ cxxISolutionComp::set_gfw()
{
/* use given chemical formula to calculate gfw */
double gfw;
if (compute_gfw(this->as.c_str(), &gfw) == ERROR)
if (P_INSTANCE_POINTER compute_gfw(this->as.c_str(), &gfw) == ERROR)
{
std::ostringstream oss;
oss << "Could not compute gfw, " << this->as;
error_msg(oss.str().c_str(), CONTINUE);
input_error++;
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
P_INSTANCE_POINTER input_error++;
return;
}
//if (this->description == "Alkalinity" && this->as == "CaCO3")
@ -138,7 +138,7 @@ cxxISolutionComp::set_gfw()
}
/* use gfw of master species */
std::string str(this->description);
struct master *master_ptr = master_bsearch(str.c_str());
struct master *master_ptr = P_INSTANCE_POINTER master_bsearch(str.c_str());
if (master_ptr != NULL)
{
/* use gfw for element redox state */
@ -147,8 +147,8 @@ cxxISolutionComp::set_gfw()
}
std::ostringstream oss;
oss << "Could not find gfw, " << this->description;
error_msg(oss.str().c_str(), CONTINUE);
input_error++;
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
P_INSTANCE_POINTER input_error++;
return;
}

View File

@ -5,7 +5,7 @@
#include <map> // std::map
#include <vector>
#include <set>
#include "Phreeqc_class.h"
// forward declarations
class cxxISolution; // reqd for read and dump_xml
@ -116,14 +116,14 @@ class cxxISolutionComp
{
this->gfw = gfw;
}
void set_gfw();
void set_gfw(PHREEQC_PTR_ARG);
bool operator<(const cxxISolutionComp & conc) const
{
return ::strcmp(this->description.c_str(), conc.description.c_str()) < 0;
}
static struct conc *cxxISolutionComp2conc(const std::map < std::string, cxxISolutionComp > &t);
static struct conc *cxxISolutionComp2conc(PHREEQC_PTR_ARG_COMMA const std::map < std::string, cxxISolutionComp > &t);
private:
std::string description;

View File

@ -133,7 +133,7 @@ cxxNameDouble::~cxxNameDouble()
}
struct elt_list *
cxxNameDouble::elt_list()
cxxNameDouble::elt_list(PHREEQC_PTR_ARG)
//
// Builds a exch_comp structure from instance of cxxNameDouble
//
@ -143,11 +143,11 @@ cxxNameDouble::elt_list()
(struct elt_list *)
PHRQ_malloc((size_t) ((this->size() + 1) * sizeof(struct elt_list)));
if (elt_list_ptr == NULL)
malloc_error();
P_INSTANCE_POINTER malloc_error();
int i = 0;
for (iterator it = this->begin(); it != this->end(); ++it)
{
elt_list_ptr[i].elt = element_store(it->first.c_str());
elt_list_ptr[i].elt = P_INSTANCE_POINTER element_store(it->first.c_str());
elt_list_ptr[i].coef = it->second;
i++;
}
@ -176,7 +176,7 @@ cxxNameDouble::master_activity() const
(((*this).size() +
1) * sizeof(struct master_activity)));
if (master_activity_ptr == NULL)
malloc_error();
P_INSTANCE_POINTER malloc_error();
for (const_iterator it = (*this).begin(); it != (*this).end();
it++)
{

View File

@ -7,7 +7,7 @@
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include "Phreeqc_class.h"
#include "Parser.h"
class cxxNameDouble:public
@ -34,7 +34,7 @@ class cxxNameDouble:public
cxxNameDouble();
struct elt_list *
elt_list();
elt_list(PHREEQC_PTR_ARG);
struct master_activity *
master_activity() const;

View File

@ -302,6 +302,7 @@ class CParser
ECHO_OPTION echo_file;
std::string accumulated;
bool accumulate;
//int const &input_error_parser;
};
// Global functions

View File

@ -16,7 +16,6 @@
#include <math.h>
#include <errno.h>
#include <float.h>
#include <assert.h>
#include <setjmp.h>
#include "phrqtype.h"
#include "sundialstypes.h"
@ -103,9 +102,8 @@ public:
/* integertype, and the constant FALSE */
public:
#include "output.h"
private:
public:
#include "global.h"
/*
All functions are included as methods here
*/
@ -437,7 +435,6 @@ static void Jac(integertype N, DenseMat J, RhsFn f, void *f_data, realtype t,
realtype uround, void *jac_data, long int *nfePtr,
N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
private:
int calc_final_kinetic_reaction(struct kinetics *kinetics_ptr);
int calc_kinetic_reaction(struct kinetics *kinetics_ptr,
LDBLE time_step);
@ -534,7 +531,6 @@ int get_secondary(char **t_ptr, char *element, int *i);
int get_species(char **ptr);
// phqalloc.c -------------------------------
public:
#if !defined(NDEBUG)
void *PHRQ_malloc(size_t, const char *, int);
@ -546,8 +542,9 @@ void *PHRQ_calloc(size_t, size_t);
void *PHRQ_realloc(void *, size_t);
#endif
void PHRQ_free(void *ptr);
private:
void PHRQ_free_all(void);
private:
// phreeqc_files.c -------------------------------
@ -1032,8 +1029,10 @@ struct logk *logk_search(char *name);
struct master *master_alloc(void);
CLASS_STATIC int master_compare(const void *ptr1, const void *ptr2);
int master_delete(char *ptr);
public:
struct master *master_bsearch(const char *ptr);
struct master *master_bsearch_primary(char *ptr);
private:
struct master *master_search(char *ptr, int *n);
struct mix *mix_bsearch(int k, int *n);
int mix_copy(struct mix *mix_old_ptr,
@ -1047,7 +1046,9 @@ struct pe_data *pe_data_alloc(void);
struct pe_data *pe_data_dup(struct pe_data *pe_ptr_old);
struct pe_data *pe_data_free(struct pe_data *pe_data_ptr);
int pe_data_store(struct pe_data **pe, const char *token);
public:
struct phase *phase_bsearch(const char *ptr, int *j, int print);
private:
CLASS_STATIC int phase_compare(const void *ptr1, const void *ptr2);
int phase_delete(int i);
struct phase *phase_store(char *name);
@ -1084,7 +1085,9 @@ CLASS_STATIC int s_compare(const void *ptr1, const void *ptr2);
int s_delete(int i);
struct species *s_search(const char *name);
struct species *s_store(char *name, LDBLE z, int replace_if_found);
struct s_s_assemblage *s_s_assemblage_alloc(void);
public:
struct s_s_assemblage *s_s_assemblage_alloc(void);
private:
struct s_s_assemblage *s_s_assemblage_bsearch(int k, int *n);
CLASS_STATIC int s_s_assemblage_compare(const void *ptr1, const void *ptr2);
@ -1112,7 +1115,9 @@ int save_values_store(struct save_values *s_v);
CLASS_STATIC int conc_compare(const void *ptr1, const void *ptr2);
int conc_init(struct conc *conc_ptr);
CLASS_STATIC int isotope_compare(const void *ptr1, const void *ptr2);
struct solution *solution_alloc(void);
public:
struct solution *solution_alloc(void);
private:
struct solution *solution_bsearch(int k, int *n, int print);
struct solution *solution_copy(struct solution *solution_old_ptr,
int n_user_new);
@ -1129,7 +1134,9 @@ CLASS_STATIC int species_list_compare_alk(const void *ptr1, const void *ptr2);
CLASS_STATIC int species_list_compare_master(const void *ptr1, const void *ptr2);
int species_list_sort(void);
struct Change_Surf *change_surf_alloc(int count);
struct surface *surface_alloc(void);
public:
struct surface *surface_alloc(void);
private:
struct surface *surface_bsearch(int k, int *n);
struct master *surface_get_psi_master(const char *name, int plane);
CLASS_STATIC int surface_comp_compare(const void *ptr1, const void *ptr2);
@ -1312,21 +1319,29 @@ int mix_stag(int i, LDBLE stagkin_time, int punch,
int add_elt_list(struct elt_list *elt_list_ptr, LDBLE coef);
int backspace_screen(int spaces);
LDBLE calc_alk(struct reaction *rxn_ptr);
int compute_gfw(const char *string, LDBLE * gfw);
public:
int compute_gfw(const char *string, LDBLE * gfw);
private:
int copy_token(char *token_ptr, char **ptr, int *length);
int dup_print(const char *ptr, int emphasis);
int equal(LDBLE a, LDBLE b, LDBLE eps);
void *free_check_null(void *ptr);
public:
void *free_check_null(void *ptr);
private:
void free_hash_strings(HashTable * Table);
int get_token(char **eqnaddr, char *string, LDBLE * z, int *l);
int hcreate_multi(unsigned Count, HashTable ** HashTable_ptr);
void hdestroy_multi(HashTable * HashTable_ptr);
ENTRY *hsearch_multi(HashTable * Table, ENTRY item, ACTION action);
int islegit(const char c);
public:
void malloc_error(void);
private:
int parse_couple(char *token);
int print_centered(const char *string);
int replace(const char *str1, const char *str2, char *str);
public:
CLASS_STATIC int replace(const char *str1, const char *str2, char *str);
private:
void space(void **ptr, int i, int *max, int struct_size);
void squeeze_white(char *s_l);
int status(int count, const char *str);
@ -1334,8 +1349,10 @@ void str_tolower(char *str);
void str_toupper(char *str);
CLASS_STATIC int strcmp_nocase(const char *str1, const char *str2);
int strcmp_nocase_arg1(const char *str1, const char *str2);
char *string_duplicate(const char *token);
char *string_hsave(const char *str);
public:
char *string_duplicate(const char *token);
char *string_hsave(const char *str);
private:
char *string_pad(char *str, int i);
int string_trim(char *str);
int string_trim_right(char *str);

View File

@ -77,7 +77,7 @@ cxxReaction::~cxxReaction()
struct irrev *
cxxReaction::cxxReaction2irrev()
cxxReaction::cxxReaction2irrev(PHREEQC_PTR_ARG)
//
// Builds a irrev structure from instance of cxxReaction
//
@ -85,7 +85,7 @@ cxxReaction::cxxReaction2irrev()
struct irrev *irrev_ptr;
irrev_ptr = (struct irrev *) PHRQ_malloc(sizeof(struct irrev));
if (irrev_ptr == NULL)
malloc_error();
P_INSTANCE_POINTER malloc_error();
irrev_ptr->description = this->get_description();
irrev_ptr->n_user = this->n_user;
@ -95,7 +95,7 @@ cxxReaction::cxxReaction2irrev()
irrev_ptr->count_list = (int) this->reactantList.size();
if (this->elementList.size() > 0)
{
irrev_ptr->elts = this->elementList.elt_list();
irrev_ptr->elts = this->elementList.elt_list(P_INSTANCE);
}
else
{
@ -110,7 +110,7 @@ cxxReaction::cxxReaction2irrev()
(double *)
PHRQ_malloc((size_t) (this->steps.size() * sizeof(double)));
if (irrev_ptr->steps == NULL)
malloc_error();
P_INSTANCE_POINTER malloc_error();
std::copy(this->steps.begin(), this->steps.end(), irrev_ptr->steps);
}
if (this->equalIncrements)
@ -124,7 +124,7 @@ cxxReaction::cxxReaction2irrev()
if (this->units.size() == 0)
irrev_ptr->units = NULL;
else
irrev_ptr->units = string_hsave(this->units.c_str());
irrev_ptr->units = P_INSTANCE_POINTER string_hsave(this->units.c_str());
return (irrev_ptr);
}

View File

@ -18,7 +18,7 @@ class cxxReaction:public cxxNumKeyword
cxxReaction(struct irrev *);
~cxxReaction();
struct irrev *cxxReaction2irrev();
struct irrev *cxxReaction2irrev(PHREEQC_PTR_ARG);
//void dump_xml(std::ostream& os, unsigned int indent = 0)const;

View File

@ -79,12 +79,12 @@ cxxSSassemblage::~cxxSSassemblage()
}
struct s_s_assemblage *
cxxSSassemblage::cxxSSassemblage2s_s_assemblage()
cxxSSassemblage::cxxSSassemblage2s_s_assemblage(PHREEQC_PTR_ARG)
//
// Builds a s_s_assemblage structure from instance of cxxSSassemblage
//
{
struct s_s_assemblage *s_s_assemblage_ptr = s_s_assemblage_alloc();
struct s_s_assemblage *s_s_assemblage_ptr = P_INSTANCE_POINTER s_s_assemblage_alloc();
s_s_assemblage_ptr->description = this->get_description();
s_s_assemblage_ptr->n_user = this->n_user;
@ -92,7 +92,7 @@ cxxSSassemblage::cxxSSassemblage2s_s_assemblage()
s_s_assemblage_ptr->new_def = FALSE;
s_s_assemblage_ptr->count_s_s = (int) this->ssAssemblageSSs.size();
s_s_assemblage_ptr->s_s =
cxxSSassemblageSS::cxxSSassemblageSS2s_s(this->ssAssemblageSSs);
cxxSSassemblageSS::cxxSSassemblageSS2s_s(P_INSTANCE_COMMA this->ssAssemblageSSs);
return (s_s_assemblage_ptr);
}
@ -312,14 +312,14 @@ cxxSSassemblage::mpi_unpack(int *ints, int *ii, double *doubles, int *dd)
#endif
void
cxxSSassemblage::totalize()
cxxSSassemblage::totalize(PHREEQC_PTR_ARG)
{
this->totals.clear();
// component structures
for (std::map < std::string, cxxSSassemblageSS >::iterator it =
ssAssemblageSSs.begin(); it != ssAssemblageSSs.end(); ++it)
{
(*it).second.totalize();
(*it).second.totalize(P_INSTANCE);
this->totals.add_extensive((*it).second.get_totals(), 1.0);
}
return;

View File

@ -8,6 +8,7 @@
#include <list> // std::list
#include <vector> // std::vector
#include "Phreeqc_class.h"
#include "NumKeyword.h"
#include "NameDouble.h"
class cxxSSassemblageSS;
@ -25,7 +26,7 @@ public:
cxxMix & mx, int n_user);
~cxxSSassemblage();
struct s_s_assemblage *cxxSSassemblage2s_s_assemblage();
struct s_s_assemblage *cxxSSassemblage2s_s_assemblage(PHREEQC_PTR_ARG);
struct s_s *cxxSSassemblageComp2s_s();

View File

@ -77,7 +77,7 @@ cxxSSassemblageSS::~cxxSSassemblageSS()
}
struct s_s *
cxxSSassemblageSS::cxxSSassemblageSS2s_s(std::map < std::string, cxxSSassemblageSS > &el)
cxxSSassemblageSS::cxxSSassemblageSS2s_s(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxSSassemblageSS > &el)
//
// Builds s_s structure from of cxxSSassemblageSS
//
@ -89,12 +89,12 @@ cxxSSassemblageSS::cxxSSassemblageSS2s_s(std::map < std::string, cxxSSassemblage
struct s_s *s_s_ptr =
(struct s_s *) PHRQ_malloc((size_t) (el.size() * sizeof(struct s_s)));
if (s_s_ptr == NULL)
malloc_error();
P_INSTANCE_POINTER malloc_error();
int j = 0;
for (std::map < std::string, cxxSSassemblageSS >::iterator it = el.begin();
it != el.end(); ++it)
{
s_s_ptr[j].name = string_hsave((*it).second.name.c_str());
s_s_ptr[j].name = P_INSTANCE_POINTER string_hsave((*it).second.name.c_str());
assert((*it).second.name.size() > 0);
//s_s_ptr[j].total_moles = it->total_moles;
s_s_ptr[j].total_moles = 0;
@ -132,13 +132,13 @@ cxxSSassemblageSS::cxxSSassemblageSS2s_s(std::map < std::string, cxxSSassemblage
PHRQ_malloc((size_t)
((*it).second.comps.size() * sizeof(struct s_s_comp)));
if (s_s_comp_ptr == NULL)
malloc_error();
P_INSTANCE_POINTER malloc_error();
for (cxxNameDouble::iterator itc = (*it).second.comps.begin();
itc != (*it).second.comps.end(); ++itc)
{
s_s_comp_ptr[i].name = string_hsave(itc->first.c_str());
s_s_comp_ptr[i].name = P_INSTANCE_POINTER string_hsave(itc->first.c_str());
assert(itc->first.size() > 0);
s_s_comp_ptr[i].phase = phase_bsearch(itc->first.c_str(), &n, TRUE);
s_s_comp_ptr[i].phase = P_INSTANCE_POINTER phase_bsearch(itc->first.c_str(), &n, TRUE);
s_s_comp_ptr[i].initial_moles = 0;
s_s_comp_ptr[i].moles = itc->second;
s_s_comp_ptr[i].init_moles = 0;
@ -541,7 +541,7 @@ cxxSSassemblageSS::mpi_unpack(int *ints, int *ii, double *doubles, int *dd)
#endif
void
cxxSSassemblageSS::totalize()
cxxSSassemblageSS::totalize(PHREEQC_PTR_ARG)
{
this->totals.clear();
// component structures
@ -550,7 +550,7 @@ cxxSSassemblageSS::totalize()
{
struct phase *phase_ptr;
int l;
phase_ptr = phase_bsearch(it->first.c_str(), &l, FALSE);
phase_ptr = P_INSTANCE_POINTER phase_bsearch(it->first.c_str(), &l, FALSE);
if (phase_ptr != NULL)
{
cxxNameDouble phase_formula(phase_ptr->next_elt);

View File

@ -8,6 +8,7 @@
#include <vector> // std::vector
#include "NameDouble.h"
#include "Phreeqc_class.h"
class cxxSSassemblageSS
{
@ -32,7 +33,7 @@ class cxxSSassemblageSS
SS_PARM_MARGULES = 9
};
static struct s_s *cxxSSassemblageSS2s_s(std::map < std::string, cxxSSassemblageSS >
static struct s_s *cxxSSassemblageSS2s_s(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxSSassemblageSS >
&el);
void dump_xml(std::ostream & os, unsigned int indent = 0) const;
@ -53,7 +54,7 @@ class cxxSSassemblageSS
this->name.clear();
}
void totalize();
void totalize(PHREEQC_PTR_ARG);
const cxxNameDouble & get_totals() const
{
return (this->totals);

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
#include <string> // std::string
#include <vector> // std::vector
#include <iostream>
#include "Phreeqc_class.h"
#include "NumKeyword.h"
#include "SolutionIsotopeList.h"
#include "NameDouble.h"
@ -18,8 +18,8 @@ class cxxSolution:public cxxNumKeyword
public:
cxxSolution();
cxxSolution(struct solution *);
cxxSolution(int n_user);
cxxSolution(const std::map < int, cxxSolution > &solution_map,
cxxSolution(PHREEQC_PTR_ARG_COMMA int n_user);
cxxSolution(PHREEQC_PTR_ARG_COMMA const std::map < int, cxxSolution > &solution_map,
cxxMix & mx, int n_user);
~cxxSolution();
@ -148,7 +148,7 @@ class cxxSolution:public cxxNumKeyword
void set_isotope(char *string, double value);
*/
struct solution *cxxSolution2solution();
struct solution *cxxSolution2solution(PHREEQC_PTR_ARG);
void dump_raw(std::ostream & s_oss, unsigned int indent) const;

View File

@ -36,7 +36,7 @@ cxxSolutionIsotope::~cxxSolutionIsotope(void)
}
struct isotope *
cxxSolutionIsotope::list2isotope(std::list < cxxSolutionIsotope > &isolist)
cxxSolutionIsotope::list2isotope(PHREEQC_PTR_ARG_COMMA std::list < cxxSolutionIsotope > &isolist)
// takes a std::list of cxxSolutionIsotope structures
// returns array of isotope structures
{
@ -51,18 +51,18 @@ cxxSolutionIsotope::list2isotope(std::list < cxxSolutionIsotope > &isolist)
(struct isotope *)
PHRQ_malloc((size_t) ((isolist.size()) * sizeof(struct isotope)));
if (iso == NULL)
malloc_error();
P_INSTANCE_POINTER malloc_error();
int i = 0;
for (std::list < cxxSolutionIsotope >::iterator it = isolist.begin();
it != isolist.end(); ++it)
{
iso[i].isotope_number = it->isotope_number;
iso[i].elt_name = string_hsave(it->elt_name.c_str());
iso[i].elt_name = P_INSTANCE_POINTER string_hsave(it->elt_name.c_str());
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();
iso[i].master = it->master(P_INSTANCE);
iso[i].primary = it->primary(P_INSTANCE);
i++;
}
}
@ -213,16 +213,16 @@ cxxSolutionIsotope::operator<(const cxxSolutionIsotope & isotope) const
}
struct master *
cxxSolutionIsotope::master(void)
cxxSolutionIsotope::master(PHREEQC_PTR_ARG)
{
return (master_bsearch(this->elt_name.c_str()));
return (P_INSTANCE_POINTER master_bsearch(this->elt_name.c_str()));
}
struct master *
cxxSolutionIsotope::primary(void)
cxxSolutionIsotope::primary(PHREEQC_PTR_ARG)
{
char * str = string_hsave(this->elt_name.c_str());
return (master_bsearch_primary(str));
char * str = P_INSTANCE_POINTER string_hsave(this->elt_name.c_str());
return (P_INSTANCE_POINTER master_bsearch_primary(str));
}
void

View File

@ -5,6 +5,7 @@
#include <string> // std::string
#include <list> // std::list
#include "Parser.h"
#include "Phreeqc_class.h"
class cxxSolutionIsotope
{
@ -20,7 +21,7 @@ class cxxSolutionIsotope
};
*/
//cxxSolutionIsotope::STATUS read(CParser& parser);
static struct isotope *list2isotope(std::list < cxxSolutionIsotope > &t);
static struct isotope *list2isotope(PHREEQC_PTR_ARG_COMMA std::list < cxxSolutionIsotope > &t);
void dump_xml(std::ostream & os, unsigned int indent) const;
void dump_raw(std::ostream & os, unsigned int indent) const;
@ -83,8 +84,8 @@ class cxxSolutionIsotope
bool operator<(const cxxSolutionIsotope & conc) const;
struct master *master(void);
struct master *primary(void);
struct master *master(PHREEQC_PTR_ARG);
struct master *primary(PHREEQC_PTR_ARG);
void add(const cxxSolutionIsotope & isotope_ptr, double intensive,
double extensive);

View File

@ -85,7 +85,7 @@ cxxSolutionIsotopeList::multiply(double extensive)
}
}
struct isotope *
cxxSolutionIsotopeList::cxxSolutionIsotopeList2isotope()
cxxSolutionIsotopeList::cxxSolutionIsotopeList2isotope(PHREEQC_PTR_ARG)
{
struct isotope *iso;
if (this->size() <= 0)
@ -98,18 +98,18 @@ cxxSolutionIsotopeList::cxxSolutionIsotopeList2isotope()
(struct isotope *)
PHRQ_malloc((size_t) ((this->size()) * sizeof(struct isotope)));
if (iso == NULL)
malloc_error();
P_INSTANCE_POINTER 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 = string_hsave(it->elt_name.c_str());
iso[i].elt_name = P_INSTANCE_POINTER string_hsave(it->elt_name.c_str());
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();
iso[i].master = it->master(P_INSTANCE);
iso[i].primary = it->primary(P_INSTANCE);
i++;
}
}

View File

@ -6,6 +6,7 @@
#include <list> // std::list
#include "SolutionIsotope.h"
#include "Phreeqc_class.h"
class cxxSolutionIsotopeList:public
std::list < cxxSolutionIsotope >
@ -18,7 +19,7 @@ public:
~cxxSolutionIsotopeList();
struct isotope * cxxSolutionIsotopeList2isotope();
struct isotope * cxxSolutionIsotopeList2isotope(PHREEQC_PTR_ARG);
void add(cxxSolutionIsotopeList oldlist, double intensive, double extensive);
void multiply(double extensive);

View File

@ -6,7 +6,7 @@
#endif
#include <cassert> // assert
#include <algorithm> // std::sort
#include "Phreeqc_class.h"
#include "Utils.h" // define first
#if !defined(PHREEQC_CLASS)
#define EXTERNAL extern
@ -143,12 +143,12 @@ cxxSurface::get_related_rate()
}
struct surface *
cxxSurface::cxxSurface2surface()
cxxSurface::cxxSurface2surface(PHREEQC_PTR_ARG)
//
// Builds a surface structure from instance of cxxSurface
//
{
struct surface *surface_ptr = surface_alloc();
struct surface *surface_ptr = P_INSTANCE_POINTER surface_alloc();
surface_ptr->description = this->get_description();
surface_ptr->n_user = this->n_user;
@ -175,19 +175,19 @@ cxxSurface::cxxSurface2surface()
// Surface comps
surface_ptr->count_comps = (int) this->surfaceComps.size();
surface_ptr->comps =
(struct surface_comp *) free_check_null(surface_ptr->comps);
(struct surface_comp *) P_INSTANCE_POINTER free_check_null(surface_ptr->comps);
surface_ptr->comps =
cxxSurfaceComp::cxxSurfaceComp2surface_comp(this->surfaceComps);
// Surface charge
surface_ptr->charge =
(struct surface_charge *) free_check_null(surface_ptr->charge);
(struct surface_charge *) P_INSTANCE_POINTER free_check_null(surface_ptr->charge);
//if (surface_ptr->edl == TRUE) {
if (surface_ptr->type == DDL || surface_ptr->type == CD_MUSIC)
{
surface_ptr->count_charge = (int) this->surfaceCharges.size();
surface_ptr->charge =
cxxSurfaceCharge::cxxSurfaceCharge2surface_charge(this->surfaceCharges);
cxxSurfaceCharge::cxxSurfaceCharge2surface_charge(P_INSTANCE_COMMA this->surfaceCharges);
}
else
{
@ -199,7 +199,7 @@ cxxSurface::cxxSurface2surface()
int i, j;
for (i = 0; i < surface_ptr->count_comps; i++)
{
char *charge_name = string_hsave(
char *charge_name = P_INSTANCE_POINTER string_hsave(
cxxSurfaceComp::get_charge_name(surface_ptr->comps[i].
formula).c_str());
for (j = 0; j < surface_ptr->count_charge; j++)

View File

@ -26,9 +26,9 @@ class cxxSurface:public cxxNumKeyword
//enum SURFACE_DL_TYPE { NO_DL, BORKOVEC_DL, DONNAN_DL } ;
//enum SURFACE_SITES_UNITS { SITES_ABSOLUTE, SITES_DENSITY } ;
struct surface *cxxSurface2surface();
struct surface *cxxSurface2surface(PHREEQC_PTR_ARG);
struct surf_comp *cxxSurfaceComp2surf_comp();
struct surf_comp *cxxSurfaceComp2surf_comp(PHREEQC_PTR_ARG);
void dump_xml(std::ostream & os, unsigned int indent = 0) const;

View File

@ -64,27 +64,27 @@ cxxSurfaceCharge::~cxxSurfaceCharge()
{
}
struct master *
cxxSurfaceCharge::get_psi_master()
{
struct master *master_ptr = NULL;
std::string str = this->name;
str.append("_psi");
master_ptr = master_bsearch(str.c_str());
if (master_ptr == NULL)
{
std::ostringstream error_oss;
error_oss << "Surface charge psi_master not found." << this->
name << std::endl;
//Utilities::error_msg(error_oss.str(), CONTINUE);
error_msg(error_oss.str().c_str(), CONTINUE);
}
return (master_ptr);
}
//struct master *
//cxxSurfaceCharge::get_psi_master()
//{
// struct master *master_ptr = NULL;
// std::string str = this->name;
//
// str.append("_psi");
// master_ptr = master_bsearch(str.c_str());
// if (master_ptr == NULL)
// {
// std::ostringstream error_oss;
// error_oss << "Surface charge psi_master not found." << this->
// name << std::endl;
// //Utilities::error_msg(error_oss.str(), CONTINUE);
// error_msg(error_oss.str().c_str(), CONTINUE);
// }
// return (master_ptr);
//}
struct surface_charge *
cxxSurfaceCharge::cxxSurfaceCharge2surface_charge(std::map < std::string, cxxSurfaceCharge > &el)
cxxSurfaceCharge::cxxSurfaceCharge2surface_charge(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxSurfaceCharge > &el)
//
// Builds surface_charge structure from of cxxSurfaceCharge
//
@ -93,13 +93,13 @@ cxxSurfaceCharge::cxxSurfaceCharge2surface_charge(std::map < std::string, cxxSur
(struct surface_charge *)
PHRQ_malloc((size_t) (el.size() * sizeof(struct surface_charge)));
if (surf_charge_ptr == NULL)
malloc_error();
P_INSTANCE_POINTER malloc_error();
int i = 0;
for (std::map < std::string, cxxSurfaceCharge >::iterator it = el.begin();
it != el.end(); ++it)
{
surf_charge_ptr[i].name = string_hsave((*it).second.name.c_str());
surf_charge_ptr[i].name = P_INSTANCE_POINTER string_hsave((*it).second.name.c_str());
assert((*it).second.name.size() > 0);
surf_charge_ptr[i].specific_area = (*it).second.specific_area;
surf_charge_ptr[i].grams = (*it).second.grams;
@ -114,7 +114,7 @@ cxxSurfaceCharge::cxxSurfaceCharge2surface_charge(std::map < std::string, cxxSur
surf_charge_ptr[i].sigma1 = 0;
surf_charge_ptr[i].sigma2 = 0;
surf_charge_ptr[i].sigmaddl = 0;
surf_charge_ptr[i].diffuse_layer_totals = (*it).second.diffuse_layer_totals.elt_list();
surf_charge_ptr[i].diffuse_layer_totals = (*it).second.diffuse_layer_totals.elt_list(P_INSTANCE);
//surf_charge_ptr[i].psi_master = it->get_psi_master();
surf_charge_ptr[i].count_g = 0;
surf_charge_ptr[i].g = NULL;

View File

@ -8,6 +8,7 @@
#include <vector> // std::vector
#include "NameDouble.h"
#include "Phreeqc_class.h"
class cxxSurfaceCharge
{
@ -21,7 +22,7 @@ public:
struct master *get_psi_master();
static struct surface_charge *cxxSurfaceCharge2surface_charge(std::map < std::string, cxxSurfaceCharge > &el);
static struct surface_charge *cxxSurfaceCharge2surface_charge(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxSurfaceCharge > &el);
void dump_xml(std::ostream & os, unsigned int indent = 0) const;

View File

@ -65,7 +65,7 @@ cxxSurfaceComp::~cxxSurfaceComp()
}
struct master *
cxxSurfaceComp::get_master()
cxxSurfaceComp::get_master(PHREEQC_PTR_ARG)
{
struct master *master_ptr = NULL;
//for (std::map <char *, double, CHARSTAR_LESS>::iterator it = totals.begin(); it != totals.end(); it++) {
@ -73,16 +73,16 @@ struct master *
it != this->totals.end(); it++)
{
/* Find master species */
char *eltName = string_hsave(it->first.c_str());
char *eltName = P_INSTANCE_POINTER string_hsave(it->first.c_str());
assert(it->first.size() > 0);
struct element *elt_ptr = element_store(eltName);
struct element *elt_ptr = P_INSTANCE_POINTER element_store(eltName);
if (elt_ptr->master == NULL)
{
std::ostringstream error_oss;
error_oss << "Master species not in data base for " << elt_ptr->
name << std::endl;
//Utilities::error_msg(error_oss.str(), CONTINUE);
error_msg(error_oss.str().c_str(), CONTINUE);
P_INSTANCE_POINTER error_msg(error_oss.str().c_str(), CONTINUE);
return (NULL);
}
if (elt_ptr->master->type != SURF)
@ -97,7 +97,7 @@ struct master *
"Surface formula does not contain an surface master species, " <<
this->formula << std::endl;
//Utilities::error_msg(error_oss.str(), CONTINUE);
error_msg(error_oss.str().c_str(), CONTINUE);
P_INSTANCE_POINTER error_msg(error_oss.str().c_str(), CONTINUE);
}
return (master_ptr);
}

View File

@ -18,7 +18,7 @@ public:
cxxSurfaceComp(struct surface_comp *);
~cxxSurfaceComp();
struct master *get_master();
struct master *get_master(PHREEQC_PTR_ARG);
const std::string &get_phase_name() const;
void set_phase_name(char * f);
const std::string &get_rate_name() const;

View File

@ -73,16 +73,16 @@ cxxTemperature::~cxxTemperature()
struct temperature *
cxxTemperature::cxxTemperature2temperature()
cxxTemperature::cxxTemperature2temperature(PHREEQC_PTR_ARG)
//
// Builds a temperature structure from instance of cxxTemperature
//
{
struct temperature *temperature_ptr;
temperature_ptr =
(struct temperature *) PHRQ_malloc(sizeof(struct temperature));
(struct temperature *) P_INSTANCE_POINTER PHRQ_malloc(sizeof(struct temperature));
if (temperature_ptr == NULL)
malloc_error();
P_INSTANCE_POINTER malloc_error();
temperature_ptr->description = this->get_description();
temperature_ptr->n_user = this->n_user;
@ -96,7 +96,7 @@ cxxTemperature::cxxTemperature2temperature()
(double *)
PHRQ_malloc((size_t) (this->temps.size() * sizeof(double)));
if (temperature_ptr->t == NULL)
malloc_error();
P_INSTANCE_POINTER malloc_error();
std::copy(this->temps.begin(), this->temps.end(), temperature_ptr->t);
}
if (this->equalIncrements)

View File

@ -8,6 +8,7 @@
#include <vector> // std::vector
#include "NumKeyword.h"
#include "Phreeqc_class.h"
class cxxTemperature:public cxxNumKeyword
{
@ -17,7 +18,7 @@ class cxxTemperature:public cxxNumKeyword
cxxTemperature(struct temperature *);
~cxxTemperature();
struct temperature *cxxTemperature2temperature();
struct temperature *cxxTemperature2temperature(PHREEQC_PTR_ARG);
//void dump_xml(std::ostream& os, unsigned int indent = 0)const;

15
phreeqc_class.h Normal file
View File

@ -0,0 +1,15 @@
#if !defined PHREEQC_CLASS
#define P_INSTANCE
#define P_INSTANCE_COMMA
#define P_INSTANCE_POINTER
#define PHREEQC_PTR_ARG
#define PHREEQC_PTR_ARG_COMMA
#else
#define P_INSTANCE p_instance
#define P_INSTANCE_COMMA p_instance,
#define P_INSTANCE_POINTER p_instance->
#define PHREEQC_PTR_ARG Phreeqc *p_instance
#define PHREEQC_PTR_ARG_COMMA Phreeqc *p_instance,
#endif
//#include "Phreeqc_class.h"