CMS 3D CMS Logo

Group.h

Go to the documentation of this file.
00001 #ifndef FWCore_Framework_Group_h
00002 #define FWCore_Framework_Group_h
00003 
00004 /*----------------------------------------------------------------------
00005   
00006 Group: A collection of information related to a single EDProduct. This
00007 is the storage unit of such information.
00008 
00009 ----------------------------------------------------------------------*/
00010 
00011 #include <memory>
00012 
00013 #include "boost/shared_ptr.hpp"
00014 
00015 #include "Reflex/Type.h"
00016 
00017 #include "DataFormats/Common/interface/EDProduct.h"
00018 #include "DataFormats/Provenance/interface/ConstBranchDescription.h"
00019 #include "DataFormats/Provenance/interface/EventEntryInfo.h"
00020 #include "DataFormats/Provenance/interface/Provenance.h"
00021 
00022 namespace edm {
00023   class Group {
00024   public:
00025     Group();
00026 
00027     Group(ConstBranchDescription const& bd, bool demand);
00028 
00029     explicit Group(ConstBranchDescription const& bd);
00030 
00031     Group(std::auto_ptr<EDProduct> edp,
00032           ConstBranchDescription const& bd,
00033           std::auto_ptr<EventEntryInfo> entryInfo);
00034 
00035     Group(ConstBranchDescription const& bd,
00036           std::auto_ptr<EventEntryInfo> entryInfo);
00037 
00038     Group(std::auto_ptr<EDProduct> edp,
00039           ConstBranchDescription const& bd,
00040           boost::shared_ptr<EventEntryInfo> entryInfo);
00041 
00042     Group(ConstBranchDescription const& bd,
00043           boost::shared_ptr<EventEntryInfo> entryInfo);
00044 
00045     ~Group();
00046 
00047     void swap(Group& other);
00048 
00049     // product is not available (dropped or never created)
00050     bool productUnavailable() const;
00051 
00052     // provenance is currently available
00053     bool provenanceAvailable() const;
00054 
00055     // Scheduled for on demand production
00056     bool onDemand() const;
00057 
00058     EDProduct const* product() const { return product_.get(); }
00059 
00060     boost::shared_ptr<EventEntryInfo> entryInfoPtr() const {return entryInfo_;}
00061 
00062     ConstBranchDescription const& productDescription() const {return *branchDescription_;}
00063 
00064     std::string const& moduleLabel() const {return branchDescription_->moduleLabel();}
00065 
00066     std::string const& productInstanceName() const {return branchDescription_->productInstanceName();}
00067 
00068     std::string const& processName() const {return branchDescription_->processName();}
00069 
00070     Provenance const * provenance() const;
00071 
00072     ProductStatus status() const;
00073 
00074     // The following is const because we can add an EDProduct to the
00075     // cache after creation of the Group, without changing the meaning
00076     // of the Group.
00077     void setProduct(std::auto_ptr<EDProduct> prod) const;
00078 
00079     // The following is const because we can add the provenance
00080     // to the cache after creation of the Group, without changing the meaning
00081     // of the Group.
00082     void setProvenance(boost::shared_ptr<EventEntryInfo> entryInfo) const;
00083 
00084     // Write the group to the stream.
00085     void write(std::ostream& os) const;
00086 
00087     // Replace the existing group with a new one
00088     void replace(Group& g);
00089 
00090     // Return the type of the product stored in this Group.
00091     // We are relying on the fact that Type instances are small, and
00092     // so we are free to copy them at will.
00093     ROOT::Reflex::Type productType() const;
00094 
00095     // Return true if this group's product is a sequence, and if the
00096     // sequence has a 'value_type' that 'matches' the given type.
00097     // 'Matches' in this context means the sequence's value_type is
00098     // either the same as the given type, or has the given type as a
00099     // public base type.
00100     bool isMatchingSequence(ROOT::Reflex::Type const& wanted) const;
00101 
00102     void mergeGroup(Group * newGroup);
00103 
00104   private:
00105     Group(const Group&);
00106     void operator=(const Group&);
00107 
00108     mutable boost::shared_ptr<EDProduct> product_;
00109     boost::shared_ptr<ConstBranchDescription> branchDescription_;
00110     mutable boost::shared_ptr<EventEntryInfo> entryInfo_;
00111     mutable boost::shared_ptr<Provenance> prov_;
00112     bool    dropped_;
00113     bool    onDemand_;
00114   };
00115 
00116   // Free swap function
00117   inline
00118   void
00119   swap(Group& a, Group& b) {
00120     a.swap(b);
00121   }
00122 
00123   inline
00124   std::ostream&
00125   operator<<(std::ostream& os, Group const& g) {
00126     g.write(os);
00127     return os;
00128   }
00129 
00130 }
00131 #endif

Generated on Tue Jun 9 17:35:41 2009 for CMSSW by  doxygen 1.5.4