1 #ifndef DataFormats_Common_View_h
2 #define DataFormats_Common_View_h
23 #include "boost/iterator/indirect_iterator.hpp"
70 class View :
public ViewBase {
71 typedef std::vector<T const*>
seq_t;
81 typedef boost::indirect_iterator<typename seq_t::const_iterator>
const_iterator;
97 View(std::vector<void const*>
const& pointers,
140 return refs_.product();
153 template<
typename T>
bool operator< (View<T>
const&,
View<T> const&);
154 template<
typename T>
bool operator<=(View<T>
const&,
View<T> const&);
181 if(helpers.get() != 0) {
182 assert(numElements == helpers->size());
184 items_.reserve(numElements);
185 ptrs_.reserve(refs_.size());
187 void const*
p = pointers[
i];
188 items_.push_back(static_cast<pointer>(p));
190 ptrs_.push_back(Ptr<T>(helpers->id(),
static_cast<T const*
>(
p), helpers->keyForIndex(
i)));
191 }
else if(helpers->productGetter() != 0) {
192 ptrs_.push_back(Ptr<T>(helpers->id(), helpers->keyForIndex(
i), helpers->productGetter()));
194 ptrs_.push_back(Ptr<T>(helpers->id(), 0, helpers->keyForIndex(
i)));
211 items_.swap(other.items_);
212 refs_.swap(other.refs_);
213 ptrs_.swap(other.ptrs_);
219 View<T>::capacity()
const {
220 return items_.capacity();
225 typename View<T>::const_iterator
227 return items_.begin();
232 typename View<T>::const_iterator
239 typename View<T>::const_reverse_iterator
240 View<T>::rbegin()
const {
241 return items_.rbegin();
246 typename View<T>::const_reverse_iterator
247 View<T>::rend()
const {
248 return items_.rend();
255 return items_.size();
261 View<T>::max_size()
const {
262 return items_.max_size();
269 return items_.empty();
274 typename View<T>::const_reference
276 return *items_.at(pos);
281 typename View<T>::const_reference
298 return Ptr<T>(ref.id(), (ref.isAvailable() ? ref.get(): 0), ref.key());
303 typename View<T>::const_reference
305 return *items_.front();
310 typename View<T>::const_reference
312 return *items_.back();
318 View<T>::pop_back() {
325 View<T>::id()
const {
331 View<T>::productGetter()
const {
332 return refs_.productGetter();
340 output.items_.resize(std::distance(first, last));
342 output.items_[i] = first;
347 View<T>::doClone()
const {
348 return new View(*
this);
354 View<T>::operator=(View<T>
const& rhs) {
365 lhs.size() == rhs.size() &&
366 std::equal(lhs.begin(), lhs.end(), rhs.begin());
373 return !(lhs == rhs);
379 operator<(View<T>
const& lhs,
View<T> const& rhs) {
380 return std::lexicographical_compare(lhs.begin(), lhs.end(),
381 rhs.begin(), rhs.end());
387 operator<=(View<T>
const& lhs,
View<T> const& rhs) {
void swap(ora::Record &rh, ora::Record &lh)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
boost::shared_ptr< reftobase::RefVectorHolderBase > helper_vector_ptr
const_reference front() const
const_reverse_iterator rbegin() const
virtual ViewBase * doClone() const =0
View & operator=(View const &rhs)
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
size_type capacity() const
bool operator==(const CaloTower &t1, const CaloTower &t2)
const_reverse_iterator rend() const
RefToBase< value_type > refAt(size_type i) const
T const & const_reference
ViewBase * doClone() const
seq_t::difference_type difference_type
bool operator>=(View< T > const &, View< T > const &)
Ptr< value_type > ptrAt(size_type i) const
RefToBaseVector< T > refs_
static void fill_from_range(T *first, T *last, View &output)
size_type max_size() const
boost::indirect_iterator< typename seq_t::const_reverse_iterator > const_reverse_iterator
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &)
bool operator>(View< T > const &, View< T > const &)
void const * product() const
T operator[](int i) const
const_reference back() const
ViewBase & operator=(ViewBase const &)
const_reference operator[](size_type pos) const
const_reference at(size_type pos) const
std::vector< T const * > seq_t
const_iterator begin() const
const_iterator end() const
PtrVector< T > const & ptrVector() const
T first(std::pair< T, U > const &p)
EDProductGetter const * productGetter() const
tuple size
Write out results.
RefToBaseVector< T > const & refVector() const