LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
ProcessHistory.h
Go to the documentation of this file.
1 #ifndef canvas_Persistency_Provenance_ProcessHistory_h
2 #define canvas_Persistency_Provenance_ProcessHistory_h
3 
7 
8 #include <iosfwd>
9 #include <map>
10 #include <string>
11 #include <vector>
12 
13 namespace art {
15 
16  typedef std::map<ProcessHistoryID const, ProcessHistory> ProcessHistoryMap;
17 
19 
20  bool operator==(art::ProcessHistory const& a, art::ProcessHistory const& b);
21 
22  bool operator!=(art::ProcessHistory const& a, art::ProcessHistory const& b);
23 
24  bool isAncestor(art::ProcessHistory const& a, art::ProcessHistory const& b);
25 
26  bool isDescendant(art::ProcessHistory const& a, art::ProcessHistory const& b);
27 
28  std::ostream& operator<<(std::ostream& ost, art::ProcessHistory const& ph);
29 }
30 
32 public:
34  typedef std::vector<value_type> collection_type;
35 
38 
39  typedef collection_type::reverse_iterator reverse_iterator;
40  typedef collection_type::const_reverse_iterator const_reverse_iterator;
41 
42  typedef collection_type::reference reference;
43  typedef collection_type::const_reference const_reference;
44 
45  typedef collection_type::size_type size_type;
46 
47  ProcessHistory() = default;
48  explicit ProcessHistory(size_type n);
49  explicit ProcessHistory(collection_type const& vec);
50 
51  void swap(ProcessHistory& other);
52 
53  // Put the given ProcessConfiguration into the history. This makes
54  // our ProcessHistoryID become invalid.
55  void push_back(const_reference t);
56 
57  bool empty() const;
58  size_type size() const;
59  size_type capacity() const;
60  void reserve(size_type n);
61 
62  reference operator[](size_type i) { return data_[i]; }
63  const_reference operator[](size_type i) const { return data_[i]; }
64 
65  reference
66  at(size_type i)
67  {
68  return data_.at(i);
69  }
70  const_reference
71  at(size_type i) const
72  {
73  return data_.at(i);
74  }
75 
76  const_iterator
77  begin() const
78  {
79  return data_.begin();
80  }
81  const_iterator
82  end() const
83  {
84  return data_.end();
85  }
86  const_iterator
87  cbegin() const
88  {
89  return data_.cbegin();
90  }
91  const_iterator
92  cend() const
93  {
94  return data_.cend();
95  }
96  const_reverse_iterator
97  rbegin() const
98  {
99  return data_.rbegin();
100  }
101  const_reverse_iterator
102  rend() const
103  {
104  return data_.rend();
105  }
106 
107  const_reverse_iterator
108  crbegin() const
109  {
110  return data_.crbegin();
111  }
112  const_reverse_iterator
113  crend() const
114  {
115  return data_.crend();
116  }
117 
118  collection_type const&
119  data() const
120  {
121  return data_;
122  }
123  ProcessHistoryID id() const;
124 
125  // Return true, and fill in config appropriately, if the a process
126  // with the given name is recorded in this ProcessHistory. Return
127  // false, and do not modify config, if process with the given name
128  // is found.
129  bool getConfigurationForProcess(std::string const& name,
130  ProcessConfiguration& config) const;
131 
132  struct Transients {
134  };
135 
136 private:
137  collection_type data_{};
139 
140  void
142  {
143  transients_.get().phid_ = ProcessHistoryID();
144  }
145 
147  phid() const
148  {
149  return transients_.get().phid_;
150  }
151 };
152 
153 // Free swap function
154 inline void
156 {
157  a.swap(b);
158 }
159 
160 inline bool
162 {
163  return a.data() == b.data();
164 }
165 
166 inline bool
168 {
169  return !(a == b);
170 }
171 
172 inline bool
174 {
175  return isAncestor(b, a);
176 }
177 
178 //--------------------------------------------------------------------
179 // Implementation of ProcessHistory
180 
182  : data_(n) // NOT uniform initialization
183 {}
184 
186  : data_{vec}
187 {}
188 
189 inline void
191 {
192  data_.swap(other.data_);
193  phid().swap(other.phid());
194 }
195 
196 inline void
198 {
199  data_.push_back(t);
201 }
202 
203 inline bool
205 {
206  return data_.empty();
207 }
208 
211 {
212  return data_.size();
213 }
214 
217 {
218  return data_.capacity();
219 }
220 
221 inline void
223 {
224  data_.reserve(n);
225 }
226 
227 #endif /* canvas_Persistency_Provenance_ProcessHistory_h */
228 
229 // Local Variables:
230 // mode: c++
231 // End:
std::ostream & operator<<(std::ostream &os, EDAnalyzer::Table< T > const &t)
Definition: EDAnalyzer.h:184
const_iterator cbegin() const
const_reverse_iterator crend() const
collection_type::const_reference const_reference
reference operator[](size_type i)
intermediate_table::iterator iterator
const_reverse_iterator rend() const
bool empty() const
bool getConfigurationForProcess(std::string const &name, ProcessConfiguration &config) const
Transient< Transients > transients_
ProcessHistory()=default
collection_type::reference reference
const_iterator end() const
const_reverse_iterator rbegin() const
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
collection_type::const_iterator const_iterator
ProcessHistoryID id() const
std::map< ProcessHistoryID const, ProcessHistory > ProcessHistoryMap
const_iterator begin() const
Hash< ProcessHistoryType > ProcessHistoryID
collection_type::const_reverse_iterator const_reverse_iterator
collection_type::iterator iterator
collection_type const & data() const
intermediate_table::const_iterator const_iterator
void swap(Handle< T > &a, Handle< T > &b)
bool isDescendant(art::ProcessHistory const &a, art::ProcessHistory const &b)
const_reference at(size_type i) const
bool isAncestor(ProcessHistory const &a, ProcessHistory const &b)
collection_type data_
void invalidateProcessHistoryID_()
const_reverse_iterator crbegin() const
reference at(size_type i)
std::vector< value_type > collection_type
collection_type::reverse_iterator reverse_iterator
void reserve(size_type n)
HLT enums.
const_iterator cend() const
void swap(ProcessHistory &other)
Char_t n[5]
const_reference operator[](size_type i) const
size_type size() const
bool operator==(Provenance const &a, Provenance const &b)
Definition: Provenance.h:168
ProcessConfiguration value_type
void swap(Hash< I > &other)
Definition: Hash.h:175
void push_back(const_reference t)
size_type capacity() const
ProcessHistoryID & phid() const
collection_type::size_type size_type