CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes

edm::View< T > Class Template Reference

#include <View.h>

Inheritance diagram for edm::View< T >:
edm::ViewBase

List of all members.

Public Types

typedef
boost::indirect_iterator
< typename
seq_t::const_iterator > 
const_iterator
typedef T const * const_pointer
typedef T const & const_reference
typedef
boost::indirect_iterator
< typename
seq_t::const_reverse_iterator > 
const_reverse_iterator
typedef seq_t::difference_type difference_type
typedef T const * pointer
typedef T const & reference
typedef unsigned int size_type
typedef T value_type

Public Member Functions

const_reference at (size_type pos) const
const_reference back () const
const_iterator begin () const
size_type capacity () const
bool empty () const
const_iterator end () const
const_reference front () const
ProductID id () const
size_type max_size () const
Viewoperator= (View const &rhs)
const_reference operator[] (size_type pos) const
void pop_back ()
void const * product () const
EDProductGetter const * productGetter () const
Ptr< value_typeptrAt (size_type i) const
PtrVector< T > const & ptrVector () const
const_reverse_iterator rbegin () const
RefToBase< value_typerefAt (size_type i) const
RefToBaseVector< T > const & refVector () const
const_reverse_iterator rend () const
size_type size () const
void swap (View &other)
 View (std::vector< void const * > const &pointers, helper_vector_ptr const &helpers)
 View ()
virtual ~View ()

Static Public Member Functions

static void fill_from_range (T *first, T *last, View &output)

Private Types

typedef std::vector< T const * > seq_t

Private Member Functions

ViewBasedoClone () const

Private Attributes

seq_t items_
PtrVector< Tptrs_
RefToBaseVector< Trefs_

Detailed Description

template<typename T>
class edm::View< T >

Class template View<T>

View<T> provides a way to allow reference to the elements (of type T) of some collection in an Event, without knowing about the type of the collection itself. For example, View<int> can refer to the ints in either a vector<int> or a list<int>, without the client code knowing about which type of container manages the ints.

View<T> is not persistable.

View<T> can be used to reference objects of any type that has T as a public base.

Description: Provide access to the collected elements contained by any EDProduct that is a sequence.

Definition at line 70 of file View.h.


Member Typedef Documentation

template<typename T>
typedef boost::indirect_iterator<typename seq_t::const_iterator> edm::View< T >::const_iterator

Definition at line 81 of file View.h.

template<typename T>
typedef T const* edm::View< T >::const_pointer

Definition at line 74 of file View.h.

template<typename T>
typedef T const& edm::View< T >::const_reference

Definition at line 77 of file View.h.

template<typename T>
typedef boost::indirect_iterator<typename seq_t::const_reverse_iterator> edm::View< T >::const_reverse_iterator

Definition at line 88 of file View.h.

template<typename T>
typedef seq_t::difference_type edm::View< T >::difference_type

Definition at line 86 of file View.h.

template<typename T>
typedef T const* edm::View< T >::pointer

Definition at line 73 of file View.h.

template<typename T>
typedef T const& edm::View< T >::reference

Definition at line 76 of file View.h.

template<typename T>
typedef std::vector<T const*> edm::View< T >::seq_t [private]

Definition at line 71 of file View.h.

template<typename T>
typedef unsigned int edm::View< T >::size_type

Definition at line 85 of file View.h.

template<typename T>
typedef T edm::View< T >::value_type

Definition at line 79 of file View.h.


Constructor & Destructor Documentation

template<typename T >
edm::View< T >::View ( ) [inline]

Definition at line 164 of file View.h.

                :
    items_(),
    refs_(),
    ptrs_() {
  }
template<typename T >
edm::View< T >::View ( std::vector< void const * > const &  pointers,
helper_vector_ptr const &  helpers 
)

Definition at line 171 of file View.h.

References compareJSON::const, i, edm::View< T >::items_, AlCaHLTBitMon_ParallelJobs::p, edm::View< T >::ptrs_, edm::View< T >::refs_, and groupFilesInBlocks::temp.

                                                  :
    items_(),
    refs_(),
    ptrs_() {
    size_type numElements = pointers.size();

    // If the two input vectors are not of the same size, there is a
    // logic error in the framework code that called this.
    // constructor.
    if(helpers.get() != 0) {
      assert(numElements == helpers->size());

      items_.reserve(numElements);
       ptrs_.reserve(refs_.size());
      for(std::vector<void const*>::size_type i = 0; i < pointers.size(); ++i) {
        void const* p = pointers[i];
        items_.push_back(static_cast<pointer>(p));
        if(0!=p) {
           ptrs_.push_back(Ptr<T>(helpers->id(), static_cast<T const*>(p), helpers->keyForIndex(i)));
        } else if(helpers->productGetter() != 0) {
           ptrs_.push_back(Ptr<T>(helpers->id(), helpers->keyForIndex(i), helpers->productGetter()));
        } else {
           ptrs_.push_back(Ptr<T>(helpers->id(), 0, helpers->keyForIndex(i)));
        }
      }
      RefToBaseVector<T> temp(helpers);
      refs_.swap(temp);
    }
  }
template<typename T >
edm::View< T >::~View ( ) [virtual]

Definition at line 203 of file View.h.

                 {
  }

Member Function Documentation

