File indexing completed on 2024-04-06 12:04:10
0001 #ifndef DataFormats_FWLite_Record_h
0002 #define DataFormats_FWLite_Record_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #include <map>
0024 #include <string>
0025 #include <typeinfo>
0026 #include <vector>
0027
0028
0029 #include "DataFormats/FWLite/interface/IOVSyncValue.h"
0030 #include "FWCore/Utilities/interface/TypeID.h"
0031 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0032
0033
0034 class TTree;
0035 class TBranch;
0036 namespace edm {
0037 class EventID;
0038 class Timestamp;
0039 }
0040
0041 namespace cms {
0042 class Exception;
0043 }
0044
0045 namespace fwlite {
0046
0047 class Record {
0048 public:
0049 Record(const char* iName, TTree*);
0050 Record(const Record&) = delete;
0051 const Record& operator=(const Record&) = delete;
0052
0053 virtual ~Record();
0054
0055
0056 const std::string& name() const;
0057
0058 template <typename HANDLE>
0059 bool get(HANDLE&, const char* iLabel = "") const;
0060
0061 const IOVSyncValue& startSyncValue() const;
0062 const IOVSyncValue& endSyncValue() const;
0063
0064 std::vector<std::pair<std::string, std::string>> typeAndLabelOfAvailableData() const;
0065
0066
0067
0068 void syncTo(const edm::EventID&, const edm::Timestamp&);
0069
0070 private:
0071 cms::Exception* get(const edm::TypeID&, const char* iLabel, const void*&) const;
0072 void resetCaches();
0073
0074 std::string m_name;
0075 TTree* m_tree;
0076 std::map<IOVSyncValue, unsigned int> m_startIOVtoEntry;
0077 long m_entry;
0078 IOVSyncValue m_start;
0079 IOVSyncValue m_end;
0080
0081
0082 CMS_SA_ALLOW mutable std::map<std::pair<edm::TypeID, std::string>, std::pair<TBranch*, void*>> m_branches;
0083 };
0084
0085 template <typename HANDLE>
0086 bool Record::get(HANDLE& iHandle, const char* iLabel) const {
0087 const void* value = nullptr;
0088 cms::Exception* e = get(edm::TypeID(iHandle.typeInfo()), iLabel, value);
0089 if (nullptr == e) {
0090 iHandle = HANDLE(value);
0091 } else {
0092 iHandle = HANDLE(e);
0093 }
0094 return nullptr == e;
0095 }
0096
0097 }
0098
0099 #endif