CMS 3D CMS Logo

IndirectVectorHolder.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_IndirectVectorHolder_h
2 #define DataFormats_Common_IndirectVectorHolder_h
7 #include <memory>
8 
9 namespace edm {
10  namespace reftobase {
11 
12  template <typename T>
13  class IndirectVectorHolder : public BaseVectorHolder<T> {
14  public:
16  typedef typename base_type::size_type size_type;
20 
23  IndirectVectorHolder(std::shared_ptr<RefVectorHolderBase> p);
25  ~IndirectVectorHolder() override;
28  BaseVectorHolder<T>* clone() const override;
29  BaseVectorHolder<T>* cloneEmpty() const override;
30  ProductID id() const override;
31  EDProductGetter const* productGetter() const override;
32  bool empty() const override;
33  size_type size() const override;
34  void clear() override;
35  base_ref_type const at(size_type idx) const override;
36  std::unique_ptr<reftobase::RefVectorHolderBase> vectorHolder() const override {
37  return std::unique_ptr<reftobase::RefVectorHolderBase>(helper_->clone());
38  }
39  void push_back(const BaseHolder<T>* r) override {
40  typedef IndirectHolder<T> holder_type;
41  const holder_type* h = dynamic_cast<const holder_type*>(r);
42  if (h == nullptr)
44  "In IndirectHolder<T> trying to push_back wrong reference type");
45  helper_->push_back(h->helper_);
46  }
47 
50  bool isAvailable() const override { return helper_->isAvailable(); }
51 
52  //Used by ROOT storage
54 
55  private:
58 
59  public:
61  typedef ptrdiff_t difference_type;
66  void increase() override { ++i; }
67  void decrease() override { --i; }
68  void increase(difference_type d) override { i += d; }
69  void decrease(difference_type d) override { i -= d; }
70  bool equal_to(const const_iterator_imp* o) const override { return i == dc(o); }
71  bool less_than(const const_iterator_imp* o) const override { return i < dc(o); }
72  void assign(const const_iterator_imp* o) override { i = dc(o); }
73  base_ref_type deref() const override { return base_ref_type(*i); }
74  difference_type difference(const const_iterator_imp* o) const override { return i - dc(o); }
75 
76  private:
78  if (o == nullptr) {
80  "In IndirectVectorHolder trying to dereference a null pointer");
81  }
82  const const_iterator_imp_specific* oo = dynamic_cast<const const_iterator_imp_specific*>(o);
83  if (oo == nullptr) {
85  "In IndirectVectorHolder trying to cast iterator to wrong type ");
86  }
87  return oo->i;
88  }
90  };
91 
92  const_iterator begin() const override {
94  }
96  };
97 
98  template <typename T>
100 
101  template <typename T>
102  IndirectVectorHolder<T>::IndirectVectorHolder(std::shared_ptr<RefVectorHolderBase> p)
103  : BaseVectorHolder<T>(), helper_(p->clone()) {}
104 
105  template <typename T>
107 
108  template <typename T>
110  : BaseVectorHolder<T>(), helper_(other.helper_->clone()) {}
111 
112  template <typename T>
114  delete helper_;
115  }
116 
117  template <typename T>
119  this->BaseVectorHolder<T>::swap(other);
120  std::swap(helper_, other.helper_);
121  }
122 
123  template <typename T>
126  swap(temp);
127  return *this;
128  }
129 
130  template <typename T>
132  return new IndirectVectorHolder<T>(*this);
133  }
134 
135  template <typename T>
137  return new IndirectVectorHolder<T>(helper_->cloneEmpty());
138  }
139 
140  template <typename T>
142  return helper_->id();
143  }
144 
145  template <typename T>
147  return helper_->productGetter();
148  }
149 
150  template <typename T>
152  return helper_->empty();
153  }
154 
155  template <typename T>
157  return helper_->size();
158  }
159 
160  template <typename T>
162  return helper_->clear();
163  }
164 
165  template <typename T>
167  return helper_ ? helper_->template getRef<T>(idx) : typename IndirectVectorHolder<T>::base_ref_type();
168  }
169 
170  // Free swap function
171  template <typename T>
173  lhs.swap(rhs);
174  }
175  } // namespace reftobase
176 } // namespace edm
177 
178 #endif
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::clone
const_iterator_imp_specific * clone() const override
Definition: IndirectVectorHolder.h:65
mps_fire.i
i
Definition: mps_fire.py:428
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::difference_type
ptrdiff_t difference_type
Definition: IndirectVectorHolder.h:61
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::const_iterator_imp_specific
const_iterator_imp_specific()
Definition: IndirectVectorHolder.h:62
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::i
RefVectorHolderBase::const_iterator i
Definition: IndirectVectorHolder.h:89
RefVectorHolderBase.h
edm::errors::InvalidReference
Definition: EDMException.h:39
edm::reftobase::IndirectVectorHolder::~IndirectVectorHolder
~IndirectVectorHolder() override
Definition: IndirectVectorHolder.h:113
edm::reftobase::IndirectVectorHolder::swap
void swap(IndirectVectorHolder &other)
Definition: IndirectVectorHolder.h:118
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::reftobase::BaseVectorHolder
Definition: BaseHolder.h:16
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::less_than
bool less_than(const const_iterator_imp *o) const override
Definition: IndirectVectorHolder.h:71
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::reftobase::RefVectorHolderBase::end
virtual const_iterator end() const =0
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::deref
base_ref_type deref() const override
Definition: IndirectVectorHolder.h:73
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::equal_to
bool equal_to(const const_iterator_imp *o) const override
Definition: IndirectVectorHolder.h:70
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::decrease
void decrease() override
Definition: IndirectVectorHolder.h:67
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::~const_iterator_imp_specific
~const_iterator_imp_specific() override
Definition: IndirectVectorHolder.h:64
edm::reftobase::IndirectVectorHolder::clone
BaseVectorHolder< T > * clone() const override
Definition: IndirectVectorHolder.h:131
edm::reftobase::RefVectorHolderBase
Definition: RefVectorHolderBase.h:13
edm::reftobase::IndirectVectorHolder::id
ProductID id() const override
Definition: IndirectVectorHolder.h:141
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
edm::reftobase::BaseVectorHolder::size_type
size_t size_type
Definition: BaseVectorHolder.h:17
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
edm::reftobase::BaseVectorHolder::swap
void swap(BaseVectorHolder &)
Definition: BaseVectorHolder.h:33
edm::EDProductGetter
Definition: EDProductGetter.h:41
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::const_iterator_imp_specific
const_iterator_imp_specific(const typename RefVectorHolderBase::const_iterator &it)
Definition: IndirectVectorHolder.h:63
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
edm::reftobase::IndirectVectorHolder::empty
bool empty() const override
Definition: IndirectVectorHolder.h:151
edm::reftobase::IndirectVectorHolder::cloneEmpty
BaseVectorHolder< T > * cloneEmpty() const override
Definition: IndirectVectorHolder.h:136
edm::reftobase::BaseHolder
Definition: BaseHolder.h:29
edm::reftobase::BaseVectorHolder::const_iterator
Definition: BaseVectorHolder.h:54
trackingPlots.other
other
Definition: trackingPlots.py:1467
CMS_CLASS_VERSION
#define CMS_CLASS_VERSION(_version_)
Definition: CMS_CLASS_VERSION.h:30
h
edm::reftobase::RefVectorHolderBase::clone
virtual RefVectorHolderBase * clone() const =0
edm::reftobase::RefVectorHolderBase::const_iterator
Definition: RefVectorHolderBase.h:47
edm::reftobase::IndirectVectorHolder
Definition: IndirectHolder.h:17
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::difference
difference_type difference(const const_iterator_imp *o) const override
Definition: IndirectVectorHolder.h:74
edm::reftobase::IndirectVectorHolder::base_type
BaseVectorHolder< T > base_type
Definition: IndirectVectorHolder.h:15
edm::reftobase::IndirectVectorHolder::isAvailable
bool isAvailable() const override
Definition: IndirectVectorHolder.h:50
edm::reftobase::IndirectVectorHolder::end
const_iterator end() const override
Definition: IndirectVectorHolder.h:95
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific
Definition: IndirectVectorHolder.h:60
edm::reftobase::IndirectVectorHolder::size
size_type size() const override
Definition: IndirectVectorHolder.h:156
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::increase
void increase(difference_type d) override
Definition: IndirectVectorHolder.h:68
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::decrease
void decrease(difference_type d) override
Definition: IndirectVectorHolder.h:69
edm::reftobase::IndirectVectorHolder::vectorHolder
std::unique_ptr< reftobase::RefVectorHolderBase > vectorHolder() const override
Definition: IndirectVectorHolder.h:36
edm::reftobase::BaseVectorHolder::element_type
T element_type
Definition: BaseVectorHolder.h:18
edm::reftobase::IndirectVectorHolder::element_type
base_type::element_type element_type
Definition: IndirectVectorHolder.h:17
edm::reftobase::BaseVectorHolder::const_iterator_imp::difference_type
ptrdiff_t difference_type
Definition: BaseVectorHolder.h:39
edm::reftobase::IndirectVectorHolder::productGetter
EDProductGetter const * productGetter() const override
Definition: IndirectVectorHolder.h:146
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::reftobase::IndirectVectorHolder::const_iterator
base_type::const_iterator const_iterator
Definition: IndirectVectorHolder.h:19
edm::reftobase::IndirectHolder
Definition: EDProductfwd.h:48
edm::reftobase::swap
void swap(BaseHolder< T > &lhs, BaseHolder< T > &rhs)
Definition: BaseHolder.h:111
edm::reftobase::RefVectorHolderBase::push_back
virtual void push_back(RefHolderBase const *r)=0
edm::reftobase::IndirectVectorHolder::push_back
void push_back(const BaseHolder< T > *r) override
Definition: IndirectVectorHolder.h:39
edm::reftobase::IndirectVectorHolder::helper_
RefVectorHolderBase * helper_
Definition: IndirectVectorHolder.h:57
edm::reftobase::RefVectorHolderBase::isAvailable
virtual bool isAvailable() const =0
CMS_CLASS_VERSION.h
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::increase
void increase() override
Definition: IndirectVectorHolder.h:66
BaseVectorHolder.h
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::dc
const RefVectorHolderBase::const_iterator & dc(const const_iterator_imp *o) const
Definition: IndirectVectorHolder.h:77
edm::reftobase::IndirectVectorHolder::IndirectVectorHolder
IndirectVectorHolder()
Definition: IndirectVectorHolder.h:99
edm::reftobase::RefVectorHolderBase::begin
virtual const_iterator begin() const =0
T
long double T
Definition: Basic3DVectorLD.h:48
edm::reftobase::IndirectVectorHolder::begin
const_iterator begin() const override
Definition: IndirectVectorHolder.h:92
edm::Exception::throwThis
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
Definition: EDMException.cc:83
edm::reftobase::IndirectVectorHolder::at
const base_ref_type at(size_type idx) const override
Definition: IndirectVectorHolder.h:166
edm::reftobase::IndirectVectorHolder::const_iterator_imp_specific::assign
void assign(const const_iterator_imp *o) override
Definition: IndirectVectorHolder.h:72
edm::RefToBase
Definition: AssociativeIterator.h:54
edm::reftobase::IndirectVectorHolder::operator=
IndirectVectorHolder & operator=(IndirectVectorHolder const &rhs)
Definition: IndirectVectorHolder.h:124
ztail.d
d
Definition: ztail.py:151
edm::reftobase::IndirectVectorHolder::size_type
base_type::size_type size_type
Definition: IndirectVectorHolder.h:16
edm::reftobase::BaseVectorHolder::const_iterator_imp
Definition: BaseVectorHolder.h:38
IndirectHolder.h
edm::ProductID
Definition: ProductID.h:27
edm::reftobase::IndirectVectorHolder::clear
void clear() override
Definition: IndirectVectorHolder.h:161
edm::reftobase::IndirectVectorHolder::base_ref_type
base_type::base_ref_type base_ref_type
Definition: IndirectVectorHolder.h:18
edm::ProductID::id
ProductIndex id() const
Definition: ProductID.h:35