IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
FromOtherPlanIndexedInitializer.h
1 // FromOtherPlanIndexedInitializer.h:
3 // ----------------------------------
4 //
15 
16 #ifndef __IPSDKIMAGEPROCESSING_FROMOTHERPLANINDEXEDINITIALIZER_H__
17 #define __IPSDKIMAGEPROCESSING_FROMOTHERPLANINDEXEDINITIALIZER_H__
18 
19 #include <IPSDKImageProcessing/OutputInitializer/PlanIndexed/BaseFromOtherPlanIndexedInitializer.h>
21 #include <boost/make_shared.hpp>
22 #include <boost/function.hpp>
23 
24 namespace ipsdk {
25 namespace imaproc {
26 
29 
30 template <typename OutputAttributeType>
32 {
33 // predefined public types
34 public:
36  typedef typename OutputAttributeType::ValueType ValueType;
37 
39  typedef typename OutputAttributeType::StorageType StorageType;
40 
42  typedef typename OutputAttributeType::PlanValueType PlanValueType;
43 
45  typedef typename OutputAttributeType::PlanStorageType PlanStorageType;
46 
48  typedef boost::function<typename OutputAttributeType::PlanStorageType ()> PlanCreator;
49 
50 public:
56 
57 // methods
58 public:
67  void init(const PlanIndexedAttributeWeakPtr& pOutputAttribute,
68  const PlanIndexedAttributeConstWeakPtr& pInputAttribute);
69  void init(const PlanIndexedAttributeWeakPtr& pOutputAttribute,
70  const PlanIndexedAttributeConstWeakPtr& pInputAttribute,
71  PlanCreator pPlanCreator);
73 
74 protected:
77  BoolResult initAttribute(BasePlanIndexedAttribute& baseAttributeOut,
78  const ipUInt64 sizeZ,
79  const ipUInt64 sizeC,
80  const ipUInt64 sizeT);
81 
82 // attributes
83 protected:
86 };
87 
90 
91 template <typename OutputAttributeType>
92 inline void
94  const PlanIndexedAttributeConstWeakPtr& pInputAttribute)
95 {
96  // update of plan creator function
97  _pPlanCreator = static_cast<const PlanCreator&>(&boost::make_shared<PlanValueType>);
98 
99  // call of base class initialization method
100  this->initBase(pOutputAttribute, pInputAttribute);
101 }
102 
103 template <typename OutputAttributeType>
104 inline void
106  const PlanIndexedAttributeConstWeakPtr& pInputAttribute,
107  PlanCreator pPlanCreator)
108 {
109  // update of plan creator function
110  _pPlanCreator = pPlanCreator;
111 
112  // call of base class initialization method
113  this->initBase(pOutputAttribute, pInputAttribute);
114 }
115 
116 template <typename OutputAttributeType>
117 inline BoolResult
119  const ipUInt64 sizeZ,
120  const ipUInt64 sizeC,
121  const ipUInt64 sizeT)
122 {
123  // retrieve concrete attribute
124  OutputAttributeType& attributeOut = static_cast<OutputAttributeType&>(baseAttributeOut);
125 
126  // check for attribute initialization
127  if (attributeOut.isInit() == false)
128  attributeOut.init(boost::make_shared<ValueType>());
129 
130  // retrieve associated collection
131  ValueType& coll = *attributeOut.getStorage();
132 
133  // initalization of plan indexed collection
134  initPlanIndexed(sizeZ, sizeC, sizeT, coll, _pPlanCreator);
135 
136  return true;
137 }
138 
141 
142 } // end of namespace imaproc
143 } // end of namespace ipsdk
144 
145 #endif // __IPSDKIMAGEPROCESSING_FROMOTHERPLANINDEXEDINITIALIZER_H__
boost::weak_ptr< const BasePlanIndexedAttribute > PlanIndexedAttributeConstWeakPtr
weak pointer to const plan indexed attribute
Definition: PlanIndexedAttributeTypes.h:39
Class allowing to encapsulate a typed process result associated to a string description.
Definition: ProcessingResult.h:28
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
void init(const PlanIndexedAttributeWeakPtr &pOutputAttribute, const PlanIndexedAttributeConstWeakPtr &pInputAttribute)
initialize object
Definition: FromOtherPlanIndexedInitializer.h:93
OutputAttributeType::ValueType ValueType
value type associated to attribute
Definition: FromOtherPlanIndexedInitializer.h:36
uint64_t ipUInt64
Base types definition.
Definition: BaseTypes.h:55
void initPlanIndexed(const ipUInt64 sizeZ, const ipUInt64 sizeC, const ipUInt64 sizeT, T &coll, boost::function< typename T::StorageType()> planCreator)
function allowing to initialize a plan indexed collection with respect to given components sizes ...
Definition: PlanIndexedInitializerUtils.h:34
boost::function< typename OutputAttributeType::PlanStorageType()> PlanCreator
plan creator function
Definition: FromOtherPlanIndexedInitializer.h:48
OutputAttributeType::StorageType StorageType
storage type associated to attribute
Definition: FromOtherPlanIndexedInitializer.h:39
Base class for plan indexed attributes.
Definition: BasePlanIndexedAttribute.h:33
OutputAttributeType::PlanStorageType PlanStorageType
plan storage type associated to attribute
Definition: FromOtherPlanIndexedInitializer.h:45
OutputAttributeType::PlanValueType PlanValueType
plan value type associated to attribute
Definition: FromOtherPlanIndexedInitializer.h:42
PlanCreator _pPlanCreator
function used to create new plan shared pointers
Definition: FromOtherPlanIndexedInitializer.h:85
boost::weak_ptr< BasePlanIndexedAttribute > PlanIndexedAttributeWeakPtr
weak pointer to plan indexed attribute
Definition: PlanIndexedAttributeTypes.h:36
Class allowing initialization of a plan indexed collection from an other plan indexed collection...
Definition: FromOtherPlanIndexedInitializer.h:31
Utility functions for plan indexed collection initializer.
Base class for initialization of a plan indexed collection from an other plan indexed collection...
Definition: BaseFromOtherPlanIndexedInitializer.h:32