FFSM++  1.1.0
French Forest Sector Model ++
LLData Class Reference

Low level data. XML input is reversed here after unzipping oocalc file and parsing content.xml. More...

#include <ModelData.h>

Inheritance diagram for LLData:
Collaboration diagram for LLData:

Public Member Functions

 LLData (ThreadManager *MTHREAD_h, string tableName_h)
 
 ~LLData ()
 
void clean ()
 
string getTableName ()
 
int nrecords ()
 
int nheaders ()
 
string getData (const int &pos_h, const string &header_h, const int &debugLevel=MSG_CRITICAL_ERROR) const
 
- Public Member Functions inherited from BaseClass
 BaseClass ()
 
 ~BaseClass ()
 
void msgOut (const int &msgCode_h, const string &msg_h, const bool &refreshGUI_h=true) const
 Overloaded function to print the output log. More...
 
void msgOut (const int &msgCode_h, const int &msg_h, const bool &refreshGUI_h=true) const
 Overloaded function to print the output log. More...
 
void msgOut (const int &msgCode_h, const double &msg_h, const bool &refreshGUI_h=true) const
 Overloaded function to print the output log. More...
 
int s2i (const string &string_h) const
 string to integer conversion More...
 
double s2d (const string &string_h) const
 string to double conversion More...
 
double s2d (const string &string_h, const bool &replaceComma) const
 string to double conversion More...
 
bool s2b (const string &string_h) const
 string to bool conversion More...
 
string i2s (const int &int_h) const
 integer to string conversion More...
 
string d2s (const double &double_h) const
 double to string conversion More...
 
string b2s (const bool &bool_h) const
 bool to string conversion More...
 
vector< int > s2i (const vector< string > &string_h) const
 string to integer conversion (vector) More...
 
vector< double > s2d (const vector< string > &string_h, const bool &replaceComma=false) const
 string to double conversion (vector) More...
 
vector< bool > s2b (const vector< string > &string_h) const
 string to bool conversion (vector) More...
 
vector< string > i2s (const vector< int > &int_h) const
 integer to string conversion (vector) More...
 
vector< string > d2s (const vector< double > &double_h) const
 double to string conversion (vector) More...
 
vector< string > b2s (const vector< bool > &bool_h) const
 bool to string conversion (vector) More...
 
int getType (const string &type_h) const
 Return a type according to enum TYPE_* from a string (eg: "string" -> TYPE_STRING (2)) More...
 
void refreshGUI () const
 Ping to periodically return the control to the GUI. More...
 
template<typename T >
string toString (const T &x) const
 
template<typename T >
stringTo (const std::string &s) const
 
int vSum (const vector< int > &vector_h) const
 
double vSum (const vector< double > &vector_h) const
 
int vSum (const vector< vector< int > > &vector_h) const
 
double vSum (const vector< vector< double > > &vector_h) const
 
void tokenize (const string &str, vector< string > &tokens, const string &delimiter=" ") const
 Tokenize a string using a delimiter (default is space) More...
 
void untokenize (string &str, vector< string > &tokens, const string &delimiter=" ") const
 
template<typename K , typename V >
findMap (const map< K, V > &mymap, const K &key, const int &error_level=MSG_CRITICAL_ERROR, const V &notFoundValue=numeric_limits< V >::min()) const
 Lookup a map for a value. Return the value starting from the key. More...
 
template<typename K , typename V >
void changeMapValue (map< K, V > &mymap, const K &key, const V &value, const int &error_level=MSG_CRITICAL_ERROR)
 Change the value stored in a map given the key and the new value. More...
 
template<typename K , typename V >
void incrMapValue (map< K, V > &mymap, const K &key, const V &value, const int &error_level=MSG_CRITICAL_ERROR)
 Increments a value stored in a map of the specified value, given the key. More...
 
template<typename K , typename V >
void incrOrAddMapValue (map< K, V > &mymap, const K &key, const V &value)
 Increments a value stored in a map of the specified value, given the key. More...
 
template<typename K , typename V >
void resetMapValues (map< K, V > &mymap, const V &value)
 Reset all values stored in a map to the specified one. More...
 
template<typename K , typename V >
map< K, V > vectorToMap (const vector< K > &keys, const V &value=0.0)
 Returns a map built using the given vector and the given (scalar) value as keys/values pairs. More...
 
template<typename T >
vector< T > positionsToContent (const vector< T > &vector_h, const vector< int > &positions)
 Return a vector of content from a vector and a vector of positions (int) More...
 
template<typename V >
void debugMap (const map< iisskey, V > &mymap)
 Debug a map. More...
 
template<typename K , typename V >
void debugMap (const map< K, V > &mymap, const K &key)
 
template<typename K >
int getMaxPos (const vector< K > &v)
 Returns the position of the maximum element in the vector (the last one in case of multiple equivalent maxima) More...
 
template<typename K >
int getMinPos (const vector< K > &v)
 Returns the position of the minimum element in the vector (the first one in case of multiple equivalent minima) More...
 
template<typename K >
getMax (const vector< K > &v)
 Returns the value of the maximum element in the vector (the last one in case of multiple equivalent maxima) More...
 
template<typename K >
getMin (const vector< K > &v)
 Returns the value of the minimum element in the vector (the first one in case of multiple equivalent minima) More...
 
template<typename K >
double getAvg (const vector< K > &v)
 Returns the average of the elements in the vector. More...
 
