00001 #ifndef PARAMETERDESCRIPTION_H
00002 #define PARAMETERDESCRIPTION_H
00003
00004 #include <vector>
00005 #include <string>
00006 #include <typeinfo>
00007 #include <boost/shared_ptr.hpp>
00008
00009
00010 namespace RuleParser{
00011
00012 class RuleFactory;
00013
00014 class ParameterDescription
00015 {
00016 public:
00017
00018 ParameterDescription(unsigned int id,
00019 const std::string& name,
00020 const std::type_info& type,
00021 const std::vector<std::string>& operators,
00022 const boost::shared_ptr<RuleFactory>& ruleFactory
00023 );
00024
00025 ParameterDescription(unsigned int id,
00026 const std::string& name,
00027 const std::type_info& type,
00028 const std::vector<std::string>& operators,
00029 RuleFactory* ruleFactory
00030 );
00031
00032
00033 ParameterDescription(unsigned int id,
00034 const std::string& name,
00035 const std::type_info& type
00036 );
00037
00038 ~ParameterDescription();
00039
00040 const std::string& name() const{ return m_name; };
00041 unsigned int id() const{ return m_id; };
00042 const std::string& type() const{ return m_type; };
00043
00044 const std::vector<std::string>& operators() const{ return m_operators; };
00045 const boost::shared_ptr<RuleFactory>& factory() const{ return m_factory; };
00046 bool isCustom() const{ return m_factory.get(); };
00047
00048 protected:
00049 unsigned int m_id;
00050 std::string m_name;
00051 std::string m_type;
00052 std::vector<std::string> m_operators;
00053 boost::shared_ptr<RuleFactory> m_factory;
00054 };
00055
00056
00057 class ParameterList;
00058
00059 class ParameterList : public std::vector<ParameterDescription>
00060 {
00061 public:
00062
00063
00064 ParameterList& add(const ParameterDescription& d) { push_back(d); return *this; };
00065
00066 template<typename T>
00067 ParameterList& add(unsigned int id, const std::string& name)
00068 { push_back(ParameterDescription(id,name,typeid(T))); return *this; } ;
00069
00070 template<typename T>
00071 ParameterList& add(unsigned int id,
00072 const std::string& name,
00073 const std::string& alias1)
00074 {
00075 push_back(ParameterDescription(id,name, typeid(T)));
00076 push_back(ParameterDescription(id,alias1,typeid(T)));
00077 return *this;
00078 };
00079
00080 template<typename T>
00081 ParameterList& add(unsigned int id,
00082 const std::string& name,
00083 const std::string& alias1,
00084 const std::string& alias2)
00085 {
00086 push_back(ParameterDescription(id,name, typeid(T)));
00087 push_back(ParameterDescription(id,alias1,typeid(T)));
00088 push_back(ParameterDescription(id,alias2,typeid(T)));
00089 return *this;
00090 };
00091
00092 template<typename T>
00093 ParameterList& add(unsigned int id,
00094 const std::string& name,
00095 const std::string& alias1,
00096 const std::string& alias2,
00097 const std::string& alias3)
00098 {
00099 push_back(ParameterDescription(id,name, typeid(T)));
00100 push_back(ParameterDescription(id,alias1,typeid(T)));
00101 push_back(ParameterDescription(id,alias2,typeid(T)));
00102 push_back(ParameterDescription(id,alias3,typeid(T)));
00103 return *this;
00104 };
00105
00106 template<typename T>
00107 ParameterList& add(unsigned int id,
00108 const std::string& name,
00109 const std::string& opname,
00110 RuleFactory* factory)
00111 {
00112 push_back(ParameterDescription(id,name,typeid(T),std::vector<std::string>(1,opname),factory));
00113 return *this;
00114 };
00115
00116 template<typename T>
00117 ParameterList& add(unsigned int id,
00118 const std::string& name,
00119 const std::string& opname,
00120 const boost::shared_ptr<RuleFactory>& factory)
00121 {
00122 push_back(ParameterDescription(id,name,typeid(T),std::vector<std::string>(1,opname),factory));
00123 return *this;
00124 };
00125
00126 };
00127
00128 }
00129
00130 #endif