IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
PlanIndexedColl.h
1 // PlanIndexedColl.h:
3 // ------------------
4 //
14 
15 #ifndef __IPSDKBASEDATA_PLANINDEXEDCOLL_H__
16 #define __IPSDKBASEDATA_PLANINDEXEDCOLL_H__
17 
18 #include <IPSDKBaseData/PlanIndex/BasePlanIndexedColl.h>
19 #include <IPSDKSerialization/Engine/BaseObjectWithSkeleton.h>
20 #include <boost/type_traits/is_base_of.hpp>
21 
22 namespace ipsdk {
23 
26 
27 template <typename T>
29 {
30 // predefined public types
31 public:
32  // value type associated to objects into collection
33  typedef T ValueType;
34 
35  // storage type associated to objects into collection
36  typedef boost::shared_ptr<T> StorageType;
37 
38  // const storage type associated to objects into collection
39  typedef boost::shared_ptr<const T> ConstStorageType;
40 
41 public:
44  PlanIndexedColl() {}
45  ~PlanIndexedColl() {}
47 
48 // methods
49 public:
51  const std::string& getElementsClassName() const;
52 
55  bool haveSkeleton() const;
56 
57  // \brief insert a new element for a given plan index
62  void insert(const ipsdk::PlanIndex& planIndex,
63  const StorageType& pObject);
64 
65  // \brief insert a new element for a given plan index
70  void insert(const ipsdk::ipUInt64 zPlanIdx,
71  const ipsdk::ipUInt64 cPlanIdx,
72  const ipsdk::ipUInt64 tPlanIdx,
73  const StorageType& pObject);
74 
77  void assign(const T& object,
78  const ipUInt64 sizeZ,
79  const ipUInt64 sizeC,
80  const ipUInt64 sizeT);
81 
85  ConstStorageType getStorage(const ipsdk::PlanIndex& planIndex) const;
86 
90  ConstStorageType getStorage(const ipsdk::ipUInt64 zPlanIdx,
91  const ipsdk::ipUInt64 cPlanIdx,
92  const ipsdk::ipUInt64 tPlanIdx) const;
93 
97  StorageType getStorage(const ipsdk::PlanIndex& planIndex);
98 
102  StorageType getStorage(const ipsdk::ipUInt64 zPlanIdx,
103  const ipsdk::ipUInt64 cPlanIdx,
104  const ipsdk::ipUInt64 tPlanIdx);
105 
109  const ValueType& getValue(const ipsdk::PlanIndex& planIndex) const;
110 
114  const ValueType& getValue(const ipsdk::ipUInt64 zPlanIdx,
115  const ipsdk::ipUInt64 cPlanIdx,
116  const ipsdk::ipUInt64 tPlanIdx) const;
117 
121  const ValueType& getValue(const ipsdk::ipUInt64 planOffset) const;
122 
126  ValueType& getValue(const ipsdk::PlanIndex& planIndex);
127 
131  ValueType& getValue(const ipsdk::ipUInt64 zPlanIdx,
132  const ipsdk::ipUInt64 cPlanIdx,
133  const ipsdk::ipUInt64 tPlanIdx);
134 
138  ValueType& getValue(const ipsdk::ipUInt64 planOffset);
139 
140 // attributes
141 protected:
142 
143 };
144 
147 
148 template <typename T>
149 inline const std::string&
151 {
152  return ValueType::getTypeName();
153 }
154 
155 template <typename T>
156 inline bool
158 {
159  return boost::is_base_of<ipsdk::BaseObjectWithSkeleton, ValueType>::value;
160 }
161 
162 template <typename T>
163 inline void
165  const StorageType& pObject)
166 {
167  BasePlanIndexedColl::insert(planIndex, pObject);
168 }
169 
170 template <typename T>
171 inline void
173  const ipsdk::ipUInt64 cPlanIdx,
174  const ipsdk::ipUInt64 tPlanIdx,
175  const StorageType& pObject)
176 {
177  insert(PlanIndex(zPlanIdx, cPlanIdx, tPlanIdx), pObject);
178 }
179 
180 template <typename T>
181 inline void
183  const ipUInt64 sizeZ,
184  const ipUInt64 sizeC,
185  const ipUInt64 sizeT)
186 {
187  BasePlanIndexedColl::assign(object, sizeZ, sizeC, sizeT);
188 }
189 
190 template <typename T>
191 inline typename PlanIndexedColl<T>::ConstStorageType
193 {
194  return boost::static_pointer_cast<const ValueType>(BasePlanIndexedColl::getStorage(planIndex));
195 }
196 
197 template <typename T>
198 inline typename PlanIndexedColl<T>::ConstStorageType
200  const ipsdk::ipUInt64 cPlanIdx,
201  const ipsdk::ipUInt64 tPlanIdx) const
202 {
203  return getStorage(PlanIndex(zPlanIdx, cPlanIdx, tPlanIdx));
204 }
205 
206 template <typename T>
207 inline typename PlanIndexedColl<T>::StorageType
209 {
210  return boost::static_pointer_cast<ValueType>(BasePlanIndexedColl::getStorage(planIndex));
211 }
212 
213 template <typename T>
214 inline typename PlanIndexedColl<T>::StorageType
216  const ipsdk::ipUInt64 cPlanIdx,
217  const ipsdk::ipUInt64 tPlanIdx)
218 {
219  return getStorage(PlanIndex(zPlanIdx, cPlanIdx, tPlanIdx));
220 }
221 
222 template <typename T>
223 inline const typename PlanIndexedColl<T>::ValueType&
225 {
226  return static_cast<const ValueType&>(*getStorage(planIndex));
227 }
228 
229 template <typename T>
230 inline const typename PlanIndexedColl<T>::ValueType&
232  const ipsdk::ipUInt64 cPlanIdx,
233  const ipsdk::ipUInt64 tPlanIdx) const
234 {
235  return getValue(PlanIndex(zPlanIdx, cPlanIdx, tPlanIdx));
236 }
237 
238 template <typename T>
239 inline const typename PlanIndexedColl<T>::ValueType&
241 {
242  return getValue(BasePlanIndexedColl::getPlanIndex(planOffset));
243 }
244 
245 template <typename T>
246 inline typename PlanIndexedColl<T>::ValueType&
248 {
249  return static_cast<ValueType&>(*getStorage(planIndex));
250 }
251 
252 template <typename T>
253 inline typename PlanIndexedColl<T>::ValueType&
255  const ipsdk::ipUInt64 cPlanIdx,
256  const ipsdk::ipUInt64 tPlanIdx)
257 {
258  return getValue(PlanIndex(zPlanIdx, cPlanIdx, tPlanIdx));
259 }
260 
261 template <typename T>
262 inline typename PlanIndexedColl<T>::ValueType&
264 {
265  return getValue(BasePlanIndexedColl::getPlanIndex(planOffset));
266 }
267 
270 
271 } // end of namespace ipsdk
272 
273 #endif // __IPSDKBASEDATA_PLANINDEXEDCOLL_H__
std::map< PlanIndex, SerializationObjectPtr > PlanIndexedColl
collection of plan indexed serializable object shared pointers
Definition: BasePlanIndexedColl.h:42
SerializationObjectConstPtr getStorage(const PlanIndex &planIndex) const
retrieve an element associated to a given plan index
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
uint64_t ipUInt64
Base types definition.
Definition: BaseTypes.h:55
const ValueType & getValue(const ipsdk::PlanIndex &planIndex) const
retrieve an element associated to a given plan index
Definition: PlanIndexedColl.h:224
bool haveSkeleton() const
Definition: PlanIndexedColl.h:157
ConstStorageType getStorage(const ipsdk::PlanIndex &planIndex) const
retrieve an element associated to a given plan index
Definition: PlanIndexedColl.h:192
void assign(const T &object, const ipUInt64 sizeZ, const ipUInt64 sizeC, const ipUInt64 sizeT)
assign a given value to all data of collection
Definition: PlanIndexedColl.h:182
Class used to store image plan index.
Definition: PlanIndex.h:26
void insert(const ipsdk::PlanIndex &planIndex, const StorageType &pObject)
Definition: PlanIndexedColl.h:164
const PlanIndex & getPlanIndex(const ipUInt64 planOffset) const
retrieve plan index associated to a given plan offset
const std::string & getElementsClassName() const
retrieve class name associated to concrete elements into collection
Definition: PlanIndexedColl.h:150
Collection of serializable objects indexed by plan.
Definition: BasePlanIndexedColl.h:34
void insert(const PlanIndex &planIndex, const SerializationObjectPtr &pObject)
insert a new element for a given plan index
void assign(const BaseSerializationObject &object, const ipUInt64 sizeZ, const ipUInt64 sizeC, const ipUInt64 sizeT)
assign a given value to all data of collection