3DiVi Face SDK  3.21.0
 Указатель Классы Пространства имен Файлы Функции Переменные Определения типов Перечисления Элементы перечислений Свойства Группы
ProcessingUnit.h
1 #ifndef __PBIO_API__PBIO__PROCESSING_UNIT_H_
2 #define __PBIO_API__PBIO__PROCESSING_UNIT_H_
3 
5 
6 #include "ComplexObject.h"
7 #include "SmartPtr.h"
8 #include "Error.h"
9 #include "ExceptionCheck.h"
10 
11 namespace pbio
12 {
13 
14 class FacerecService;
15 
16 
17 class ProcessingUnit : public ComplexObject
18 {
19 public:
20 
21  enum BLOCK_TYPE
22  {
23  FACE_ATTRIBUTES_ESTIMATOR = 1,
24  };
25 
26  typedef LightSmartPtr<ProcessingUnit>::tPtr Ptr;
27 
28  char* processSparse(char* serializedCtx) const;
29 
30  void freeStr(char* str_ptr) const;
31 
32  void* getException() const;
33 
34 private:
35 
36  ProcessingUnit(
37  const DHPtr &dll_handle,
38  const int block_type,
39  const char* serializedConfig);
40 
41  ~ProcessingUnit();
42 
43  void* _block_ptr;
44 
45  friend class FacerecService;
46  friend class object_with_ref_counter<ProcessingUnit>;
47 };
48 
49 } // pbio namespace
50 
51 
52 
56 
57 namespace pbio
58 {
59 
60 
61 inline
62 ProcessingUnit::ProcessingUnit(
63  const DHPtr &dll_handle,
64  const int block_type,
65  const char* serializedConfig)
66 : ComplexObject(dll_handle, nullptr)
67 {
68  if (block_type == FACE_ATTRIBUTES_ESTIMATOR)
69  {
70  _block_ptr = _dll_handle->TDVFaceAttributesEstimator_createByConfig(serializedConfig);
71  }else
72  {
73  throw pbio::Error(0x10ba1f8e, "Error in pbio::ProcessingUnit"
74  " unknown block_type for ProcessingUnit");
75  }
76  checkException(getException(), *_dll_handle);
77 }
78 
79 
80 inline
81 ProcessingUnit::~ProcessingUnit()
82 {
83  if(_block_ptr)
84  {
85  _dll_handle->TDVProcessingBlock_destroy(_block_ptr);
86  _block_ptr = nullptr;
87  }
88 }
89 
90 
91 inline
92 char* ProcessingUnit::processSparse(char* serializedCtx) const
93 {
94  char* result = _dll_handle->TDVProcessingBlock_processSparse(_block_ptr, serializedCtx);
95  checkException(getException(), *_dll_handle);
96  return result;
97 }
98 
99 
100 inline
101 void* ProcessingUnit::getException() const
102 {
103  return _dll_handle->TDVProcessingBlock_getException(_block_ptr);
104 }
105 
106 
107 inline
108 void ProcessingUnit::freeStr(char* str_ptr) const
109 {
110  _dll_handle->tdvFreeStr(str_ptr);
111 }
112 
113 } // pbio namespace
114 
116 
117 
118 #endif // __PBIO_API__PBIO__PROCESSING_BLOCK_H_
Error - класс исключений, выбрасываемых при возникновении ошибок.
Класс исключений, выбрасываемых при возникновении ошибок.
Definition: Error.h:26
SmartPtr.