#ifndef ATOOLS_Org_Getter_Function_H #define ATOOLS_Org_Getter_Function_H #include #include #include namespace ATOOLS { class String_Sort; template > class Getter_Function { public: typedef ObjectType Object_Type; typedef SortCriterion Sort_Criterion; typedef std::vector Getter_List; typedef ParameterType Parameter_Type; typedef typename std::map String_Getter_Map; private: static String_Getter_Map *s_getters; static bool s_exactmatch; bool m_display; protected: virtual Object_Type * operator()(const Parameter_Type ¶meters) const; virtual void PrintInfo(std::ostream &str,const size_t width) const; public: // constructor Getter_Function(const std::string &name); // destructor virtual ~Getter_Function(); // member functions static void PrintGetterInfo(std::ostream &str,const size_t width, const std::string &indent=" ", const std::string &separator=" ", const std::string &lineend="\n", const std::string &replacefrom="", const std::string &replaceto=""); Object_Type *GetObject(const Parameter_Type ¶meters) const; static Object_Type *GetObject(const std::string &name, const Parameter_Type ¶meters); static Getter_List GetGetters(const std::string &name=""); // inline functions inline static void SetExactMatch(const bool exactmatch) { s_exactmatch=exactmatch; } inline void SetDisplay(const bool display) { m_display=display; } inline static bool ExactMatch() { return s_exactmatch; } };// end of class Getter_Function template > class Getter {}; }// end of namespace ATOOLS #define DECLARE_GETTER_BASE(NAME,TAG,OBJECT,PARAMETER,SORT) \ \ namespace ATOOLS { \ template <> class Getter: \ public Getter_Function { \ private: \ static Getter s_initializer; \ protected: \ void PrintInfo(std::ostream &str,const size_t width) const; \ Object_Type *operator()(const Parameter_Type ¶meters) const; \ public: \ Getter(const bool &d=true): \ Getter_Function(TAG) \ { SetDisplay(d); } \ }; \ } #define DECLARE_ND_GETTER(NAME,TAG,OBJECT,PARAMETER,DISP) \ DECLARE_GETTER_BASE(NAME,TAG,OBJECT,PARAMETER,std::less) \ ATOOLS::Getter \ ATOOLS::Getter::s_initializer(DISP) #define DECLARE_GETTER(NAME,TAG,OBJECT,PARAMETER) \ DECLARE_ND_GETTER(NAME,TAG,OBJECT,PARAMETER,true) #define DECLARE_NI_GETTER(NAME,OBJECT,PARAMETER,SORT) \ \ namespace ATOOLS { \ template <> class Getter: \ public ATOOLS::Getter_Function { \ protected: \ void PrintInfo(std::ostream &str,const size_t width) const; \ Object_Type *operator()(const Parameter_Type ¶meters) const; \ public: \ Getter \ (const std::string &name,const bool d=true): \ Getter_Function(name) \ { SetDisplay(d); } \ }; \ } #endif