CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/CondCore/DBOutputService/interface/KeyedElement.h

Go to the documentation of this file.
00001 #include "CondFormats/Common/interface/Time.h"
00002 #include "CondFormats/Common/interface/BaseKeyed.h"
00003 #include "CondFormats/Common/interface/hash64.h"
00004 #include <sstream>
00005 
00006 namespace cond{
00007 
00008   /* encapsulate data to write a keyed element in an IOVSequence
00009    */
00010   class KeyedElement {
00011 
00012   public:
00013     // constructor from int key
00014    KeyedElement(BaseKeyed * obj, cond::Time_t key) : 
00015      m_obj(obj), 
00016      m_skey(""),
00017      m_key(key) {
00018      std::ostringstream ss; ss << key;
00019      m_skey  = ss.str();
00020      (*obj).setKey(m_skey); 
00021    }
00022 
00023     // constructor from ascii key
00024    KeyedElement(BaseKeyed * obj, std::string key) : 
00025       m_obj(obj), 
00026       m_skey(key),
00027       m_key(convert(key)) {
00028      (*obj).setKey(m_skey);
00029    }
00030     
00031     static cond::Time_t convert(std::string key) {
00032       return cond::hash64( (unsigned char*)(&key[0]),key.size(),0);
00033     }
00034 
00035     BaseKeyed * m_obj;
00036     std::string  m_skey;
00037     cond::Time_t m_key;
00038   };
00039   
00040   
00041 }