00001 #ifndef _CONFIGOBJECT_H_ 00002 #define _CONFIGOBJECT_H_ 00003 00004 #include<stdio.h> 00005 #include<iostream> 00006 #include<cstring> 00007 #include<sstream> 00008 #include <map> 00009 #include "DBField.h" 00010 #include "../db/DBConnection.h" 00011 #include "../db/DBValue.h" 00012 #include "../db/IntVal.h" 00013 #include "../db/IntVectorVal.h" 00014 #include "../db/StringVal.h" 00015 00016 using namespace std; 00017 00021 class ConfigObject{ 00022 00023 private: 00024 bool modified; 00025 map<string, DBValue*> parameters; 00026 map<string, vector<string>* > table_parameter_map; 00027 00028 static map<string, vector<DBField*> > dbCache;//used to avoid a query per object... 00029 00030 void addToCache(string n, ResultSet* r); 00031 00032 protected: 00033 void createParameters(string objectName); 00034 void addParameter(string param, string type); 00035 00036 public: 00041 virtual string toXML() const; 00042 ConfigObject(); 00043 virtual ~ConfigObject(); 00044 00048 virtual string getObjectName() const=0; 00049 00054 void setModified(bool b); 00059 bool isModified(); 00060 00066 void setInt(string parameter, int val) throw (ILCException::Exception); 00072 void setString(string parameter, string val) throw (ILCException::Exception); 00078 void setIntVector(string parameter, vector<int> val) throw (ILCException::Exception); 00083 void setNull(string parameter) throw (ILCException::Exception); 00084 00090 bool isNull(string parameter) throw (ILCException::Exception); 00096 int getInt(string parameter) throw (ILCException::Exception); 00102 string getString(string parameter) throw (ILCException::Exception); 00108 vector<int> getIntVector(string parameter) throw (ILCException::Exception); 00114 string getType(string parameter) throw (ILCException::Exception); 00115 00120 vector<string> getParametersNames() throw (ILCException::Exception); 00125 vector<string> getParametersTypes() throw (ILCException::Exception); 00130 vector<string> getParametersTables() throw (ILCException::Exception); 00135 vector<string> getParametersFromTable(string tableName) throw (ILCException::Exception); 00136 00137 static void terminate(); 00138 00143 void setParameters(map<string, string> p); 00144 00145 }; 00146 #endif