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 //
12 
13 // user include files
19 
20 // system include files
21 #include <ostream>
22 
23 //
24 // constants, enums and typedefs
25 //
26 namespace edm {
27 //
28 // static data member definitions
29 //
30 
31 //
32 // constructor and destructor
33 //
35  }
36 
38  }
39 
40 //
41 // assignment operators
42 //
43 
44 //
45 // member functions
46 //
47 
49  void
51  core_.swap(other.core_);
52  indicies_.swap(other.indicies_);
53  cachedItems_.swap(other.cachedItems_);
54  }
55 
56  void
57  PtrVectorBase::push_back_base(RefCore const& core, key_type iKey, void const* iData) {
58  core_.pushBackItem(core, false);
59  //Did we already push a 'non-cached' Ptr into the container or is this a 'non-cached' Ptr?
60  if(indicies_.size() == cachedItems_.size()) {
61  if(iData) {
62  cachedItems_.push_back(iData);
63  } else if(key_traits<key_type>::value == iKey) {
64  cachedItems_.push_back(0);
65  } else {
66  cachedItems_.clear();
67  }
68  }
69  indicies_.push_back(iKey);
70  }
71 
72 //
73 // const member functions
74 //
75  void
77  if(hasCache()) {
78  return;
79  }
80  if(indicies_.size() == 0) {
81  return;
82  }
83  if(0 == productGetter()) {
84  throw Exception(errors::LogicError) << "Tried to get data for a PtrVector which has no EDProductGetter\n";
85  }
87 
88  if(!product.isValid()) {
89  throw Exception(errors::InvalidReference) << "Asked for data from a PtrVector which refers to a non-existent product which id " << id() << "\n";
90  }
92  }
93 
94  bool
96  if(core_ != iRHS.core_) {
97  return false;
98  }
99  if(indicies_.size() != iRHS.indicies_.size()){
100  return false;
101  }
102  return std::equal(indicies_.begin(),
103  indicies_.end(),
104  iRHS.indicies_.begin());
105  return true;
106  }
107 
108 //
109 // static member functions
110 //
111 }
void pushBackItem(RefCore const &productToBeInserted, bool checkPointer)
Definition: RefCore.cc:133
void swap(RefCore &)
Definition: RefCore.h:116
bool operator==(PtrVectorBase const &iRHS) const
virtual std::type_info const & typeInfo() const
bool equal(const T &first, const T &second)
Definition: Equal.h:34
void getProduct_() const
ProductID id() const
Accessor for product ID.
Definition: PtrVectorBase.h:56
std::vector< key_type > indicies_
virtual WrapperHolder getIt(ProductID const &) const =0
void fillPtrVector(std::type_info const &iToType, std::vector< unsigned long > const &iIndicies, std::vector< void const * > &oPtr) const
Definition: WrapperHolder.h:43
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()
bool isValid() const
Definition: WrapperHolder.h:27
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