3DiVi Face SDK  3.26.0
 Указатель Классы Пространства имен Файлы Функции Переменные Определения типов Перечисления Элементы перечислений Свойства Группы
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 __cplusplus >= 201703L
71  if (eh_ && std::uncaught_exceptions() > 0)
72 #else
73  if (eh_ && std::uncaught_exception())
74 #endif
75  std::cerr << Error(dll_handle_->TDVException_getErrorCode(eh_), dll_handle_->TDVException_getMessage(eh_)).what();
76  else
77  tdvCheckException(dll_handle_, eh_);
78  handle_ = nullptr;
79  }
80  }
81 
82 private:
83 
84  ProcessingBlock(void* service, const DHPtr &dll_handle, const pbio::Context& ctx) : dll_handle_(dll_handle), eh_(nullptr) {
85  void* exception = nullptr;
86  handle_ = dll_handle_->FacerecService_ProcessingBlock_createProcessingBlock(service, ctx.getHandle(), &exception);
87  checkException(exception, *dll_handle_);
88  }
89 
90  typedef LightSmartPtr<import::DllHandle>::tPtr DHPtr;
91 
92  const DHPtr dll_handle_;
93  mutable ContextEH* eh_;
94  HPBlock* handle_;
95 
96  friend class FacerecService;
97 };
98 }
99 
100 #endif // WITHOUT_PROCESSING_BLOCK
101 #endif // PROCESSINGBLOCK_H
Интерфейсный объект для взаимодействия с методами из Processing Block API.
Definition: ProcessingBlock.h:29
virtual void operator()(pbio::Context &ctx)
Вызов функции процессинг-блока.
Definition: ProcessingBlock.h:60
Интерфейсный объект для взаимодействия с методами из Processing Block API.
Definition: ProcessingBlock.h:16
Класс исключений, выбрасываемых при возникновении ошибок.
Definition: Error.h:26
Context - интерфейсный объект для хранения данных и взаимодействия с методами из Processing Block API...
Definition: Context.h:48
Definition: FacerecService.mm:79