NIREP
|
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 #pragma once 00014 #ifndef _EVALUATOR_LIST_H_ 00015 #define _EVALUATOR_LIST_H_ 00016 00017 /* +-----------+ 00018 | Libraries | 00019 +-----------+ */ 00020 #include <map> 00021 #include <string> 00022 #include <vector> 00023 00024 #include <iostream> 00025 #include <fstream> 00026 00027 00028 #include "wx/wxprec.h" 00029 #include "../VariableList/VariableList.h" 00030 00031 00032 00033 #ifndef WX_PRECOMP 00034 #include "wx/wx.h" 00035 #endif 00036 00037 00038 00039 /* +--------+ 00040 | Macros | 00041 +--------+ */ 00042 #define EVALUATORLIST 2 00043 00044 00045 00046 /* +---------+ 00047 | Classes | 00048 +---------+ */ 00065 class EvaluatorList { 00066 public: 00067 00068 /* +----------------+ 00069 | Public Methods | 00070 +----------------+ */ 00071 00078 EvaluatorList(); 00079 EvaluatorList(VariableList* vList); 00080 EvaluatorList(const std::string& fileName); 00081 EvaluatorList(const std::string& fileName, VariableList* vList); 00082 00085 ~EvaluatorList(); 00086 00087 00094 bool Read(const std::string& fileName); 00095 00096 00103 void Write(const std::string& fileName); 00104 00106 void SetVarList(VariableList* list){this->vars = list;} 00107 00115 void SetEvaluatorTask(std::string taskName, std::string fullName){this->task[taskName] = fullName;} 00116 00117 00129 std::vector <std::string> GetTaskParameters(const std::string taskName); 00130 00131 00137 std::string GetTaskFunction(const std::string taskName); 00138 00139 00144 std::vector<std::string> GetTaskKeys(); 00145 00146 00152 std::vector<std::string> GetTaskValues(bool fullName=0); 00153 00160 void GetTasks(std::vector<std::string> * keys, std::vector<std::string> * values, bool fullName=0); 00161 00171 void SetFullTaskName(std::string taskName, std::string fullName){ this->taskFullName[taskName]=fullName; } 00172 00182 std::string GetFullTaskName(std::string taskName){ 00183 return (this->inMap(this->taskFullName, taskName))?this->taskFullName[taskName]:"!"; 00184 } 00185 00195 std::string GetEvaluatorCommand(const std::string& taskName) { 00196 if (this->inMap(this->taskFullName,taskName)) { 00197 return this->taskFullName[taskName]; 00198 } else { 00199 return this->unwrap(taskName); 00200 } 00201 00202 //return (this->inMap(this->taskFullName,taskName))?this->taskFullName[taskName]:this->unwrap(taskName); 00203 } 00204 00207 std::map<std::string, std::string>* GetList() { return &(this->task); } 00208 00209 void ClearTaskFullName(){taskFullName.clear();}; 00210 00211 bool AnyError(){return error;}; 00212 00213 00214 private: 00215 00216 /* +-----------------+ 00217 | Private Methods | 00218 +-----------------+ */ 00219 00235 std::string unwrap(std::string source); 00236 00237 00254 void parse(std::string source, std::string * fcn, std::vector<std::string> * params); 00255 00256 00267 void StringExplode(std::string str, std::string separator, std::vector<std::string> * results); 00268 00269 00279 template <typename S, typename T> 00280 bool inMap(std::map<S, T> map, S key); 00281 00282 00283 /* +-------------------+ 00284 | Private Parameters | 00285 +-------------------+ */ 00286 std::map<std::string, std::string> task; //Container of the evaluator list <taskName, taskExpression> 00287 std::map<std::string, std::string> taskFullName; // <taskName, fully qualified expression> 00288 VariableList* vars; // variable list 00289 bool error; 00290 00291 }; 00292 00293 #endif