renamed *M routines without the M

git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/branches/class@4223 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
Scott R Charlton 2010-04-07 21:30:49 +00:00
parent 094d4c0684
commit 1daa55e41c
2 changed files with 72 additions and 61 deletions

View File

@ -3,6 +3,17 @@
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
class IPhreeqcLib
{
public:
static int CreateIPhreeqc(void);
static IPQ_RESULT DestroyIPhreeqc(int n);
static IPhreeqc2* GetInstance(int n);
private:
static std::map<size_t, IPhreeqc2*> Instances;
static size_t InstancesIndex;
};
int int
CreateIPhreeqc(void) CreateIPhreeqc(void)
@ -17,7 +28,7 @@ DestroyIPhreeqc(int id)
} }
int int
LoadDatabaseM(int id, const char* filename) LoadDatabase(int id, const char* filename)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -28,7 +39,7 @@ LoadDatabaseM(int id, const char* filename)
} }
int int
LoadDatabaseStringM(int id, const char* input) LoadDatabaseString(int id, const char* input)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -39,7 +50,7 @@ LoadDatabaseStringM(int id, const char* input)
} }
int int
UnLoadDatabaseM(int id) UnLoadDatabase(int id)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -51,7 +62,7 @@ UnLoadDatabaseM(int id)
} }
void void
OutputLastErrorM(int id) OutputLastError(int id)
{ {
static const char err_msg[] = "OutputLastError: Bad instance.\n"; static const char err_msg[] = "OutputLastError: Bad instance.\n";
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
@ -64,7 +75,7 @@ OutputLastErrorM(int id)
} }
const char* const char*
GetLastErrorStringM(int id) GetLastErrorString(int id)
{ {
static const char err_msg[] = "GetLastErrorString: Bad instance.\n"; static const char err_msg[] = "GetLastErrorString: Bad instance.\n";
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
@ -76,7 +87,7 @@ GetLastErrorStringM(int id)
} }
const char* const char*
GetDumpStringM(int id) GetDumpString(int id)
{ {
static const char empty[] = ""; static const char empty[] = "";
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
@ -88,7 +99,7 @@ GetDumpStringM(int id)
} }
int int
GetDumpLineCountM(int id) GetDumpLineCount(int id)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -99,7 +110,7 @@ GetDumpLineCountM(int id)
} }
const char* const char*
GetDumpLineM(int id, int n) GetDumpLine(int id, int n)
{ {
static const char err_msg[] = "GetDumpLine: Bad instance.\n"; static const char err_msg[] = "GetDumpLine: Bad instance.\n";
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
@ -111,7 +122,7 @@ GetDumpLineM(int id, int n)
} }
int int
GetComponentCountM(int id) GetComponentCount(int id)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -122,7 +133,7 @@ GetComponentCountM(int id)
} }
const char* const char*
GetComponentM(int id, int n) GetComponent(int id, int n)
{ {
static const char err_msg[] = "GetComponent: Bad instance.\n"; static const char err_msg[] = "GetComponent: Bad instance.\n";
static const char empty[] = ""; static const char empty[] = "";
@ -148,7 +159,7 @@ GetComponentM(int id, int n)
} }
IPQ_RESULT IPQ_RESULT
AccumulateLineM(int id, const char *line) AccumulateLine(int id, const char *line)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -167,7 +178,7 @@ AccumulateLineM(int id, const char *line)
} }
int int
GetSelectedOutputOnM(int id) GetSelectedOutputOn(int id)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -185,7 +196,7 @@ GetSelectedOutputOnM(int id)
} }
IPQ_RESULT IPQ_RESULT
SetSelectedOutputOnM(int id, int value) SetSelectedOutputOn(int id, int value)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -197,7 +208,7 @@ SetSelectedOutputOnM(int id, int value)
} }
int int
GetOutputOnM(int id) GetOutputOn(int id)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -215,7 +226,7 @@ GetOutputOnM(int id)
} }
IPQ_RESULT IPQ_RESULT
SetOutputOnM(int id, int value) SetOutputOn(int id, int value)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -227,7 +238,7 @@ SetOutputOnM(int id, int value)
} }
int int
GetErrorOnM(int id) GetErrorOn(int id)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -245,7 +256,7 @@ GetErrorOnM(int id)
} }
IPQ_RESULT IPQ_RESULT
SetErrorOnM(int id, int value) SetErrorOn(int id, int value)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -257,7 +268,7 @@ SetErrorOnM(int id, int value)
} }
int int
GetLogOnM(int id) GetLogOn(int id)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -275,7 +286,7 @@ GetLogOnM(int id)
} }
IPQ_RESULT IPQ_RESULT
SetLogOnM(int id, int value) SetLogOn(int id, int value)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -288,7 +299,7 @@ SetLogOnM(int id, int value)
int int
GetDumpOnM(int id) GetDumpOn(int id)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -306,7 +317,7 @@ GetDumpOnM(int id)
} }
IPQ_RESULT IPQ_RESULT
SetDumpOnM(int id, int value) SetDumpOn(int id, int value)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -318,7 +329,7 @@ SetDumpOnM(int id, int value)
} }
int int
GetDumpStringOnM(int id) GetDumpStringOn(int id)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -336,7 +347,7 @@ GetDumpStringOnM(int id)
} }
IPQ_RESULT IPQ_RESULT
SetDumpStringOnM(int id, int value) SetDumpStringOn(int id, int value)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -348,7 +359,7 @@ SetDumpStringOnM(int id, int value)
} }
int int
RunAccumulatedM(int id) RunAccumulated(int id)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -359,7 +370,7 @@ RunAccumulatedM(int id)
} }
int int
RunFileM(int id, const char* filename) RunFile(int id, const char* filename)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -370,7 +381,7 @@ RunFileM(int id, const char* filename)
} }
int int
RunStringM(int id, const char* input) RunString(int id, const char* input)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -381,7 +392,7 @@ RunStringM(int id, const char* input)
} }
int int
GetSelectedOutputRowCountM(int id) GetSelectedOutputRowCount(int id)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -392,7 +403,7 @@ GetSelectedOutputRowCountM(int id)
} }
int int
GetSelectedOutputColumnCountM(int id) GetSelectedOutputColumnCount(int id)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -404,7 +415,7 @@ GetSelectedOutputColumnCountM(int id)
IPQ_RESULT IPQ_RESULT
GetSelectedOutputValueM(int id, int row, int col, VAR* pVAR) GetSelectedOutputValue(int id, int row, int col, VAR* pVAR)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -425,7 +436,7 @@ GetSelectedOutputValueM(int id, int row, int col, VAR* pVAR)
} }
int int
AddErrorM(int id, const char* error_msg) AddError(int id, const char* error_msg)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -436,7 +447,7 @@ AddErrorM(int id, const char* error_msg)
} }
void void
OutputLinesM(int id) OutputLines(int id)
{ {
static const char err_msg[] = "OutputLines: Bad instance.\n"; static const char err_msg[] = "OutputLines: Bad instance.\n";
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
@ -449,7 +460,7 @@ OutputLinesM(int id)
} }
int int
GetErrorLineCountM(int id) GetErrorLineCount(int id)
{ {
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
if (IPhreeqcPtr) if (IPhreeqcPtr)
@ -460,7 +471,7 @@ GetErrorLineCountM(int id)
} }
const char* const char*
GetErrorLineM(int id, int n) GetErrorLine(int id, int n)
{ {
static const char err_msg[] = "GetErrorLine: Bad instance.\n"; static const char err_msg[] = "GetErrorLine: Bad instance.\n";
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);

View File

@ -83,11 +83,11 @@ LoadDatabaseF(int *id, char* filename, unsigned int filename_length)
cfilename = f2cstring(filename, filename_length); cfilename = f2cstring(filename, filename_length);
if (!cfilename) if (!cfilename)
{ {
::AddErrorM(*id, "LoadDatabase: Out of memory.\n"); ::AddError(*id, "LoadDatabase: Out of memory.\n");
return VR_OUTOFMEMORY; return VR_OUTOFMEMORY;
} }
int n = ::LoadDatabaseM(*id, cfilename); int n = ::LoadDatabase(*id, cfilename);
free(cfilename); free(cfilename);
return n; return n;
} }
@ -100,11 +100,11 @@ LoadDatabaseStringF(int *id, char* input, unsigned int input_length)
cinput = f2cstring(input, input_length); cinput = f2cstring(input, input_length);
if (!cinput) if (!cinput)
{ {
::AddErrorM(*id, "LoadDatabaseString: Out of memory.\n"); ::AddError(*id, "LoadDatabaseString: Out of memory.\n");
return VR_OUTOFMEMORY; return VR_OUTOFMEMORY;
} }
int n = ::LoadDatabaseStringM(*id, cinput); int n = ::LoadDatabaseString(*id, cinput);
free(cinput); free(cinput);
return n; return n;
} }
@ -118,11 +118,11 @@ AccumulateLineF(int *id, char *line, unsigned int line_length)
cline = f2cstring(line, line_length); cline = f2cstring(line, line_length);
if (!cline) if (!cline)
{ {
::AddErrorM(*id, "AccumulateLine: Out of memory.\n"); ::AddError(*id, "AccumulateLine: Out of memory.\n");
return IPQ_OUTOFMEMORY; return IPQ_OUTOFMEMORY;
} }
n = ::AccumulateLineM(*id, cline); n = ::AccumulateLine(*id, cline);
free(cline); free(cline);
return n; return n;
} }
@ -130,79 +130,79 @@ AccumulateLineF(int *id, char *line, unsigned int line_length)
IPQ_RESULT IPQ_RESULT
SetSelectedOutputOnF(int *id, int* sel_on) SetSelectedOutputOnF(int *id, int* sel_on)
{ {
return ::SetSelectedOutputOnM(*id, *sel_on); return ::SetSelectedOutputOn(*id, *sel_on);
} }
IPQ_RESULT IPQ_RESULT
SetOutputOnF(int *id, int* output_on) SetOutputOnF(int *id, int* output_on)
{ {
return ::SetOutputOnM(*id, *output_on); return ::SetOutputOn(*id, *output_on);
} }
IPQ_RESULT IPQ_RESULT
SetErrorOnF(int *id, int* error_on) SetErrorOnF(int *id, int* error_on)
{ {
return ::SetErrorOnM(*id, *error_on); return ::SetErrorOn(*id, *error_on);
} }
IPQ_RESULT IPQ_RESULT
SetLogOnF(int *id, int* log_on) SetLogOnF(int *id, int* log_on)
{ {
return ::SetLogOnM(*id, *log_on); return ::SetLogOn(*id, *log_on);
} }
IPQ_RESULT IPQ_RESULT
SetDumpOnF(int *id, int* dump_on) SetDumpOnF(int *id, int* dump_on)
{ {
return ::SetDumpOnM(*id, *dump_on); return ::SetDumpOn(*id, *dump_on);
} }
IPQ_RESULT IPQ_RESULT
SetDumpStringOnF(int *id, int* dump_string_on) SetDumpStringOnF(int *id, int* dump_string_on)
{ {
return ::SetDumpStringOnM(*id, *dump_string_on); return ::SetDumpStringOn(*id, *dump_string_on);
} }
int int
GetDumpLineCountF(int *id) GetDumpLineCountF(int *id)
{ {
return ::GetDumpLineCountM(*id); return ::GetDumpLineCount(*id);
} }
void void
GetDumpLineF(int *id, int* n, char* line, unsigned int line_length) GetDumpLineF(int *id, int* n, char* line, unsigned int line_length)
{ {
padfstring(line, ::GetDumpLineM(*id, (*n) - 1), line_length); padfstring(line, ::GetDumpLine(*id, (*n) - 1), line_length);
} }
int int
GetErrorLineCountF(int *id) GetErrorLineCountF(int *id)
{ {
return ::GetErrorLineCountM(*id); return ::GetErrorLineCount(*id);
} }
void void
GetErrorLineF(int *id, int* n, char* line, unsigned int line_length) GetErrorLineF(int *id, int* n, char* line, unsigned int line_length)
{ {
padfstring(line, ::GetErrorLineM(*id, (*n) - 1), line_length); padfstring(line, ::GetErrorLine(*id, (*n) - 1), line_length);
} }
int int
GetComponentCountF(int *id) GetComponentCountF(int *id)
{ {
return ::GetComponentCountM(*id); return ::GetComponentCount(*id);
} }
void void
GetComponentF(int *id, int *n, char* comp, unsigned int line_length) GetComponentF(int *id, int *n, char* comp, unsigned int line_length)
{ {
padfstring(comp, ::GetComponentM(*id, (*n) - 1), line_length); padfstring(comp, ::GetComponent(*id, (*n) - 1), line_length);
} }
int int
RunAccumulatedF(int *id) RunAccumulatedF(int *id)
{ {
return ::RunAccumulatedM(*id); return ::RunAccumulated(*id);
} }
int int
@ -213,11 +213,11 @@ RunFileF(int *id, char* filename, unsigned int filename_length)
cfilename = f2cstring(filename, filename_length); cfilename = f2cstring(filename, filename_length);
if (!cfilename) if (!cfilename)
{ {
::AddErrorM(*id, "RunFile: Out of memory.\n"); ::AddError(*id, "RunFile: Out of memory.\n");
return (int)VR_OUTOFMEMORY; return (int)VR_OUTOFMEMORY;
} }
int n = ::RunFileM(*id, cfilename); int n = ::RunFile(*id, cfilename);
free(cfilename); free(cfilename);
return n; return n;
} }
@ -230,11 +230,11 @@ RunStringF(int *id, char* input, unsigned int input_length)
cinput = f2cstring(input, input_length); cinput = f2cstring(input, input_length);
if (!cinput) if (!cinput)
{ {
::AddErrorM(*id, "RunString: Out of memory.\n"); ::AddError(*id, "RunString: Out of memory.\n");
return (int)VR_OUTOFMEMORY; return (int)VR_OUTOFMEMORY;
} }
int n = ::RunStringM(*id, cinput); int n = ::RunString(*id, cinput);
free(cinput); free(cinput);
return n; return n;
} }
@ -242,7 +242,7 @@ RunStringF(int *id, char* input, unsigned int input_length)
int int
GetSelectedOutputRowCountF(int *id) GetSelectedOutputRowCountF(int *id)
{ {
int rows = ::GetSelectedOutputRowCountM(*id); int rows = ::GetSelectedOutputRowCount(*id);
if (rows > 0) if (rows > 0)
{ {
rows -= 1; rows -= 1;
@ -253,7 +253,7 @@ GetSelectedOutputRowCountF(int *id)
int int
GetSelectedOutputColumnCountF(int *id) GetSelectedOutputColumnCountF(int *id)
{ {
return ::GetSelectedOutputColumnCountM(*id); return ::GetSelectedOutputColumnCount(*id);
} }
IPQ_RESULT IPQ_RESULT
@ -265,7 +265,7 @@ GetSelectedOutputValueF(int *id, int *row, int *col, int *vtype, double* dvalue,
char buffer[100]; char buffer[100];
int adjcol = *col - 1; int adjcol = *col - 1;
result = ::GetSelectedOutputValueM(*id, *row, adjcol, &v); result = ::GetSelectedOutputValue(*id, *row, adjcol, &v);
switch (v.type) switch (v.type)
{ {
@ -301,13 +301,13 @@ GetSelectedOutputValueF(int *id, int *row, int *col, int *vtype, double* dvalue,
void void
OutputLastErrorF(int *id) OutputLastErrorF(int *id)
{ {
::OutputLastErrorM(*id); ::OutputLastError(*id);
} }
void void
OutputLinesF(int *id) OutputLinesF(int *id)
{ {
::OutputLinesM(*id); ::OutputLines(*id);
} }
#if defined(__cplusplus) #if defined(__cplusplus)