CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PtrVectorBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Common
4 // Class : PtrVectorBase
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Wed Oct 24 15:49:27 EDT 2007
11 // $Id: PtrVectorBase.cc,v 1.4.4.1 2008/11/14 18:58:50 wmtan Exp $
12 //
13 
14 // system include files
15 
16 // user include files
22 #include <ostream>
23 
24 //
25 // constants, enums and typedefs
26 //
27 namespace edm {
28 //
29 // static data member definitions
30 //
31 
32 //
33 // constructor and destructor
34 //
36  {
37  }
38 
40  {
41  }
42 
43 //
44 // assignment operators
45 //
46 
47 //
48 // member functions
49 //
50 
52  void
54  core_.swap(other.core_);
55  indicies_.swap(other.indicies_);
56  cachedItems_.swap(other.cachedItems_);
57  }
58 
59  void
60  PtrVectorBase::push_back_base(RefCore const& core, key_type iKey, void const* iData) {
61  core_.pushBackItem(core, false);
62  //Did we already push a 'non-cached' Ptr into the container or is this a 'non-cached' Ptr?
63  if(indicies_.size() == cachedItems_.size()) {
64  if(iData) {
65  cachedItems_.push_back(iData);
66  } else if(key_traits<key_type>::value == iKey) {
67  cachedItems_.push_back(0);
68  } else {
69  cachedItems_.clear();
70  }
71  }
72  indicies_.push_back(iKey);
73  }
74 
75 //
76 // const member functions
77 //
78  void
80  if(hasCache()) {
81  return;
82  }
83  if(indicies_.size() == 0) {
84  return;
85  }
86  if(0 == productGetter()) {
87  throw edm::Exception(edm::errors::LogicError) << "Tried to get data for a PtrVector which has no EDProductGetter\n";
88  }
89  EDProduct const* product = productGetter()->getIt(id());
90 
91  if(0==product) {
92  throw edm::Exception(edm::errors::InvalidReference) << "Asked for data from a PtrVector which refers to a non-existent product which id " << id() << "\n";
93  }
94  product->fillPtrVector(typeInfo(),
95  indicies_,
96  cachedItems_);
97  }
98 
99  bool
101  if (core_ != iRHS.core_) {
102  return false;
103  }
104  if (indicies_.size() != iRHS.indicies_.size()){
105  return false;
106  }
107  return std::equal(indicies_.begin(),
108  indicies_.end(),
109  iRHS.indicies_.begin());
110  return true;
111  }
112 
113 //
114 // static member functions
115 //
116 }
void pushBackItem(RefCore const &productToBeInserted, bool checkPointer)
Definition: RefCore.cc:115
void swap(RefCore &)
Definition: RefCore.h:117
bool operator==(PtrVectorBase const &iRHS) const
void fillPtrVector(std::type_info const &iToType, std::vector< unsigned long > const &iIndicies, std::vector< void const * > &oPtr) const
Definition: EDProduct.cc:33
virtual EDProduct const * getIt(ProductID const &) const =0
virtual std::type_info const & typeInfo() const
void getProduct_() const
ProductID id() const
Accessor for product ID.
Definition: PtrVectorBase.h:56
std::vector< key_type > indicies_
std::vector< void const * > cachedItems_
void push_back_base(RefCore const &core, key_type iKey, void const *iData)
bool hasCache() const
Definition: PtrVectorBase.h:61
unsigned long key_type
Definition: PtrVectorBase.h:35
virtual ~PtrVectorBase()
void swap(PtrVectorBase &other)
swap
EDProductGetter const * productGetter() const
Accessor for product getter.
Definition: PtrVectorBase.h:59
void const * product() const
Definition: PtrVectorBase.h:92