CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Record.h
Go to the documentation of this file.
1 #ifndef DataFormats_FWLite_Record_h
2 #define DataFormats_FWLite_Record_h
3 // -*- C++ -*-
4 //
5 // Package: FWLite
6 // Class : Record
7 //
17 //
18 // Original Author:
19 // Created: Thu Dec 10 15:58:15 CST 2009
20 //
21 
22 // system include files
23 #include <map>
24 #include <string>
25 #include <typeinfo>
26 #include <vector>
27 
28 // user include files
31 
32 // forward declarations
33 class TTree;
34 class TBranch;
35 namespace edm {
36  class EventID;
37  class Timestamp;
38 }
39 
40 namespace cms {
41  class Exception;
42 }
43 
44 namespace fwlite
45 {
46 
47  class Record {
48  class TypeID : public edm::TypeIDBase {
49  public:
50  TypeID(const std::type_info& iInfo): edm::TypeIDBase(iInfo) {}
51  using TypeIDBase::typeInfo;
52  };
53 
54  public:
55  Record(const char* iName, TTree*);
56  virtual ~Record();
57 
58  // ---------- const member functions ---------------------
59  const std::string& name() const;
60 
61  template< typename HANDLE>
62  bool get(HANDLE&,const char* iLabel="")const;
63 
64  const IOVSyncValue& startSyncValue() const;
65  const IOVSyncValue& endSyncValue() const;
66 
67  std::vector<std::pair<std::string,std::string> > typeAndLabelOfAvailableData() const;
68  // ---------- static member functions --------------------
69 
70  // ---------- member functions ---------------------------
71  void syncTo(const edm::EventID&, const edm::Timestamp&);
72 
73  private:
74  Record(const Record&); // stop default
75 
76  const Record& operator=(const Record&); // stop default
77 
78  cms::Exception* get(const TypeID&, const char* iLabel, const void*&) const;
79 
80  void resetCaches();
81  // ---------- member data --------------------------------
82  std::string m_name;
83  TTree* m_tree;
84  std::map<IOVSyncValue,unsigned int> m_startIOVtoEntry;
85  long m_entry;
88 
89  mutable std::map<std::pair<TypeID,std::string>, std::pair<TBranch*,void*>> m_branches;
90  };
91 
92  template <typename HANDLE>
93  bool
94  Record::get(HANDLE& iHandle, const char* iLabel) const
95  {
96  const void* value = 0;
97  cms::Exception* e = get(TypeID(iHandle.typeInfo()),iLabel,value);
98  if(0==e){
99  iHandle = HANDLE(value);
100  } else {
101  iHandle = HANDLE(e);
102  }
103  return 0==e;
104  }
105 
106 } /* fwlite */
107 
108 #endif
const Record & operator=(const Record &)
Record(const char *iName, TTree *)
Definition: Record.cc:36
const IOVSyncValue & startSyncValue() const
Definition: Record.cc:166
TypeID(const std::type_info &iInfo)
Definition: Record.h:50
IOVSyncValue m_start
Definition: Record.h:86
long m_entry
Definition: Record.h:85
TTree * m_tree
Definition: Record.h:83
const std::string & name() const
Definition: Record.cc:160
void syncTo(const edm::EventID &, const edm::Timestamp &)
Definition: Record.cc:90
std::vector< std::pair< std::string, std::string > > typeAndLabelOfAvailableData() const
Definition: Record.cc:238
std::string m_name
Definition: Record.h:82
std::map< std::pair< TypeID, std::string >, std::pair< TBranch *, void * > > m_branches
Definition: Record.h:89
bool get(HANDLE &, const char *iLabel="") const
Definition: Record.h:94
std::map< IOVSyncValue, unsigned int > m_startIOVtoEntry
Definition: Record.h:84
void resetCaches()
Definition: Record.cc:139
IOVSyncValue m_end
Definition: Record.h:87
virtual ~Record()
Definition: Record.cc:69
const IOVSyncValue & endSyncValue() const
Definition: Record.cc:170