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