00001 // RateConstant.cpp: implementation of the RateConstant class. 00002 // 00004 00005 #ifdef _WINDOWS 00006 #include "stdafx.h" 00007 #endif 00008 00009 #include "RateConstant.h" 00010 #include <vector> 00011 00013 // Construction/Destruction 00015 00016 RateConstant::RateConstant(double initialValue, std::string name) 00017 { 00018 this->name = name; 00019 this->initialValue = initialValue; 00020 value = initialValue; 00021 errorInInitialValue = initialValue; 00022 this->SetTeXName(); 00023 } 00024 00025 00026 RateConstant::RateConstant(double initialValue, double errorInInitialValue, std::string name) 00027 { 00028 this->name = name; 00029 this->initialValue = initialValue; 00030 this->errorInInitialValue = errorInInitialValue; 00031 value = initialValue; 00032 this->SetTeXName(); 00033 } 00034 00035 RateConstant::~RateConstant() 00036 { 00037 00038 } 00039 00040 double RateConstant::GetValue() const 00041 { 00042 return value; 00043 } 00044 00045 double RateConstant::GetInitialValue() const 00046 { 00047 return initialValue; 00048 } 00049 00050 double RateConstant::GetErrorInInitialValue() const 00051 { 00052 return errorInInitialValue; 00053 } 00054 00055 std::string RateConstant::GetName() const 00056 { 00057 return name; 00058 } 00059 00060 std::string RateConstant::GetTeXName() const 00061 { 00062 return m_sTeXName; 00063 } 00064 00065 void RateConstant::SetErrorInInitialValue(double errorInInitialValue) 00066 { 00067 this->errorInInitialValue = errorInInitialValue; 00068 } 00069 00070 void RateConstant::SetRateConstant(double value) 00071 { 00072 this->value = value; 00073 } 00074 00075 void RateConstant::Reset() 00076 { 00077 SetRateConstant(initialValue); 00078 } 00079 00080 void RateConstant::SetTeXName() 00081 { 00082 // parse the name string into a TeX string 00083 // strstream stream; 00084 std::ostringstream stream; 00085 // get the first character of the rate constant and then a subscript opening 00086 stream << name[0] << "_{\\mathrm{"; 00087 // now the rest of the characters. this assumes there are no other 00088 // underscores or TeX control characters in the string 00089 for(int i = 1; i < name.size(); i++) 00090 { 00091 stream << name[i]; 00092 } 00093 // now close the subscript bracket 00094 stream << "}}" << name[name.length()]; 00095 // set the TeX string equal to what's in the stream 00096 m_sTeXName = stream.str(); 00097 // free the stream to avoid a memory leak 00098 // stream.rdbuf()->freeze(0); 00099 }