IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
GpuSubImageSplit.h
1 // GpuSubImageSplit.h:
3 // --------------------
4 //
14 /*
15 #ifndef __IPSDKIMAGEPROCESSING_GPUSUBIMAGESPLIT_H__
16 #define __IPSDKIMAGEPROCESSING_GPUSUBIMAGESPLIT_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::imaproc::GpuSubImageSplit<InOutStorageType>::_subImageSplitType' : class 'ipsdk::imaproc::eSubImageSplitType' needs to have dll-interface to be used by clients of class 'ipsdk::imaproc::GpuSubImageSplit<InOutStorageType>'
20 #pragma warning (push)
21 #pragma warning (disable : 4251)
22 
23 #include <IPSDKImageProcessing/IPSDKImageProcessingExports.h>
24 #include <IPSDKImageProcessing/DataSplit/SubImage/BaseGpuSubImageSplit.h>
25 #include <IPSDKImageProcessing/DataSplit/SubImage/SubImageSplitTypes.h>
26 #include <IPSDKImage/Image/ImageTypes.h>
27 #include <IPSDKUtil/Tools/ProcessingResult.h>
28 
29 namespace ipsdk {
30 namespace imaproc {
31 
34 
35 template <typename TProcessor, typename TAttribute>
36 class GpuSubImageSplit : public BaseGpuSubImageSplit<typename TAttribute::StorageType>
37 {
38  // predefined public types
39 public:
41  typedef TProcessor ProcessorType;
42 
44  typedef TAttribute AttributeType;
45 
47  typedef typename TAttribute::StorageType InputStorageType;
48 
50  typedef typename TAttribute::StorageType OutputStorageType;
51 
52 public:
55  GpuSubImageSplit() {}
56  ~GpuSubImageSplit() {}
58 
59 // methods from SubImageSplit
60 public:
62  const std::string& getAttributeName() const;
63 
65  const std::string& getAttributeToolTip() const;
66 
73  void init(const eSubImageSplitType& subImageSplitType,
74  const ipUInt64 nbDevices,
75  const InputStorageType& pImage);
76 
81  void init(const eSubImageSplitType& subImageSplitType,
82  const InputStorageType& pImage);
83 
84 protected:
86  bool checkProcessorType(const processor::BaseProcessor& processor);
87 
91  BoolResult processAttribute(processor::BaseProcessor& processor,
92  const ipUInt32 elementIdx,
93  const core::BaseRequestOrigin& requestOrigin);
94 };
95 
98 
99 template <typename TProcessor, typename TAttribute>
100 inline const std::string&
101 GpuSubImageSplit<TProcessor, TAttribute>::getAttributeName() const
102 {
103  return TAttribute::getObjectNameStr();
104 }
105 
106 template <typename TProcessor, typename TAttribute>
107 inline const std::string&
108 GpuSubImageSplit<TProcessor, TAttribute>::getAttributeToolTip() const
109 {
110  return TAttribute::getToolTipStr();
111 }
112 
113 template <typename TProcessor, typename TAttribute>
114 inline void
115 GpuSubImageSplit<TProcessor, TAttribute>::init(const eSubImageSplitType& subImageSplitType,
116  const ipUInt64 nbDevices,
117  const InputStorageType& pImage)
118 {
119  // call of base class initialization method
120  this->initBase(subImageSplitType, nbDevices, pImage);
121 }
122 
123 template <typename TProcessor, typename TAttribute>
124 inline void
125 GpuSubImageSplit<TProcessor, TAttribute>::init(const eSubImageSplitType& subImageSplitType,
126  const InputStorageType& pImage)
127 {
128  // call of base class initialization method
129  this->initBase(subImageSplitType, pImage);
130 }
131 
132 template <typename TProcessor, typename TAttribute>
133 inline bool
134 GpuSubImageSplit<TProcessor, TAttribute>::checkProcessorType(const processor::BaseProcessor& processor)
135 {
136  // check for consistency between processor and attribute
137  BOOST_STATIC_ASSERT_MSG((processor::ExistsAttribute<TAttribute, typename TProcessor::AttributesInfo>::g_bValue),
138  "This attribute is not part of processor class");
139 
140  return dynamic_cast<const TProcessor*>(&processor) != 0;
141 }
142 
143 template <typename TProcessor, typename TAttribute>
144 inline BoolResult
145 GpuSubImageSplit<TProcessor, TAttribute>::processAttribute(processor::BaseProcessor& processor,
146  const ipUInt32 elementIdx,
147  const core::BaseRequestOrigin& requestOrigin)
148 {
149  // cast of input processor object
150  TProcessor& tProcessor = static_cast<TProcessor&>(processor);
151 
152  // retrieve sub image associated to element
153  OutputStorageType pSubImage;
154  BoolResult bGetSubImageRes = this->getSubImage(elementIdx, pSubImage);
155  if (bGetSubImageRes == true) {
156 
157  // update of processor attribute value
158  tProcessor.TProcessor::template set<TAttribute>(pSubImage);
159 
160  return true;
161  }
162  else
163  return bGetSubImageRes;
164 }
165 
166 } // end of namespace imaproc
167 } // end of namespace ipsdk
168 
169 #pragma warning (pop)
170 
171 #endif // __IPSDKIMAGEPROCESSING_GPUSUBIMAGESPLIT_H__
172 */
173