3DiVi Face SDK  3.25.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups
ContextTemplate.h
1 
9 #ifndef __PBIO_API__PBIO__CONTEXT_TEMPLATE_H_
10 #define __PBIO_API__PBIO__CONTEXT_TEMPLATE_H_
11 
12 
13 #include <ostream>
14 #include <sstream>
15 
16 
17 #include "ComplexObject.h"
18 #include "Error.h"
19 #include "ExceptionCheck.h"
20 #include "SmartPtr.h"
21 #include "stl_wraps_impls/WrapOStreamImpl.h"
22 
23 
24 
25 namespace pbio
26 {
27 
28 class Recognizer;
29 class VideoWorker;
30 class TemplatesIndex;
31 
38 {
39 public:
41 
47  typedef LightSmartPtr<ContextTemplate>::tPtr Ptr;
48 
66  std::string getMethodName() const;
67 
68 
90  void save(std::ostream &binary_stream) const;
91 
113  void save(pbio::stl_wraps::WrapOStream &binary_stream) const;
114 
115  int32_t size() const;
116 
117  ~ContextTemplate();
118 
119 private:
120  ContextTemplate(const DHPtr &dll_handle, void* impl);
121 
122  const DHPtr _dll_handle;
123  void* _impl;
124  int32_t refcounter4light_shared_ptr;
125 
126  friend class DynamicTemplateIndex;
127  friend class Context;
128  friend class FacerecService;
129  friend class object_with_ref_counter<ContextTemplate>;
130 };
131 
132 } // pbio namespace
133 
134 
135 
136 
140 
141 namespace pbio
142 {
143 
144 inline ContextTemplate::ContextTemplate(const DHPtr &dll_handle,void* impl) :
145  _dll_handle(dll_handle),
146  _impl(impl)
147 {
148 
149 }
150 
151 inline std::string ContextTemplate::getMethodName() const
152 {
153  std::ostringstream name_stream;
154  pbio::stl_wraps::WrapOStreamImpl name_stream_wrap(name_stream);
155 
156  void* exception = NULL;
157 
158  _dll_handle->ContextTemplate_getMethodName(
159  _impl,
160  &name_stream_wrap,
161  pbio::stl_wraps::WrapOStream::write_func,
162  &exception);
163 
164  checkException(exception, *_dll_handle);
165 
166  return name_stream.str();
167 }
168 
169 inline void ContextTemplate::save(std::ostream &binary_stream) const
170 {
171  pbio::stl_wraps::WrapOStreamImpl binary_stream_wrap(binary_stream);
172 
173  save(binary_stream_wrap);
174 }
175 
176 inline void ContextTemplate::save(pbio::stl_wraps::WrapOStream &binary_stream) const
177 {
178  void* exception = NULL;
179 
180  _dll_handle->ContextTemplate_save(
181  _impl,
182  &binary_stream,
183  pbio::stl_wraps::WrapOStream::write_func,
184  &exception);
185 
186  checkException(exception, *_dll_handle);
187 }
188 
189 inline int32_t ContextTemplate::size() const
190 {
191  void* exception = NULL;
192 
193  int32_t result = _dll_handle->ContextTemplate_size(
194  _impl,
195  &exception);
196 
197  checkException(exception, *_dll_handle);
198 
199  return result;
200 }
201 
202 inline ContextTemplate::~ContextTemplate()
203 {
204  if (_impl)
205  {
206  _dll_handle->ContextTemplate_destructor(_impl);
207 
208  _impl = nullptr;
209  }
210 }
211 
212 } // pbio namespace
213 #endif // __PBIO_API__PBIO__TEMPLATE_H_
Interface object for creating other interface objects.
Definition: FacerecService.h:64
Definition: Recognizer.h:64
Error - the class of exceptions thrown when errors occur.
Definition: SmartPtr.h:84
std::string getMethodName() const
Get a method name. Thread-safe.
Definition: ContextTemplate.h:151
VideoWorker is an interface object for tracking, processing and matching faces on multiple video stre...
Definition: VideoWorker.h:105
Interface object for saving the face template.
Definition: ContextTemplate.h:37
Context is an interface object for storing data and interacting with methods from the Processing Bloc...
Definition: Context.h:52
SmartPtr.
LightSmartPtr< ContextTemplate >::tPtr Ptr
Alias for the type of a smart pointer to ContextTemplate.
Definition: ContextTemplate.h:47
void save(std::ostream &binary_stream) const
Save the template to binary_stream. The format is platform-independent. Thread-safe.
Definition: ContextTemplate.h:169
Interface object for working with the template index.
Definition: DynamicTemplateIndex.h:26