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
00053
00054
00055
00056
00057
00058 collection_type const& data() const {return data_;}
00059 ProcessHistoryID id() const;
00060
00061
00062
00063
00064
00065
00066 bool getConfigurationForProcess(std::string const& name, ProcessConfiguration& config) const;
00067
00068 struct Transients {
00069 Transients() : phid_() {}
00070 ProcessHistoryID phid_;
00071 };
00072
00073 private:
00074 ProcessHistoryID & phid() const {return transients_.get().phid_;}
00075 collection_type data_;
00076 mutable Transient<Transients> transients_;
00077 };
00078
00079
00080 inline
00081 void
00082 swap(ProcessHistory& a, ProcessHistory& b) {
00083 a.swap(b);
00084 }
00085
00086 inline
00087 bool
00088 operator==(ProcessHistory const& a, ProcessHistory const& b) {
00089 return a.data() == b.data();
00090 }
00091
00092 inline
00093 bool
00094 operator!=(ProcessHistory const& a, ProcessHistory const& b) {
00095 return !(a==b);
00096 }
00097
00098 bool
00099 isAncestor(ProcessHistory const& a, ProcessHistory const& b);
00100
00101 inline
00102 bool
00103 isDescendant(ProcessHistory const& a, ProcessHistory const& b) {
00104 return isAncestor(b, a);
00105 }
00106
00107 std::ostream& operator<<(std::ostream& ost, ProcessHistory const& ph);
00108 }
00109
00110 #endif