CMS 3D CMS Logo

ProcessHistory.h

Go to the documentation of this file.
00001 #ifndef DataFormats_Provenance_ProcessHistory_h
00002 #define DataFormats_Provenance_ProcessHistory_h
00003 
00004 #include <iosfwd>
00005 #include <string>
00006 #include <vector>
00007 
00008 #include "DataFormats/Provenance/interface/ProcessConfiguration.h"
00009 #include "DataFormats/Provenance/interface/ProcessHistoryID.h"
00010 #include "DataFormats/Provenance/interface/Transient.h"
00011 
00012 namespace edm {
00013   class ProcessHistory {
00014   public:
00015     typedef ProcessConfiguration value_type;
00016     typedef std::vector<value_type> collection_type;
00017 
00018     typedef collection_type::iterator       iterator;
00019     typedef collection_type::const_iterator const_iterator;
00020 
00021     typedef collection_type::reverse_iterator       reverse_iterator;
00022     typedef collection_type::const_reverse_iterator const_reverse_iterator;
00023 
00024     typedef collection_type::reference reference;
00025     typedef collection_type::const_reference const_reference;
00026 
00027     typedef collection_type::size_type size_type;
00028 
00029     ProcessHistory() : data_(), transients_() {}
00030     explicit ProcessHistory(size_type n) : data_(n), transients_() {}
00031     explicit ProcessHistory(collection_type const& vec) : data_(vec), transients_() {}
00032 
00033     void push_back(const_reference t) {data_.push_back(t); phid() = ProcessHistoryID();}
00034     void swap(ProcessHistory& other) {data_.swap(other.data_); phid().swap(other.phid());}
00035     bool empty() const {return data_.empty();}
00036     size_type size() const {return data_.size();}
00037     size_type capacity() const {return data_.capacity();}
00038     void reserve(size_type n) {data_.reserve(n);}
00039 
00040     reference operator[](size_type i) {return data_[i];}
00041     const_reference operator[](size_type i) const {return data_[i];}
00042 
00043     reference at(size_type i) {return data_.at(i);}
00044     const_reference at(size_type i) const {return data_.at(i);}
00045 
00046     const_iterator begin() const {return data_.begin();}
00047     const_iterator end() const {return data_.end();}
00048 
00049     const_reverse_iterator rbegin() const {return data_.rbegin();}
00050     const_reverse_iterator rend() const {return data_.rend();}
00051 
00052 //     iterator begin() {return data_.begin();}
00053 //     iterator end() {return data_.end();}
00054 
00055 //     reverse_iterator rbegin() {return data_.rbegin();}
00056 //     reverse_iterator rend() {return data_.rend();}
00057 
00058     collection_type const& data() const {return data_;}
00059     ProcessHistoryID id() const;
00060 
00061 
00062     // Return true, and fill in config appropriately, if the a process
00063     // with the given name is recorded in this ProcessHistory. Return
00064     // false, and do not modify config, if process with the given name
00065     // is found.
00066     bool getConfigurationForProcess(std::string const& name, ProcessConfiguration& config) const;
00067 
00068     struct Transients {
00069       Transients() : phid_() {}
00070       ProcessHistoryID phid_;
00071     };
00072 
00073     void setDefaultTransients() const {
00074         transients_ = Transients();
00075     };
00076 
00077   private:
00078     ProcessHistoryID & phid() const {return transients_.get().phid_;}
00079     collection_type data_;
00080     mutable Transient<Transients> transients_;
00081   };
00082 
00083   // Free swap function
00084   inline
00085   void
00086   swap(ProcessHistory& a, ProcessHistory& b) {
00087     a.swap(b);
00088   }
00089 
00090   inline
00091   bool
00092   operator==(ProcessHistory const& a, ProcessHistory const& b) {
00093     return a.data() == b.data();
00094   }
00095 
00096   inline
00097   bool
00098   operator!=(ProcessHistory const& a, ProcessHistory const& b) {
00099     return !(a==b);
00100   }
00101 
00102   bool
00103   isAncestor(ProcessHistory const& a, ProcessHistory const& b);
00104 
00105   inline
00106   bool
00107   isDescendant(ProcessHistory const& a, ProcessHistory const& b) {
00108     return isAncestor(b, a);
00109   }
00110 
00111   std::ostream& operator<<(std::ostream& ost, ProcessHistory const& ph);
00112 }
00113 
00114 #endif

Generated on Tue Jun 9 17:31:36 2009 for CMSSW by  doxygen 1.5.4