00001 #include "CondCore/DBCommon/interface/ClassID.h"
00002 #include "StorageSvc/DbReflex.h"
00003 #include <typeinfo>
00004 #include "cxxabi.h"
00005 #include <iostream>
00006
00007 namespace pool { void genMD5(const std::string& s, void* code); }
00008
00009 namespace cond {
00010
00011 namespace {
00012 std::string id(const std::type_info& t) {
00013 const ROOT::Reflex::Type type=ROOT::Reflex::Type::ByTypeInfo(t);
00014 std::string s;
00015 if (type) {
00016 ROOT::Reflex::PropertyList pl = type.Properties();
00017 if ( pl.HasProperty("ClassID") ) {
00018 s = pl.PropertyAsString("ClassID");
00019 }
00020 else {
00021 char buff[20];
00022 pool::genMD5(type.Name(ROOT::Reflex::SCOPED),buff);
00023 s = ((pool::Guid*)buff)->toString();
00024 }
00025
00026
00027 }
00028 else {
00029
00030 int status=0;
00031 std::string name = __cxxabiv1::__cxa_demangle(t.name(), 0, 0, &status);
00032
00033 char buff[20];
00034 pool::genMD5(name,buff);
00035 s = ((pool::Guid*)buff)->toString();
00036 }
00037 return s;
00038 }
00039 }
00040
00041 ClassIDRegistry::ClassIDRegistry(std::string const & pfix) : prefix(pfix+"/"){}
00042
00043 const char * ClassIDRegistry::registerMe(const std::type_info& t) {
00044 sids.push_back(prefix+id(t)+"\0");
00045 csids.push_back(sids.back().data());
00046 return sids.back().c_str();
00047 }
00048
00049 const char * ClassInfo::registerMe(const std::type_info& t) {
00050 return registry->registerMe(t);
00051 }
00052
00053 std::string ClassInfo::pluginName(std::string const & prefix) const {
00054 return prefix + "/" +id(tinfo);
00055 }
00056
00057
00058
00059 }
00060
00061 EDM_REGISTER_PLUGINFACTORY(cond::ClassInfoFactory, "CondFormatsID");