IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
PlanIndexedSplit.h
1 // PlanIndexedSplit.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKIMAGEPROCESSING_PLANINDEXEDSPLIT_H__
16 #define __IPSDKIMAGEPROCESSING_PLANINDEXEDSPLIT_H__
17 
18 #include <IPSDKImageProcessing/DataSplit/PlanIndexed/BasePlanIndexedSplit.h>
19  #include <boost/type_traits/remove_const.hpp>
20 
21 namespace ipsdk {
22 namespace imaproc {
23 
26 
27 template <typename TProcessor, typename InputStorageType, typename TAttribute>
29 {
30 // predefined public types
31 public:
33  typedef TProcessor ProcessorType;
34 
36  typedef TAttribute AttributeType;
37 
39  typedef typename InputStorageType::element_type InputValueType;
40 
42  typedef typename boost::remove_const<InputValueType>::type InputMutableValueType;
43 
45  typedef typename TAttribute::StorageType OutputStorageType;
46 
47 public:
50  PlanIndexedSplit() {}
51  ~PlanIndexedSplit() {}
53 
54 // methods
55 public:
57  const std::string& getAttributeName() const;
58 
60  const std::string& getAttributeToolTip() const;
61 
67  void init(const InputStorageType& pPlanIndexedColl,
68  const ipUInt64 sizeZ,
69  const ipUInt64 sizeC,
70  const ipUInt64 sizeT,
71  const bool bCanBeSingle = false);
72 
73 protected:
75  bool checkProcessorType(const processor::BaseProcessor& processor);
76 
81  const ipUInt32 elementIdx,
82  const core::BaseRequestOrigin& requestOrigin);
83 
84 // attributes
85 protected:
86 
87 };
88 
91 
92 template <typename TProcessor, typename InputStorageType, typename TAttribute>
93 inline const std::string&
95 {
96  return TAttribute::getObjectNameStr();
97 }
98 
99 template <typename TProcessor, typename InputStorageType, typename TAttribute>
100 inline const std::string&
102 {
103  return TAttribute::getToolTipStr();
104 }
105 
106 template <typename TProcessor, typename InputStorageType, typename TAttribute>
107 inline void
109  const ipUInt64 sizeZ,
110  const ipUInt64 sizeC,
111  const ipUInt64 sizeT,
112  const bool bCanBeSingle)
113 {
114  // call of base class initialization method
115  this->initBase(boost::const_pointer_cast<InputMutableValueType>(pPlanIndexedColl), sizeZ, sizeC, sizeT, bCanBeSingle);
116 }
117 
118 template <typename TProcessor, typename InputStorageType, typename TAttribute>
119 inline bool
121 {
122  // check for consistency between processor and attribute
124  "This attribute is not part of processor class");
125 
126  return dynamic_cast<const TProcessor*>(&processor) != 0;
127 }
128 
129 template <typename TProcessor, typename InputStorageType, typename TAttribute>
130 inline BoolResult
132  const ipUInt32 elementIdx,
133  const core::BaseRequestOrigin& requestOrigin)
134 {
135  // cast of input processor object
136  TProcessor& tProcessor = static_cast<TProcessor&>(processor);
137 
138  // retrieve plan indexed collection
139  InputStorageType pPlanIndexedColl = boost::static_pointer_cast<InputValueType>(_pPlanIndexedColl);
140 
141  // check for single element
142  OutputStorageType pOutputData;
143  if (pPlanIndexedColl->getNbPlans() > 1) {
144 
145  // retrieve associated element into collection
146  const ipUInt64 tPlanIdx = elementIdx / (_sizeZ * _sizeC);
147  const ipUInt64 cPlanIdx = (elementIdx - tPlanIdx * _sizeZ * _sizeC) / _sizeZ;
148  const ipUInt64 zPlanIdx = (elementIdx - tPlanIdx * _sizeZ * _sizeC - cPlanIdx * _sizeZ);
149  pOutputData = pPlanIndexedColl->getStorage(zPlanIdx, cPlanIdx, tPlanIdx);
150  }
151  else
152  pOutputData = pPlanIndexedColl->getStorage(0, 0, 0);
153 
154  // update of processor attribute value
155  tProcessor.TProcessor::template set<TAttribute>(pOutputData);
156 
157  return true;
158 }
159 
162 
163 } // end of namespace imaproc
164 } // end of namespace ipsdk
165 
166 #endif // __IPSDKIMAGEPROCESSING_PLANINDEXEDSPLIT_H__
TProcessor ProcessorType
processor type associated to object
Definition: PlanIndexedSplit.h:33
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
uint64_t ipUInt64
Base types definition.
Definition: BaseTypes.h:55
TAttribute::StorageType OutputStorageType
output storage type for split operation
Definition: PlanIndexedSplit.h:45
const std::string & getAttributeName() const
retrieve attribute name associated to split operation
Definition: PlanIndexedSplit.h:94
TAttribute AttributeType
attribute type associated to object
Definition: PlanIndexedSplit.h:36
Base class for processor class.
Definition: BaseProcessor.h:43
structure allowing to check whether a given attribute exists in attribute collection information ...
Definition: AttributeCollInfoCheckMacros.h:131
BoolResult processAttribute(processor::BaseProcessor &processor, const ipUInt32 elementIdx, const core::BaseRequestOrigin &requestOrigin)
initialize processor attribute associate to split operation for a given element index ...
Definition: PlanIndexedSplit.h:131
InputStorageType::element_type InputValueType
input value type for split operation
Definition: PlanIndexedSplit.h:39
Concrete class for split operation using input plan indexed data.
Definition: PlanIndexedSplit.h:28
const std::string & getAttributeToolTip() const
retrieve attribute tooltip associated to split operation
Definition: PlanIndexedSplit.h:101
Base class for request origin description.
Definition: BaseRequestOrigin.h:28
bool checkProcessorType(const processor::BaseProcessor &processor)
check processor type in derived class
Definition: PlanIndexedSplit.h:120
void init(const InputStorageType &pPlanIndexedColl, const ipUInt64 sizeZ, const ipUInt64 sizeC, const ipUInt64 sizeT, const bool bCanBeSingle=false)
initialization method for splitted objects
Definition: PlanIndexedSplit.h:108
Base class for plan indexed split operations for data dispatch.
Definition: BasePlanIndexedSplit.h:34
boost::remove_const< InputValueType >::type InputMutableValueType
input mutable value type for split operation
Definition: PlanIndexedSplit.h:42
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53