26 #include <vapor/XmlNode.h>
27 #include <vapor/ParamNode.h>
28 #include <vapor/ExpatParseMgr.h>
30 #include <vapor/common.h>
97 XmlNode *parent,
const string &name
102 _currentParamNode = _rootParamNode = 0;
104 _paramsBaseName = name;
127 void SetParent(XmlNode *parent);
143 virtual bool elementStartHandler(
144 ExpatParseMgr* pm,
int depth,
string& tag,
const char ** attribs
159 virtual bool elementEndHandler(ExpatParseMgr* pm,
int depth,
string& tag);
184 const string GetName()
const {
return _paramsBaseName;}
193 virtual long GetValueLong(
const string& tag,
const vector<long>& defaultVal = _emptyLongVec)
195 return GetRootNode()->GetElementLong(tag, defaultVal)[0];
205 virtual double GetValueDouble(
const string& tag,
const vector<double>& defaultVal = _emptyDoubleVec)
206 {
return GetRootNode()->GetElementDouble(tag,defaultVal)[0];}
215 virtual const string GetValueString(
const string& tag,
const string& defaultVal = _emptyString)
216 {
return GetRootNode()->GetElementString(tag, defaultVal);}
225 virtual const vector<long>
GetValueLongVec(
const string& tag,
const vector<long>& defaultVal = _emptyLongVec)
226 {
return GetRootNode()->GetElementLong(tag, defaultVal);}
235 virtual const vector<double>
GetValueDoubleVec(
const string& tag,
const vector<double>& defaultVal = _emptyDoubleVec)
236 {
return GetRootNode()->GetElementDouble(tag, defaultVal);}
245 virtual void GetValueStringVec(
const string& tag, vector<string>& vec,
const vector<string>& defaultVal = _emptyStringVec)
246 {GetRootNode()->GetElementStringVec(tag, vec, defaultVal);}
260 virtual int SetValueLong(
string tag,
const char* description,
long value,
Params* p);
273 virtual int SetValueLong(
string tag,
const char* description,
const vector<long>& value,
Params* p);
286 virtual int SetValueDouble(
string tag,
const char* description,
double value,
Params* p);
299 virtual int SetValueDouble(
string tag,
const char* description,
const vector<double>& value,
Params* p);
312 virtual int SetValueString(
string tag,
const char* description,
const string& value,
Params* p);
325 virtual int SetValueStringVec(
string tag,
const char* description,
const vector<string>& value,
Params* p);
338 static ParamsBaseType GetTypeFromTag(
const string&tag);
344 static const string GetTagFromType(ParamsBaseType t);
353 ParamsBase *p = (createDefaultFcnMap[pType])();
362 static ParamsBase* CreateDefaultParamsBase(
const string&tag);
375 static int RegisterParamsBaseClass(
const string& tag, BaseCreateFcn fcn,
bool isParams);
385 static int ReregisterParamsBaseClass(
const string& tag,
const string& newtag,
bool isParams);
407 static bool IsParamsTag(
const string&tag) {
return (GetTypeFromTag(tag) > 0);}
414 ParamsBase* GetParamsBase(
const vector<string>& path)
const;
430 int SetParamsBase(
const vector<string>& path,
ParamsBase* pbase);
442 int RemoveParamsBase(
const vector<string>& path,
ParamsBase* pbase);
444 #ifndef DOXYGEN_SKIP_THIS
446 static ParamsBase* CreateDummyParamsBase(std::string tag);
448 static void addDummyParamsBaseInstance(
ParamsBase*
const & pb ) {dummyParamsBaseInstances.push_back(pb);}
450 static void clearDummyParamsBaseInstances();
456 ParamsBase* deepCopy(ParamNode* newRoot = 0);
460 static void setDataMgr(DataMgrV3_0* dataMgr){ _dataMgr = dataMgr;}
463 static DataMgrV3_0* _dataMgr;
465 ParamNode *_currentParamNode;
466 ParamNode *_rootParamNode;
470 static DataMgrV3_0* GetDataMgr() {
return _dataMgr;}
471 static vector<ParamsBase*> dummyParamsBaseInstances;
472 static const string _emptyString;
473 static const vector<string> _emptyStringVec;
474 static const vector<double> _emptyDoubleVec;
475 static const vector<long> _emptyLongVec;
476 virtual ParamNode *getCurrentParamNode() {
return _currentParamNode;}
478 virtual void setCurrentParamNode(ParamNode* pn){ _currentParamNode=pn;}
482 static map<string,int> classIdFromTagMap;
483 static map<int,string> tagFromClassIdMap;
484 static map<int,BaseCreateFcn> createDefaultFcnMap;
486 string _paramsBaseName;
488 static int _numParamsClasses;
489 static int _numBasicParamsClasses;
490 static int _numEmbedClasses;
492 #endif //DOXYGEN_SKIP_THIS
550 void Remove(
const string &name);
556 const map <string, string> &GetAttributes();
569 #ifndef DOXYGEN_SKIP_THIS
574 class DummyParamsBase :
public ParamsBase {
576 DummyParamsBase(XmlNode *parent,
const string &name) :
577 ParamsBase(parent, name) {}
579 virtual ~DummyParamsBase(){}
581 #endif //DOXYGEN_SKIP_THIS
583 #endif //ParamsBase_H
virtual long GetValueLong(const string &tag, const vector< long > &defaultVal=_emptyLongVec)
ParamNode * GetRootNode() const
A pure virtual class for managing parameters used in visualization.
ParamNode * GetCurrentNode()
virtual void SetRootParamNode(ParamNode *pn)
virtual const vector< long > GetValueLongVec(const string &tag, const vector< long > &defaultVal=_emptyLongVec)
ParamsBaseType GetParamsBaseTypeId()
Nodes with state in Xml tree representation.
static ParamsBase * CreateDefaultParamsBase(int pType)
static int GetNumParamsClasses()
virtual void GetValueStringVec(const string &tag, vector< string > &vec, const vector< string > &defaultVal=_emptyStringVec)
static int GetNumBasicParamsClasses()
virtual const string GetValueString(const string &tag, const string &defaultVal=_emptyString)
virtual double GetValueDouble(const string &tag, const vector< double > &defaultVal=_emptyDoubleVec)
ParamsBase(const string &name)
Default constructor.
static bool IsParamsTag(const string &tag)
virtual const vector< double > GetValueDoubleVec(const string &tag, const vector< double > &defaultVal=_emptyDoubleVec)
const string GetName() const