Go to the documentation of this file.00001 #ifndef DataFormats_Provenance_ProcessHistory_h
00002 #define DataFormats_Provenance_ProcessHistory_h
00003
00004 #include "DataFormats/Provenance/interface/ProcessConfiguration.h"
00005 #include "DataFormats/Provenance/interface/ProcessHistoryID.h"
00006
00007 #include <iosfwd>
00008 #include <string>
00009 #include <utility>
00010 #include <vector>
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_(), transient_() {}
00030 explicit ProcessHistory(size_type n) : data_(n), transient_() {}
00031 explicit ProcessHistory(collection_type const& vec) : data_(vec), transient_() {}
00032
00033 #ifndef __GCCXML__
00034 template<typename... Args>
00035 void emplace_back(Args&&... args) {data_.emplace_back(std::forward<Args>(args)...); phid() = ProcessHistoryID();}
00036 #endif
00037
00038 void push_front(const_reference t) {data_.insert(data_.begin(), t); phid() = ProcessHistoryID();}
00039 void push_back(const_reference t) {data_.push_back(t); phid() = ProcessHistoryID();}
00040 void swap(ProcessHistory& other) {data_.swap(other.data_); phid().swap(other.phid());}
00041 bool empty() const {return data_.empty();}
00042 size_type size() const {return data_.size();}
00043 size_type capacity() const {return data_.capacity();}
00044 void reserve(size_type n) {data_.reserve(n);}
00045
00046 reference operator[](size_type i) {return data_[i];}
00047 const_reference operator[](size_type i) const {return data_[i];}
00048
00049 reference at(size_type i) {return data_.at(i);}
00050 const_reference at(size_type i) const {return data_.at(i);}
00051
00052 const_iterator begin() const {return data_.begin();}
00053 const_iterator end() const {return data_.end();}
00054
00055 const_reverse_iterator rbegin() const {return data_.rbegin();}
00056 const_reverse_iterator rend() const {return data_.rend();}
00057
00058
00059
00060
00061
00062
00063
00064 collection_type const& data() const {return data_;}
00065 ProcessHistoryID id() const;
00066
00067
00068
00069
00070
00071 bool getConfigurationForProcess(std::string const& name, ProcessConfiguration& config) const;
00072
00073 void clear() {
00074 data_.clear();
00075 phid() = ProcessHistoryID();
00076 }
00077
00078 void reduce();
00079
00080 void initializeTransients() const {transient_.reset();}
00081
00082 struct Transients {
00083 Transients() : phid_() {}
00084 void reset() {phid_.reset();}
00085 ProcessHistoryID phid_;
00086 };
00087
00088 private:
00089 ProcessHistoryID& phid() const {return transient_.phid_;}
00090 collection_type data_;
00091 mutable Transients transient_;
00092 };
00093
00094
00095 inline
00096 void
00097 swap(ProcessHistory& a, ProcessHistory& b) {
00098 a.swap(b);
00099 }
00100
00101 inline
00102 bool
00103 operator==(ProcessHistory const& a, ProcessHistory const& b) {
00104 return a.data() == b.data();
00105 }
00106
00107 inline
00108 bool
00109 operator!=(ProcessHistory const& a, ProcessHistory const& b) {
00110 return !(a==b);
00111 }
00112
00113 bool
00114 isAncestor(ProcessHistory const& a, ProcessHistory const& b);
00115
00116 inline
00117 bool
00118 isDescendant(ProcessHistory const& a, ProcessHistory const& b) {
00119 return isAncestor(b, a);
00120 }
00121
00122 std::ostream& operator<<(std::ostream& ost, ProcessHistory const& ph);
00123 }
00124
00125 #endif