IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
FromImagePlanIndexedInitializer.h
1 // FromImagePlanIndexedInitializer.h:
3 // ----------------------------------
4 //
17 
18 #ifndef __IPSDKIMAGEPROCESSING_FROMIMAGEPLANINDEXEDINITIALIZER_H__
19 #define __IPSDKIMAGEPROCESSING_FROMIMAGEPLANINDEXEDINITIALIZER_H__
20 
21 #include <IPSDKImageProcessing/OutputInitializer/PlanIndexed/BaseFromImagePlanIndexedInitializer.h>
23 #include <boost/make_shared.hpp>
24 #include <boost/function.hpp>
25 
26 namespace ipsdk {
27 namespace imaproc {
28 
31 
32 template <typename OutputAttributeType>
34 {
35 // predefined public types
36 public:
38  typedef typename OutputAttributeType::ValueType ValueType;
39 
41  typedef typename OutputAttributeType::StorageType StorageType;
42 
44  typedef typename OutputAttributeType::PlanValueType PlanValueType;
45 
47  typedef typename OutputAttributeType::PlanStorageType PlanStorageType;
48 
50  typedef boost::function<typename OutputAttributeType::PlanStorageType ()> PlanCreator;
51 
52 public:
58 
59 // methods
60 public:
69  void init(const PlanIndexedAttributeWeakPtr& pOutputAttribute,
70  const ImageAttributeConstWeakPtr& pInputImageAttribute,
71  const eFromImagePlanIndexedPolicy& fromImagePlanIndexedPolicy);
72  void init(const PlanIndexedAttributeWeakPtr& pOutputAttribute,
73  const ImageAttributeConstWeakPtr& pInputImageAttribute,
74  const eFromImagePlanIndexedPolicy& fromImagePlanIndexedPolicy,
75  PlanCreator pPlanCreator);
77 
78 protected:
81  BoolResult initAttribute(BasePlanIndexedAttribute& baseAttributeOut,
82  const ipUInt64 sizeZ,
83  const ipUInt64 sizeC,
84  const ipUInt64 sizeT);
85 
86 // attributes
87 protected:
90 };
91 
94 
95 template <typename OutputAttributeType>
96 inline void
98  const ImageAttributeConstWeakPtr& pInputImageAttribute,
99  const eFromImagePlanIndexedPolicy& fromImagePlanIndexedPolicy)
100 {
101  // update of plan creator function
102  _pPlanCreator = static_cast<const PlanCreator&>(&boost::make_shared<PlanValueType>);
103 
104  // call of base class initialization method
105  this->initBase(pOutputAttribute, pInputImageAttribute, fromImagePlanIndexedPolicy);
106 }
107 
108 template <typename OutputAttributeType>
109 inline void
111  const ImageAttributeConstWeakPtr& pInputImageAttribute,
112  const eFromImagePlanIndexedPolicy& fromImagePlanIndexedPolicy,
113  PlanCreator pPlanCreator)
114 {
115  // update of plan creator function
116  _pPlanCreator = pPlanCreator;
117 
118  // call of base class initialization method
119  this->initBase(pOutputAttribute, pInputImageAttribute, fromImagePlanIndexedPolicy);
120 }
121 
122 template <typename OutputAttributeType>
123 inline BoolResult
125  const ipUInt64 sizeZ,
126  const ipUInt64 sizeC,
127  const ipUInt64 sizeT)
128 {
129  // retrieve concrete attribute
130  OutputAttributeType& attributeOut = static_cast<OutputAttributeType&>(baseAttributeOut);
131 
132  // check for attribute initialization
133  if (attributeOut.isInit() == false)
134  attributeOut.init(boost::make_shared<ValueType>());
135 
136  // retrieve associated collection
137  ValueType& coll = *attributeOut.getStorage();
138 
139  // initalization of plan indexed collection
140  initPlanIndexed(sizeZ, sizeC, sizeT, coll, _pPlanCreator);
141 
142  return true;
143 }
144 
147 
148 } // end of namespace imaproc
149 } // end of namespace ipsdk
150 
151 #endif // __IPSDKIMAGEPROCESSING_FROMIMAGEPLANINDEXEDINITIALIZER_H__
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
boost::function< typename OutputAttributeType::PlanStorageType()> PlanCreator
plan creator function
Definition: FromImagePlanIndexedInitializer.h:50
boost::weak_ptr< const BaseImageAttribute > ImageAttributeConstWeakPtr
Definition: ImageAttributeTypes.h:38
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
void init(const PlanIndexedAttributeWeakPtr &pOutputAttribute, const ImageAttributeConstWeakPtr &pInputImageAttribute, const eFromImagePlanIndexedPolicy &fromImagePlanIndexedPolicy)
initialize object
Definition: FromImagePlanIndexedInitializer.h:97
OutputAttributeType::PlanStorageType PlanStorageType
plan storage type associated to attribute
Definition: FromImagePlanIndexedInitializer.h:47
PlanCreator _pPlanCreator
function used to create new plan shared pointers
Definition: FromImagePlanIndexedInitializer.h:89
OutputAttributeType::ValueType ValueType
value type associated to attribute
Definition: FromImagePlanIndexedInitializer.h:38
Base class for plan indexed attributes.
Definition: BasePlanIndexedAttribute.h:33
eFromImagePlanIndexedPolicy
enumerate describing rule behavior for image plans matching
Definition: PlanIndexedInitializerTypes.h:47
boost::weak_ptr< BasePlanIndexedAttribute > PlanIndexedAttributeWeakPtr
weak pointer to plan indexed attribute
Definition: PlanIndexedAttributeTypes.h:36
Utility functions for plan indexed collection initializer.
OutputAttributeType::PlanValueType PlanValueType
plan value type associated to attribute
Definition: FromImagePlanIndexedInitializer.h:44
OutputAttributeType::StorageType StorageType
storage type associated to attribute
Definition: FromImagePlanIndexedInitializer.h:41
Class allowing to initialize a plan indexed collection from plans of an image.
Definition: FromImagePlanIndexedInitializer.h:33
Base class for initialization of a plan indexed collection from plans of an image.
Definition: BaseFromImagePlanIndexedInitializer.h:33