test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RootDelayedReader.h
Go to the documentation of this file.
1 #ifndef IOPool_Input_RootDelayedReader_h
2 #define IOPool_Input_RootDelayedReader_h
3 
4 /*----------------------------------------------------------------------
5 
6 RootDelayedReader.h // used by ROOT input sources
7 
8 ----------------------------------------------------------------------*/
9 
14 #include "RootTree.h"
15 
16 #include <map>
17 #include <memory>
18 #include <string>
19 #include <exception>
20 
21 class TClass;
22 namespace edm {
23  class InputFile;
24  class RootTree;
26  class Exception;
27 
28  //------------------------------------------------------------
29  // Class RootDelayedReader: pretends to support file reading.
30  //
31 
33  public:
36  typedef roottree::BranchMap::const_iterator iterator;
39  RootTree const& tree,
40  std::shared_ptr<InputFile> filePtr,
41  InputType inputType);
42 
43  virtual ~RootDelayedReader();
44 
45  RootDelayedReader(RootDelayedReader const&) = delete; // Disallow copying and moving
46  RootDelayedReader& operator=(RootDelayedReader const&) = delete; // Disallow copying and moving
47 
50  }
53  }
54 
55  void setSignals(signalslot::Signal<void(StreamContext const&, ModuleCallingContext const&)> const* preEventReadSource,
56  signalslot::Signal<void(StreamContext const&, ModuleCallingContext const&)> const* postEventReadSource) {
57  preEventReadFromSourceSignal_ =preEventReadSource;
58  postEventReadFromSourceSignal_ = postEventReadSource;
59  }
60 
61  private:
62  virtual std::unique_ptr<WrapperBase> getProduct_(BranchKey const& k, EDProductGetter const* ep) override;
63  virtual void mergeReaders_(DelayedReader* other) override {nextReader_ = other;}
64  virtual void reset_() override {nextReader_ = nullptr;}
65  std::pair<SharedResourcesAcquirer*, std::recursive_mutex*> sharedResources_() const override;
66 
67  BranchMap const& branches() const {return tree_.branches();}
68  iterator branchIter(BranchKey const& k) const {return branches().find(k);}
69  bool found(iterator const& iter) const {return iter != branches().end();}
70  BranchInfo const& getBranchInfo(iterator const& iter) const {return iter->second; }
71  // NOTE: filePtr_ appears to be unused, but is needed to prevent
72  // the file containing the branch from being reclaimed.
73  RootTree const& tree_;
76  std::unique_ptr<SharedResourcesAcquirer> resourceAcquirer_; // We do not use propagate_const because the acquirer is itself mutable.
77  std::shared_ptr<std::recursive_mutex> mutex_;
80 
83 
84  //If a fatal exception happens we need to make a copy so we can
85  // rethrow that exception on other threads. This avoids TTree
86  // non-exception safety problems on later calls to TTree.
87  mutable std::exception_ptr lastException_;
88  }; // class RootDelayedReader
89  //------------------------------------------------------------
90 }
91 #endif
virtual signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * preEventReadFromSourceSignal() const overridefinal
InputType
Definition: InputType.h:5
virtual void reset_() override
virtual void mergeReaders_(DelayedReader *other) override
RootTree const & tree_
roottree::BranchMap BranchMap
BranchInfo const & getBranchInfo(iterator const &iter) const
std::pair< SharedResourcesAcquirer *, std::recursive_mutex * > sharedResources_() const override
std::shared_ptr< std::recursive_mutex > mutex_
std::map< BranchKey const, BranchInfo > BranchMap
Definition: RootTree.h:63
virtual std::unique_ptr< WrapperBase > getProduct_(BranchKey const &k, EDProductGetter const *ep) override
std::exception_ptr lastException_
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * postEventReadFromSourceSignal_
void setSignals(signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *preEventReadSource, signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const *postEventReadSource)
RootDelayedReader(RootTree const &tree, std::shared_ptr< InputFile > filePtr, InputType inputType)
virtual signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * postEventReadFromSourceSignal() const overridefinal
IndexIntoFile::EntryNumber_t EntryNumber
Definition: RootTree.h:49
roottree::BranchMap::const_iterator iterator
RootDelayedReader & operator=(RootDelayedReader const &)=delete
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> const * preEventReadFromSourceSignal_
bool found(iterator const &iter) const
roottree::BranchInfo BranchInfo
string const
Definition: compareJSON.py:14
std::unique_ptr< SharedResourcesAcquirer > resourceAcquirer_
edm::propagate_const< std::shared_ptr< InputFile > > filePtr_
edm::propagate_const< TClass * > wrapperBaseTClass_
roottree::EntryNumber EntryNumber
BranchMap const & branches() const
Definition: RootTree.cc:174
iterator branchIter(BranchKey const &k) const
edm::propagate_const< DelayedReader * > nextReader_
BranchMap const & branches() const