3DiVi Face SDK  3.24.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups
ProcessingBlock.h
1 
9 #ifndef PROCESSINGBLOCK_H
10 #define PROCESSINGBLOCK_H
11 
12 #ifndef WITHOUT_PROCESSING_BLOCK
13 
14 #include "Context.h"
15 #include "DllHandle.h"
16 #include "ExceptionCheck.h"
17 
18 namespace pbio
19 {
20 
21 class FacerecService;
22 
30 {
31 public:
32 
33  ProcessingBlock(const ProcessingBlock&) = delete;
34  ProcessingBlock& operator=(const ProcessingBlock&) = delete;
35  ProcessingBlock(ProcessingBlock&& other) : dll_handle_(other.dll_handle_), eh_(nullptr)
36  {
37  handle_ = other.handle_;
38  other.handle_ = nullptr;
39  };
40  ProcessingBlock& operator=(ProcessingBlock&& other)
41  {
42  if (&other != this)
43  {
44  handle_ = other.handle_;
45  other.handle_ = nullptr;
46  }
47  return *this;
48  }
49 
60  virtual void operator()(pbio::Context& ctx)
61  {
62  dll_handle_->TDVProcessingBlock_processContext(handle_, ctx.getHandle(), &eh_);
63  tdvCheckException(dll_handle_, eh_);
64  }
65 
66  ~ProcessingBlock() {
67  if(handle_)
68  {
69  dll_handle_->TDVProcessingBlock_destroyBlock(handle_, &eh_);
70  if (eh_ && std::uncaught_exception())
71  std::cerr << Error(dll_handle_->TDVException_getErrorCode(eh_), dll_handle_->TDVException_getMessage(eh_)).what();
72  else
73  tdvCheckException(dll_handle_, eh_);
74  handle_ = nullptr;
75  }
76  }
77 
78 private:
79 
80  ProcessingBlock(void* service, const DHPtr &dll_handle, const pbio::Context& ctx) : dll_handle_(dll_handle), eh_(nullptr) {
81  void* exception = nullptr;
82  handle_ = dll_handle_->FacerecService_ProcessingBlock_createProcessingBlock(service, ctx.getHandle(), &exception);
83  checkException(exception, *dll_handle_);
84  }
85 
86  typedef LightSmartPtr<import::DllHandle>::tPtr DHPtr;
87 
88  const DHPtr dll_handle_;
89  mutable ContextEH* eh_;
90  HPBlock* handle_;
91 
92  friend class FacerecService;
93 };
94 }
95 
96 #endif // WITHOUT_PROCESSING_BLOCK
97 #endif // PROCESSINGBLOCK_H
Interface object used to work with estimators from Processing Block API.
Definition: ProcessingBlock.h:29
virtual void operator()(pbio::Context &ctx)
Calling the processing block function.
Definition: ProcessingBlock.h:60
Interface object used to work with estimators from Processing Block API.
Definition: ProcessingBlock.h:16
The class of exceptions thrown when errors occur.
Definition: Error.h:26
Context is an interface object for storing data and interacting with methods from the Processing Bloc...
Definition: Context.h:51
Definition: FacerecService.mm:79