IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
StaticResultSplit.h
1 // StaticResultSplit.h:
3 // --------------------
4 //
15 
16 #ifndef __IPSDKBASEPROCESSING_STATICRESULTSPLIT_H__
17 #define __IPSDKBASEPROCESSING_STATICRESULTSPLIT_H__
18 
19 #include <IPSDKBaseProcessing/DataSplit/Static/BaseStaticSplit.h>
20 #include <boost/utility/enable_if.hpp>
21 #include <boost/type_traits/is_same.hpp>
22 #include <boost/make_shared.hpp>
23 #include <map>
24 
25 namespace ipsdk {
26 namespace processor {
27 
30 
31 template <typename TProcessor, typename TAttribute>
33 {
34 // predefined public types
35 public:
37  typedef TProcessor ProcessorType;
38 
40  typedef TAttribute AttributeType;
41 
43  typedef typename boost::enable_if_c<boost::is_same<typename TAttribute::StorageType,
44  boost::shared_ptr<typename TAttribute::ValueType> >::value,
45  typename TAttribute::StorageType>::type ParameterType;
46 
48  typedef std::map<ipUInt32, ParameterType> ParameterColl;
49 
51  typedef boost::shared_ptr<ParameterColl> ParameterCollPtr;
52 
53 public:
59 
60 // methods
61 public:
64 
66  const std::string& getAttributeName() const;
67 
69  const std::string& getAttributeToolTip() const;
70 
72  void init(const ParameterCollPtr& pParameterColl,
73  const ParameterType& pDefaultValue);
74 
75 protected:
77  bool checkProcessorType(const BaseProcessor& processor);
78 
83  const ipUInt32 elementIdx,
84  const core::BaseRequestOrigin& requestOrigin);
85 
86 // attributes
87 protected:
90 
93 };
94 
97 
98 template <typename TProcessor, typename TAttribute>
100 {
101 
102 }
103 
104 template <typename TProcessor, typename TAttribute>
105 StaticResultSplit<TProcessor, TAttribute>::~StaticResultSplit()
106 {
107 
108 }
109 
110 template <typename TProcessor, typename TAttribute>
111 inline eSplitStaticType
113 {
115 }
116 
117 template <typename TProcessor, typename TAttribute>
118 inline const std::string&
120 {
121  return TAttribute::getObjectNameStr();
122 }
123 
124 template <typename TProcessor, typename TAttribute>
125 inline const std::string&
127 {
128  return TAttribute::getToolTipStr();
129 }
130 
131 template <typename TProcessor, typename TAttribute>
132 inline void
134  const ParameterType& pDefaultValue)
135 {
136  // check for input shared pointers validity
137  if (pParameterColl.get() == 0 || pDefaultValue.get() == 0)
138  throwNullInputSharedPtr();
139 
140  // call of base class initialization method
141  ElementsLocationInfo elementsLocationInfo;
142  elementsLocationInfo.insertNonLocalized(ElementsRange(0, 1), 0);
143  this->initBaseUnSplitted(elementsLocationInfo);
144 
145  // collection of elements associated to static split
146  _pParameterColl = pParameterColl;
147  _pParameterColl->clear();
148 
149  // default value for newly created elements
150  _pDefaultValue = pDefaultValue;
151 }
152 
153 template <typename TProcessor, typename TAttribute>
154 inline bool
156 {
157  // check for consistency between processor and attribute
159  "This attribute is not part of processor class");
160 
161  return dynamic_cast<const TProcessor*>(&processor) != 0;
162 }
163 
164 template <typename TProcessor, typename TAttribute>
165 inline BoolResult
167  const ipUInt32 elementIdx,
168  const core::BaseRequestOrigin& requestOrigin)
169 {
170  // cast of input processor object
171  TProcessor& tProcessor = static_cast<TProcessor&>(processor);
172 
173  // creation of a new result element
174  ParameterType pCurResult(boost::make_shared<typename TAttribute::ValueType>(*_pDefaultValue));
175 
176  // insertion of element into collection
177  (*_pParameterColl)[elementIdx] = pCurResult;
178 
179  // update of processor attribute value
180  tProcessor.TProcessor::template set<TAttribute>(pCurResult);
181 
182  return true;
183 }
184 
187 
188 } // end of namespace processor
189 } // end of namespace ipsdk
190 
191 #endif // __IPSDKBASEPROCESSING_STATICRESULTSPLIT_H__
Template class for results splitted data used for static data dispatch.
Definition: StaticResultSplit.h:32
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
eSplitStaticType getSplitStaticType() const
retrieve static split operation type
Definition: StaticResultSplit.h:112
ipUInt64 insertNonLocalized(const ElementsRange &elementsRange, const ipUInt64 dataMemorySize)
insertion of a new non localized information into collection
Static split operation type for results elements.
Definition: StaticSplitTypes.h:36
std::map< ipUInt32, ParameterType > ParameterColl
collection of elements associated to static split indexed by starting offset
Definition: StaticResultSplit.h:48
ParameterCollPtr _pParameterColl
collection of elements associated to static split
Definition: StaticResultSplit.h:89
void init(const ParameterCollPtr &pParameterColl, const ParameterType &pDefaultValue)
object initialization method
Definition: StaticResultSplit.h:133
const std::string & getAttributeToolTip() const
retrieve attribute tooltip associated to split operation
Definition: StaticResultSplit.h:126
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(BaseProcessor &processor, const ipUInt32 elementIdx, const core::BaseRequestOrigin &requestOrigin)
initialize processor attribute associate to split operation for a given element index ...
Definition: StaticResultSplit.h:166
eSplitStaticType
Enumerate describing static split operation type.
Definition: StaticSplitTypes.h:32
const std::string & getAttributeName() const
retrieve attribute name associated to split operation
Definition: StaticResultSplit.h:119
boost::enable_if_c< boost::is_same< typename TAttribute::StorageType, boost::shared_ptr< typename TAttribute::ValueType > >::value, typename TAttribute::StorageType >::type ParameterType
parameter type associated to object
Definition: StaticResultSplit.h:45
Base class for data static split objets used for data dispatch.
Definition: BaseStaticSplit.h:34
TProcessor ProcessorType
processor type associated to object
Definition: StaticResultSplit.h:37
Class allowing to store information about elements range (start offset and number of elements) ...
Definition: ElementsRange.h:27
Base class for request origin description.
Definition: BaseRequestOrigin.h:28
boost::shared_ptr< ParameterColl > ParameterCollPtr
shared pointer to collection of elements associated to static split
Definition: StaticResultSplit.h:51
bool checkProcessorType(const BaseProcessor &processor)
check processor type in derived class
Definition: StaticResultSplit.h:155
ParameterType _pDefaultValue
default value for split operation
Definition: StaticResultSplit.h:92
Class allowing to store elements location informations.
Definition: ElementsLocationInfo.h:32
TAttribute AttributeType
attribute type associated to object
Definition: StaticResultSplit.h:40
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53