template<typename K >
double getSd (const vector< K > &v, bool sample=true)
 
template<typename K >
int getPos (const K &element, const vector< K > &v, const int &msgCode_h=MSG_CRITICAL_ERROR)
 
template<typename K >
bool inVector (const K &element, const vector< K > &v)
 
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 after milion of loops). More...
 
template<typename K >
normSample (normal_distribution< K > &d, std::mt19937 &gen, const K &minval=NULL, const K &maxval=NULL) const
 Sample from a normal distribution with bounds. Faster (half time) as the normal_distribution is made only once. More...
 
template<typename T >
std::string toString (const T &x) const
 

Public Attributes

string tableName
 
vector< string > headers
 
vector< vector< string > > records
 

Friends

void ModelData::loadInput ()
 

Additional Inherited Members

- Protected Attributes inherited from BaseClass
ThreadManagerMTHREAD
 Pointer to the Thread manager. More...
 

Detailed Description

Low level data. XML input is reversed here after unzipping oocalc file and parsing content.xml.

Definition at line 329 of file ModelData.h.

Constructor & Destructor Documentation

LLData ( ThreadManager MTHREAD_h,
string  tableName_h 
)

Definition at line 2153 of file ModelData.cpp.

2153  {
2154  MTHREAD = MTHREAD_h;
2155  tableName = tableName_h;
2156 }
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
string tableName
Definition: ModelData.h:343
~LLData ( )

Definition at line 2158 of file ModelData.cpp.

2158  {
2159 
2160 }

Member Function Documentation

void clean ( )

Definition at line 2163 of file ModelData.cpp.

Referenced by ModelData::getTableFromFile(), and ModelData::loadInput().

2163  {
2164 
2165  //checking the size is correct...
2166  int hsize = headers.size();
2167  for (uint i=0;i<records.size();i++){
2168  if(records[i].size() != hsize){
2169  vector <string> record = records[i];
2170  msgOut(MSG_CRITICAL_ERROR,"Error in the input reading table "+tableName+". Record "+i2s(i)+" has "+i2s(records[i].size())+" fields instead of "+i2s(hsize)+".");
2171  }
2172  }
2173  //cleaning empty-header columns...
2174  for (int i=headers.size()-1;i>=0;i--){
2175  if(headers[i] == ""){
2176  headers.erase(headers.begin()+i);
2177  for (uint j=0;j<records.size();j++){
2178  records[j].erase(records[j].begin()+i);
2179  }
2180  }
2181  }
2182 
2183 }
string i2s(const int &int_h) const
integer to string conversion
Definition: BaseClass.cpp:219
vector< string > headers
Definition: ModelData.h:344
void msgOut(const int &msgCode_h, const string &msg_h, const bool &refreshGUI_h=true) const
Overloaded function to print the output log.
Definition: BaseClass.cpp:50
Print an error message and stop the model.
Definition: BaseClass.h:62
string tableName
Definition: ModelData.h:343
vector< vector< string > > records
Definition: ModelData.h:345

Here is the call graph for this function:

Here is the caller graph for this function:

string getData ( const int &  pos_h,
const string &  header_h,
const int &  debugLevel = MSG_CRITICAL_ERROR 
) const

Definition at line 2186 of file ModelData.cpp.

Referenced by ModelData::createRegions(), ModelData::getScenarios(), ModelData::setDefaultForData(), ModelData::setDefaultPathogenRules(), ModelData::setDefaultProdData(), ModelData::setDefaultProductResourceMatrixLink(), ModelData::setDefaultSettings(), ModelData::setForestTypes(), ModelData::setReclassificationRules(), ModelData::setScenarioData(), ModelData::setScenarioForData(), ModelData::setScenarioPathogenRules(), ModelData::setScenarioProdData(), ModelData::setScenarioProductResourceMatrixLink(), and ModelData::setScenarioSettings().

2186  {
2187 
2188  if (records.size()<= pos_h){
2189  msgOut(debugLevel, "Requested position "+i2s(pos_h)+" too high! Not enought records !!");
2190  return "";
2191  }
2192  int hsize = headers.size();
2193  for (uint i=0;i<hsize;i++){
2194  if(headers[i] == header_h) return records[pos_h][i];
2195  }
2196  msgOut(debugLevel, "Header string "+header_h+" not found!");
2197  return "";
2198 }
string i2s(const int &int_h) const
integer to string conversion
Definition: BaseClass.cpp:219
vector< string > headers
Definition: ModelData.h:344
void msgOut(const int &msgCode_h, const string &msg_h, const bool &refreshGUI_h=true) const
Overloaded function to print the output log.
Definition: BaseClass.cpp:50
vector< vector< string > > records
Definition: ModelData.h:345

Here is the call graph for this function:

Here is the caller graph for this function:

string getTableName ( )
inline

Definition at line 335 of file ModelData.h.

335 {return tableName;}
string tableName
Definition: ModelData.h:343

Friends And Related Function Documentation

void ModelData::loadInput ( )
friend

Member Data Documentation

vector<string> headers

Definition at line 344 of file ModelData.h.

Referenced by ModelData::getTableFromFile(), and ModelData::loadInput().

vector< vector <string> > records

Definition at line 345 of file ModelData.h.

Referenced by ModelData::getTableFromFile(), and ModelData::loadInput().

string tableName

Definition at line 343 of file ModelData.h.


The documentation for this class was generated from the following files: