test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PoolToken.cc
Go to the documentation of this file.
4 #include "ClassUtils.h"
5 //
6 #include <cstring>
7 #include <cstdio>
8 // externals
10 
11 namespace cond {
12 
13  static const char* fmt_tech = "[TECH=%08X]";
14  static const char* fmt_oid = "[OID=%08X-%08X]";
15 
16  std::pair<std::string,int> parseToken( const std::string& source ){
17  if( source.empty() ) ora::throwException("Provided token is empty.","PoolToken::parseToken");
19  std::pair<std::string,int> oid;
20  oid.first = "";
21  oid.second = -1;
22  for(char* p1 = (char*)tmp.c_str(); p1; p1 = ::strchr(++p1,'[')) {
23  char* p2 = ::strchr(p1, '=');
24  char* p3 = ::strchr(p1, ']');
25  if ( p2 && p3 ) {
26  char* val = p2+1;
27  if ( ::strncmp("[DB=", p1, 4) == 0 ) {
28  *p3 = 0;
29  } else if ( ::strncmp("[CNT=", p1, 5) == 0 ) {
30  *p3 = 0;
31  oid.first = val;
32  } else if ( ::strncmp(fmt_oid, p1, 5) == 0 ) {
33  int nn;
34  ::sscanf(p1, fmt_oid, &nn, &oid.second);
35  } else {
36  *p3 = *p2 = 0;
37  }
38  *p3 = ']';
39  *p2 = '=';
40  }
41  }
42  return oid;
43  }
44 
45  std::string writeToken( const std::string& containerName,
46  int oid0,
47  int oid1,
48  const std::string& className ){
49  std::string str = writeTokenContainerFragment( containerName, className );
50  char text[128];
51  ::sprintf(text, fmt_oid, oid0, oid1);
52  str += text;
53  return str;
54  }
55 
57  const std::string& className ){
58 
59  char buff[20];
60  std::string clguid("");
61  // first lookup the class guid in the dictionary
62  edm::TypeWithDict containerType = edm::TypeWithDict::byName( className );
63  if( containerType ){
64  clguid = ora::ClassUtils::getClassProperty( std::string("ClassID"),containerType );
65  }
66  // if not found, generate one...
67  if( clguid.empty() ){
68  genMD5(className,buff);
69  Guid* gd = reinterpret_cast<Guid*>(buff);
70  clguid = gd->toString();
71  }
72  int tech = 0xB01;
73  char text[128];
74  std::string str = "[DB="+Guid::null()+"][CNT=" + containerName + "][CLID="+clguid+"]";
75  ::sprintf(text, fmt_tech, tech);
76  str += text;
77  return str;
78  }
79 
80 
81 }
82 
83 
std::string toString() const
Definition: Guid.cc:27
static std::string null()
Definition: Guid.cc:11
std::pair< std::string, int > parseToken(const std::string &objectId)
Definition: PoolToken.cc:16
static const char * fmt_oid
Definition: PoolToken.cc:14
std::string writeTokenContainerFragment(const std::string &containerName, const std::string &className)
Definition: PoolToken.cc:56
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:60
static const char * fmt_tech
Definition: PoolToken.cc:13
void * genMD5(void *buffer, unsigned long len, void *code)
Definition: GenMD5.cc:358
tuple text
Definition: runonSM.py:42
double p2[4]
Definition: TauolaWrapper.h:90
Definition: Guid.h:10
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
double p1[4]
Definition: TauolaWrapper.h:89
std::string getClassProperty(const std::string &propertyName, const edm::TypeWithDict &type)
Definition: ClassUtils.cc:500
std::string writeToken(const std::string &containerName, int oid0, int oid1, const std::string &className)
Definition: PoolToken.cc:45
static std::string const source
Definition: EdmProvDump.cc:43
std::string className(const T &t)
Definition: ClassName.h:30
double p3[4]
Definition: TauolaWrapper.h:91