CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/CondCore/IOVService/interface/KeyList.h

Go to the documentation of this file.
00001 #ifndef CondCore_IOVService_KeyList_h
00002 #define CondCore_IOVService_KeyList_h
00003 
00004 #include "CondCore/IOVService/interface/IOVProxy.h"
00005 #include "CondFormats/Common/interface/BaseKeyed.h"
00006 #include<vector>
00007 #include<string>
00008 
00009 /*
00010  * KeyList represents a set of payloads each identified by a key  and "valid" at given time
00011  * Usually these payloads are configuration objects loaded in anvance
00012  * The model used here calls for all payloads to be "stored" in a single IOVSequence each identified by a unique key 
00013  * (properly hashed to be mapped in 64bits)
00014  *
00015  * the keylist is just a vector of the hashes each corresponding to a key
00016  * the correspondence position in the vector user-friendly name is kept in 
00017  * a list of all "names" that is defined in advance and kept in a dictionary at IOVSequence level
00018  
00019  *
00020  */
00021 
00022 namespace cond {
00023    
00024   class IOVKeysDescription;
00025 
00026   class KeyList {
00027   public:
00028     typedef BaseKeyed Base;
00029     
00030     KeyList(IOVKeysDescription const * idescr=0);
00031 
00032     void init(cond::IOVProxy const & seq ) {
00033       m_sequence = seq;
00034     }
00035 
00036     void load(std::vector<unsigned long long> const & keys);
00037 
00038     template<typename T> 
00039     T const * get(int n) const {
00040       return dynamic_cast<T const *>(elem(n));
00041     }
00042 
00043    template<typename T> 
00044     T const * get(char const * iname) const {
00045       return dynamic_cast<T const *>(elem(iname));
00046     }
00047     
00048     template<typename T> 
00049     T const * get(std::string const & iname) const {
00050       return dynamic_cast<T const *>(elem(iname));
00051     }
00052     
00053     BaseKeyed const * elem(int n) const;
00054 
00055     BaseKeyed const * elem(char const * iname) const;
00056 
00057     BaseKeyed const * elem(std::string const & iname) const;
00058 
00059     int size() const { return m_data.size();}
00060 
00061   private:
00062     // tag and dict
00063     IOVKeysDescription const * m_description;
00064 
00065     // the full collection of keyed object
00066     cond::IOVProxy m_sequence;
00067     // the current set
00068     std::vector<boost::shared_ptr<Base> > m_data;
00069 
00070   };
00071 
00072 
00073 }
00074 
00075 #endif