50BaseClass::msgOut(
const int& msgCode_h,
const string& msg_h,
const bool& refreshGUI_h)
const {
52 msgOut2(msgCode_h, msg_h, refreshGUI_h);
78BaseClass::msgOut(
const int& msgCode_h,
const double& msg_h,
const bool& refreshGUI_h)
const {
101 prefix=
"**WARNING: ";
107 prefix=
"****CRITICAL ERROR: ";
110 cerr<<
"I got an unknow error code: "<<msgCode_h<<
" ("<<msg_h<<
")"<<endl;
114 string message = prefix+msg_h;
119 string totalMsg = prefix+msg_h;
120 cout<< totalMsg <<endl;
150 if (string_h ==
"")
return 0;
152 stringstream ss(string_h);
153 ss >> valueAsInteger;
154 return valueAsInteger;
172 if (string_h ==
"")
return 0.;
173 double valueAsDouble;
174 istringstream totalSString( string_h );
175 totalSString >> valueAsDouble;
176 return valueAsDouble;
196 string valueAsString = string_h;
198 replace(valueAsString.begin(), valueAsString.end(),
',',
'.');
199 return s2d(valueAsString);
201 return s2d(string_h);
209 if (string_h ==
"true" || string_h ==
"vero" || string_h ==
"TRUE" || string_h ==
"VRAI" || string_h ==
"1" || string_h ==
"True")
211 else if (string_h ==
"false" || string_h ==
"falso" || string_h ==
"FALSE" || string_h ==
"FAUX" || string_h ==
"0" || string_h ==
"" || string_h ==
"False")
224 snprintf ( outChar,
sizeof(outChar),
"%d", int_h );
225 return string(outChar);
234 snprintf ( outChar,
sizeof(outChar),
"%f", double_h );
235 return string(outChar);
240 if (bool_h)
return "true";
246 vector <int> valuesAsInteger;
247 for (uint i=0;i<string_h.size();i++){
248 valuesAsInteger.push_back(
s2i(string_h[i]));
250 return valuesAsInteger;
256 vector <double> valuesAsDouble;
257 for (uint i=0;i<string_h.size();i++){
259 string valueAsString = string_h[i];
261 replace(valueAsString.begin(), valueAsString.end(),
',',
'.');
262 valuesAsDouble.push_back(
s2d(valueAsString));
264 valuesAsDouble.push_back(
s2d(string_h[i]));
267 return valuesAsDouble;
273 vector <bool> valuesAsBool;
274 for (uint i=0;i<string_h.size();i++){
275 valuesAsBool.push_back(
s2b(string_h[i]));
282 vector <string> valuesAsString;
283 for (uint i=0;i<int_h.size();i++){
284 valuesAsString.push_back(
i2s(int_h[i]));
286 return valuesAsString;
291 vector <string> valuesAsString;
292 for (uint i=0;i<double_h.size();i++){
293 valuesAsString.push_back(
d2s(double_h[i]));
295 return valuesAsString;
300 vector <string> valuesAsString;
301 for (uint i=0;i<bool_h.size();i++){
302 if(bool_h[i]) valuesAsString.push_back(
"true");
303 else valuesAsString.push_back(
"false");
305 return valuesAsString;
312 if (type_h ==
"int") toReturn =
TYPE_INT;
313 else if (type_h ==
"double") toReturn =
TYPE_DOUBLE;
314 else if (type_h ==
"string") toReturn =
TYPE_STRING;
315 else if (type_h ==
"bool") toReturn =
TYPE_BOOL;
321template<
typename T> std::string
323 std::ostringstream oss;
331 if(minval != NULL && maxval != NULL){
332 if (maxval <= minval){
337 normal_distribution<double> d(avg,stdev);
339 if( (minval == NULL || c >= minval) && (maxval == NULL || c <= maxval) ){
347template<
typename T> T
349 std::istringstream iss(s);
358 for(vector < vector<int> >::const_iterator j=vector_h.begin();j!=vector_h.end();++j){
359 toReturn += accumulate(j->begin(),j->end(),0);
366 double toReturn = 0.0;
367 for(vector < vector<double> >::const_iterator j=vector_h.begin();j!=vector_h.end();++j){
368 toReturn += accumulate(j->begin(),j->end(),0.0);
376 string::size_type lastPos = str.find_first_not_of(delimiter, 0);
378 string::size_type pos = str.find_first_of(delimiter, lastPos);
380 while (string::npos != pos || string::npos != lastPos)
383 tokens.push_back(str.substr(lastPos, pos - lastPos));
385 lastPos = str.find_first_not_of(delimiter, pos);
387 pos = str.find_first_of(delimiter, lastPos);
397 for(
int i=0;i<tokens.size();i++){
400 if(i != (tokens.size()-1)){
423 if(op2.
i ==
i && op2.
s ==
s){
431 if(op2.
i ==
i && op2.
s ==
s){
439 if (
i < op2.
i )
return true;
441 if (
s < op2.
s)
return true;
448 if (
i > op2.
i )
return true;
450 if (
s > op2.
s)
return true;
457 if (
i < op2.
i )
return true;
459 if (
s <= op2.
s)
return true;
466 if (
i > op2.
i )
return true;
468 if (
s >= op2.
s)
return true;
491 if(op2.
i ==
i && op2.
i2 ==
i2 && op2.
s ==
s){
499 if(op2.
i ==
i && op2.
i2 ==
i2 && op2.
s ==
s){
507 if (
i < op2.
i ) {
return true;}
509 if (
i2 < op2.
i2 ) {
return true;}
511 if (
s < op2.
s) {
return true;}
519 if (
i > op2.
i ) {
return true;}
521 if (
i2 > op2.
i2 ) {
return true;}
523 if (
s > op2.
s) {
return true;}
531 if (
i < op2.
i ) {
return true;}
533 if (
i2 < op2.
i2 ) {
return true;}
535 if (
s <= op2.
s) {
return true;}
543 if (
i > op2.
i ) {
return true;}
545 if (
i2 > op2.
i2 ) {
return true;}
547 if (
s >= op2.
s) {
return true;}
573 if(op2.
i ==
i && op2.
i2 ==
i2 && op2.
s ==
s && op2.
s2 ==
s2){
581 if(op2.
i ==
i && op2.
i2 ==
i2 && op2.
s ==
s && op2.
s2 ==
s2){
589 if (
i < op2.
i ) {
return true;}
591 if (
i2 < op2.
i2 ) {
return true;}
593 if (
s < op2.
s) {
return true;}
595 if (
s2 < op2.
s2) {
return true;}
604 if (
i > op2.
i ) {
return true;}
606 if (
i2 > op2.
i2 ) {
return true;}
608 if (
s > op2.
s) {
return true;}
610 if (
s2 > op2.
s2) {
return true;}
619 if (
i < op2.
i ) {
return true;}
621 if (
i2 < op2.
i2 ) {
return true;}
623 if (
s < op2.
s) {
return true;}
625 if (
s2 <= op2.
s2) {
return true;}
634 if (
i > op2.
i ) {
return true;}
636 if (
i2 > op2.
i2 ) {
return true;}
638 if (
s > op2.
s) {
return true;}
640 if (
s2 >= op2.
s2) {
return true;}
649 if( (key_h.
i == NULL || key_h.
i==
i) &&
650 (key_h.
i2 == NULL || key_h.
i2==
i2) &&
651 (key_h.
s ==
"" || key_h.
s==
s) &&
652 (key_h.
s2 ==
"" || key_h.
s2==
s2) )
return true;
660 snprintf ( outChar1,
sizeof(outChar1),
"%d",
i);
661 snprintf ( outChar2,
sizeof(outChar2),
"%d",
i2);
662 return string(outChar1)+
'\t'+string(outChar2)+
'\t'+
s+
'\t'+
s2;
This file is the header of BaseClass and it is included by ALL compiled code.
@ TYPE_DOUBLE
The required data is a double.
@ TYPE_BOOL
The required data is a bool.
@ TYPE_INT
The required data is an integer.
@ TYPE_STRING
The required data is a string.
@ MSG_CRITICAL_ERROR
Print an error message and stop the model.
@ MSG_ERROR
Print an ERROR message, but don't stop the model.
@ MSG_DEBUG
Print a debug message, normally filtered out.
@ MSG_WARNING
Print a WARNING message.
@ MSG_INFO
Print an INFO message.
@ MSG_NO_MSG
Do not actually output any message.
ThreadManager * MTHREAD
Pointer to the Thread manager.
string b2s(const bool &bool_h) const
bool to string conversion
int s2i(const string &string_h) const
string to integer conversion
void untokenize(string &str, vector< string > &tokens, const string &delimiter=" ") const
int vSum(const vector< int > &vector_h) const
void tokenize(const string &str, vector< string > &tokens, const string &delimiter=" ") const
Tokenize a string using a delimiter (default is space)
string d2s(const double &double_h) const
double to string conversion
T stringTo(const std::string &s) const
void msgOut(const int &msgCode_h, const string &msg_h, const bool &refreshGUI_h=true) const
Overloaded function to print the output log.
double normSample(const double &avg, const double &stdev, const double &minval=NULL, const double &maxval=NULL) const
Sample from a normal distribution with bounds. Slower (double time, but still you see the diff only a...
void refreshGUI() const
Ping to periodically return the control to the GUI.
bool s2b(const string &string_h) const
string to bool conversion
int getType(const string &type_h) const
Return a type according to enum TYPE_* from a string (eg: "string" -> TYPE_STRING (2))
string i2s(const int &int_h) const
integer to string conversion
vector< double > s2d(const vector< string > &string_h, const bool &replaceComma=false) const
string to double conversion (vector)
double s2d(const string &string_h) const
string to double conversion
void msgOut2(const int &msgCode_h, const string &msg_h, const bool &refreshGUI_h) const
Do the job of the overloaded functions.
string toString(const T &x) const
void msgOut(const int msgCode_h, const string message_h)
std::mt19937 * gen
used in the sampling from normal distribution
Class to provide a simple integer-integer-string key in std maps.
iiskey()
iiskey class (note the double ii) ///
bool operator>(const iiskey &op2) const
bool operator>=(const iiskey &op2) const
bool operator<(const iiskey &op2) const
bool operator==(const iiskey &op2) const
bool operator!=(const iiskey &op2) const
bool operator<=(const iiskey &op2) const
Class to provide a simple integer-integer-string-string key in std maps.
iisskey()
iisskey class (note the double ii and double ss) ///
bool filter(const iisskey &key_h) const
bool operator>=(const iisskey &op2) const
bool operator==(const iisskey &op2) const
bool operator<(const iisskey &op2) const
bool operator>(const iisskey &op2) const
bool operator<=(const iisskey &op2) const
bool operator!=(const iisskey &op2) const
Class to provide a simple integer-string key to be used in std maps.
bool operator==(const iskey &op2) const
bool operator<(const iskey &op2) const
bool operator!=(const iskey &op2) const
bool operator>(const iskey &op2) const
bool operator>=(const iskey &op2) const
bool operator<=(const iskey &op2) const