CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClassID.cc
Go to the documentation of this file.
3 #include <typeinfo>
4 #include "cxxabi.h"
5 
6 namespace cond {
7 
8  char const * className(const std::type_info& t) {
9  int status=0;
10  return __cxxabiv1::__cxa_demangle(t.name(), 0, 0, &status);
11  }
12 
13 
14  namespace {
15  std::string id(const std::type_info& t) {
16  const Reflex::Type type=Reflex::Type::ByTypeInfo(t);
17  std::string s;
18  if (type) {
19  Reflex::PropertyList pl = type.Properties();
20  if ( pl.HasProperty("ClassID") ) {
21  s = pl.PropertyAsString("ClassID");
22  }
23  else {
24  char buff[20];
25  genMD5(type.Name(Reflex::SCOPED),buff);
26  Guid* gd = reinterpret_cast<Guid*>(buff);
27  s = gd->toString();
28  }
29 // std::cout << "CondCore::ClassID: CLID for Reflex type " << type.Name(Reflex::SCOPED)
30 // << " is " << s << std::endl;
31  }
32  else {
33  // only for test
34  std::string name = className(t);
35 // std::cout << "CondCore::ClassID: Warning no Reflex type for " << name << std::endl;
36  char buff[20];
37  genMD5(name,buff);
38  Guid* gd = reinterpret_cast<Guid*>(buff);
39  s = gd->toString();
40  }
41  return s;
42  }
43  }
44 
45 
46 
47 
48  ClassIDRegistry::ClassIDRegistry(std::string const & pfix) : prefix(pfix+"/"){}
49 
50  const char * ClassIDRegistry::registerMe(const std::type_info& t) {
51  sids.push_back(prefix+id(t)+"\0");
52  csids.push_back(sids.back().data());
53  return sids.back().c_str();
54  }
55 
56  const char * ClassInfo::registerMe(const std::type_info& t) {
57  return registry->registerMe(t);
58  }
59 
60  std::string ClassInfo::pluginName(std::string const & prefix) const {
61  return prefix + "/" +id(tinfo);
62  }
63 
64 
65 
66 }
67 
type
Definition: HCALResponse.h:22
const std::type_info & tinfo
Definition: ClassID.h:31
std::vector< std::string > sids
Definition: ClassID.h:38
std::string prefix
Definition: ClassID.h:45
void * genMD5(void *buffer, unsigned long len, void *code)
Definition: GenMD5.cc:358
const char * registerMe(const std::type_info &t)
Definition: ClassID.cc:50
ClassIDRegistry(std::string const &pfix)
Definition: ClassID.cc:48
std::vector< const char * > csids
Definition: ClassID.h:39
ClassIDRegistry * registry
Definition: ClassID.h:29
#define EDM_REGISTER_PLUGINFACTORY(_factory_, _category_)
const char * registerMe(const std::type_info &t)
Definition: ClassID.cc:56
std::string pluginName(std::string const &prefix) const
Definition: ClassID.cc:60
char const * className(const std::type_info &t)
Definition: ClassID.cc:8
string s
Definition: asciidump.py:422
tuple status
Definition: ntuplemaker.py:245