template<typename T >
View< T >::const_reference edm::View< T >::at ( size_type  pos) const [inline]

Definition at line 275 of file View.h.

                                 {
    return *items_.at(pos);
  }
template<typename T >
View< T >::const_reference edm::View< T >::back ( ) const [inline]

Definition at line 311 of file View.h.

                      {
    return *items_.back();
  }
template<typename T >
View< T >::const_iterator edm::View< T >::begin ( void  ) const [inline]
template<typename T >
View< T >::size_type edm::View< T >::capacity ( ) const [inline]

Definition at line 219 of file View.h.

                          {
    return items_.capacity();
  }
template<typename T >
ViewBase * edm::View< T >::doClone ( ) const [private, virtual]

Implements edm::ViewBase.

Definition at line 347 of file View.h.

                         {
    return new View(*this);
  }
template<typename T >
bool edm::View< T >::empty ( ) const [inline]

Definition at line 268 of file View.h.

                       {
    return items_.empty();
  }
template<typename T >
View< T >::const_iterator edm::View< T >::end ( void  ) const [inline]
template<typename T >
void edm::View< T >::fill_from_range ( T first,
T last,
View< T > &  output 
) [inline, static]

Definition at line 339 of file View.h.

References edm::first(), i, edm::View< T >::items_, and prof2calltree::last.

                                                          {
    output.items_.resize(std::distance(first, last));
    for(typename View<T>::size_type i = 0; first != last; ++i, ++first)
      output.items_[i] = first;
  }
template<typename T >
View< T >::const_reference edm::View< T >::front ( ) const [inline]

Definition at line 304 of file View.h.

Referenced by MuonMETAlgo::MuonMETAlgo_run().

                       {
    return *items_.front();
  }
template<typename T >
ProductID edm::View< T >::id ( void  ) const [inline]

Definition at line 325 of file View.h.

References edm::ProductID::id().

                    {
    return refs_.id();
  }
template<typename T >
View< T >::size_type edm::View< T >::max_size ( ) const [inline]

Definition at line 261 of file View.h.

                          {
    return items_.max_size();
  }
template<typename T>
View& edm::View< T >::operator= ( View< T > const &  rhs)
template<typename T >
View< T >::const_reference edm::View< T >::operator[] ( size_type  pos) const [inline]

Definition at line 282 of file View.h.

References pos.

                                         {
    return *items_[pos];
  }
template<typename T >
void edm::View< T >::pop_back ( ) [inline]

Definition at line 318 of file View.h.

                    {
    items_.pop_back();
  }
template<typename T>
void const* edm::View< T >::product ( ) const [inline]

Definition at line 139 of file View.h.

References edm::View< T >::refs_.

                                {
      return refs_.product();
    }
template<typename T >
EDProductGetter const * edm::View< T >::productGetter ( ) const [inline]

Definition at line 331 of file View.h.

                               {
    return refs_.productGetter();
  }
template<typename T >
Ptr< T > edm::View< T >::ptrAt ( size_type  i) const [inline]

Definition at line 296 of file View.h.

References edm::RefToBase< T >::get(), edm::RefToBase< T >::id(), edm::RefToBase< T >::isAvailable(), and edm::RefToBase< T >::key().

Referenced by pat::PATJetProducer::produce().

                                  {
    RefToBase<T> ref = refAt(i);
    return Ptr<T>(ref.id(), (ref.isAvailable() ? ref.get(): 0), ref.key());
  }
template<typename T>
PtrVector<T> const& edm::View< T >::ptrVector ( ) const [inline]

Definition at line 125 of file View.h.

References edm::View< T >::ptrs_.

{ return ptrs_; }
template<typename T >
View< T >::const_reverse_iterator edm::View< T >::rbegin ( ) const [inline]

Definition at line 240 of file View.h.

                        {
    return items_.rbegin();
  }
template<typename T >
RefToBase< T > edm::View< T >::refAt ( size_type  i) const [inline]
template<typename T>
RefToBaseVector<T> const& edm::View< T >::refVector ( ) const [inline]

Definition at line 124 of file View.h.

References edm::View< T >::refs_.

{ return refs_; }
template<typename T >
View< T >::const_reverse_iterator edm::View< T >::rend ( ) const [inline]

Definition at line 247 of file View.h.

                      {
    return items_.rend();
  }
template<typename T >
View< T >::size_type edm::View< T >::size ( void  ) const [inline]
template<typename T >
void edm::View< T >::swap ( View< T > &  other) [inline]

Definition at line 209 of file View.h.

References edm::View< T >::items_, edm::View< T >::ptrs_, edm::View< T >::refs_, and edm::ViewBase::swap().

Referenced by edm::swap().

                           {
    this->ViewBase::swap(other);
    items_.swap(other.items_);
    refs_.swap(other.refs_);
    ptrs_.swap(other.ptrs_);
  }

Member Data Documentation

template<typename T>
seq_t edm::View< T >::items_ [private]
template<typename T>
PtrVector<T> edm::View< T >::ptrs_ [private]

Definition at line 146 of file View.h.

Referenced by edm::View< T >::ptrVector(), edm::View< T >::swap(), and edm::View< T >::View().

template<typename T>
RefToBaseVector<T> edm::View< T >::refs_ [private]