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  public:
49  Record(const char* iName, TTree*);
50  virtual ~Record();
51 
52  // ---------- const member functions ---------------------
53  const std::string& name() const;
54 
55  template< typename HANDLE>
56  bool get(HANDLE&,const char* iLabel="")const;
57 
58  const IOVSyncValue& startSyncValue() const;
59  const IOVSyncValue& endSyncValue() const;
60 
61  std::vector<std::pair<std::string,std::string> > typeAndLabelOfAvailableData() const;
62  // ---------- static member functions --------------------
63 
64  // ---------- member functions ---------------------------
65  void syncTo(const edm::EventID&, const edm::Timestamp&);
66 
67  private:
68  Record(const Record&); // stop default
69 
70  const Record& operator=(const Record&); // stop default
71 
72  cms::Exception* get(const edm::TypeID&, const char* iLabel, const void*&) const;
73  void resetCaches();
74  // ---------- member data --------------------------------
76  TTree* m_tree;
77  std::map<IOVSyncValue,unsigned int> m_startIOVtoEntry;
78  long m_entry;
81 
82  mutable std::map<std::pair<edm::TypeID,std::string>, std::pair<TBranch*,void*>> m_branches;
83  };
84 
85  template <typename HANDLE>
86  bool
87  Record::get(HANDLE& iHandle, const char* iLabel) const
88  {
89  const void* value = 0;
90  cms::Exception* e = get(edm::TypeID(iHandle.typeInfo()),iLabel,value);
91  if(0==e){
92  iHandle = HANDLE(value);
93  } else {
94  iHandle = HANDLE(e);
95  }
96  return 0==e;
97  }
98 
99 } /* fwlite */
100 
101 
102 #endif
const Record & operator=(const Record &)
Record(const char *iName, TTree *)
Definition: Record.cc:36
const IOVSyncValue & startSyncValue() const
Definition: Record.cc:166
IOVSyncValue m_start
Definition: Record.h:79
long m_entry
Definition: Record.h:78
TTree * m_tree
Definition: Record.h:76
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:236
std::string m_name
Definition: Record.h:75
std::map< std::pair< edm::TypeID, std::string >, std::pair< TBranch *, void * > > m_branches
Definition: Record.h:82
bool get(HANDLE &, const char *iLabel="") const
Definition: Record.h:87
std::map< IOVSyncValue, unsigned int > m_startIOVtoEntry
Definition: Record.h:77
void resetCaches()
Definition: Record.cc:139
IOVSyncValue m_end
Definition: Record.h:80
virtual ~Record()
Definition: Record.cc:69
const IOVSyncValue & endSyncValue() const
Definition: Record.cc:170