CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/CondCore/DBCommon/interface/ClassID.h

Go to the documentation of this file.
00001 #ifndef CondCoreDBCommon_ClassID_H
00002 #define CondCoreDBCommon_ClassID_H
00003 #include <typeinfo>
00004 #include<vector>
00005 #include<string>
00006 
00007 namespace cond {
00008 
00009   namespace idCategories {
00010     std::string const pythonIDCategory("CondPythonID");
00011   }
00012 
00013 
00014 
00015   char const * className(const std::type_info& t);
00016 
00017 
00018   class ClassInfo {
00019   public:
00020     virtual ~ClassInfo(){}
00021     inline ClassInfo(const std::type_info& t) : tinfo(t) {}
00022     //inline ClassInfo(const std::type_info& t, int);
00023     inline const std::type_info& type() const { return tinfo;}
00024     std::string pluginName(std::string const & prefix) const;
00025     virtual std::string resource() const=0;
00026   private:
00027     //ClassIDRegistry * registry;
00028     //const char * registerMe(const std::type_info& t);
00029     const std::type_info& tinfo;
00030   };
00031   
00032   
00048   template<typename T>
00049   struct ClassID : public  ClassInfo {
00050     ClassID() : ClassInfo(typeid(T)) {}
00051     ClassID(char const * res ) : ClassInfo(typeid(T)), m_res(res) {}
00052     ClassID(int i) : ClassInfo(typeid(T),i) {}
00053     virtual std::string resource() const { return m_res;}
00054   private:
00055     std::string m_res;
00056   };
00057   
00058     
00059 }
00060 
00067 #include "FWCore/PluginManager/interface/PluginFactory.h"
00068 namespace cond{
00069   typedef edmplugin::PluginFactory<ClassInfo*() > ClassInfoFactory;
00070 }
00071 
00072 #define PYTHON_ID(type_, plugName_, uname_)                                     \
00073   namespace pythonID { struct EDM_PLUGIN_SYM(plugName_, uname_)  : public cond::ClassID<type_> { EDM_PLUGIN_SYM(plugName_ , uname_) () : cond::ClassID<type_>(::plugName_){}};} \
00074   DEFINE_EDM_PLUGIN(cond::ClassInfoFactory, EDM_PLUGIN_SYM(pythonID::plugName_, uname_) , EDM_PLUGIN_SYM(pythonID::plugName_, uname_)().pluginName(cond::idCategories::pythonIDCategory).c_str() )
00075 
00076 
00077 #endif //  CondCoreDBCommon_ClassID_H