9 #ifndef __PBIO_API__PBIO__RESIZABLE_TEMPLATE_INDEX_H_
10 #define __PBIO_API__PBIO__RESIZABLE_TEMPLATE_INDEX_H_
12 #include "ComplexObject.h"
15 #include "stl_wraps_impls/WrapOStreamImpl.h"
17 #include "ContextTemplate.h"
34 typedef LightSmartPtr<DynamicTemplateIndex>::tPtr
Ptr;
57 size_t capacity()
const;
82 std::string
getUUID(
size_t index)
const;
90 void add(
const std::vector<pbio::Template::Ptr>& templates,
const std::vector<std::string>& uuids);
94 void add(
const std::vector<pbio::ContextTemplate::Ptr>& templates,
const std::vector<std::string>& uuids);
96 void remove(
const std::string& uuid);
98 void remove(
const std::vector<std::string>& uuids);
129 const DHPtr _dll_handle;
131 int32_t refcounter4light_shared_ptr;
145 inline DynamicTemplateIndex::DynamicTemplateIndex(
const DHPtr& dll_handle,
void* impl,
bool weak) :
146 _dll_handle(dll_handle),
155 std::ostringstream name_stream;
156 pbio::stl_wraps::WrapOStreamImpl name_stream_wrap(name_stream);
158 void* exception =
nullptr;
160 _dll_handle->DynamicTemplateIndex_getMethodName(
163 pbio::stl_wraps::WrapOStream::write_func,
166 checkException(exception, *_dll_handle);
168 return name_stream.str();
173 void* exception =
nullptr;
175 const size_t size = _dll_handle->DynamicTemplateIndex_size(
179 checkException(exception, *_dll_handle);
184 inline size_t DynamicTemplateIndex::capacity()
const
186 void* exception =
nullptr;
188 size_t capacity = _dll_handle->DynamicTemplateIndex_capacity(
193 checkException(exception, *_dll_handle);
200 void* exception =
nullptr;
201 std::ostringstream name_stream;
202 pbio::stl_wraps::WrapOStreamImpl name_stream_wrap(name_stream);
204 _dll_handle->DynamicTemplateIndex_at_by_index(
208 pbio::stl_wraps::WrapOStream::write_func,
211 checkException(exception, *_dll_handle);
213 return name_stream.str();
218 void* exception =
nullptr;
220 void* implementation = _dll_handle->DynamicTemplateIndex_at_by_uuid(
225 checkException(exception, *_dll_handle);
227 return ContextTemplate::Ptr::make(_dll_handle, implementation);
232 void* exception =
nullptr;
234 void* implementation = _dll_handle->DynamicTemplateIndex_get(
239 checkException(exception, *_dll_handle);
241 return ContextTemplate::Ptr::make(_dll_handle, implementation);
246 void* exception =
nullptr;
248 _dll_handle->DynamicTemplateIndex_add_1(_impl, static_cast<pbio::facerec::TemplateImpl*>(templ->_impl), uuid.data(), &exception);
250 checkException(exception, *_dll_handle);
253 inline void DynamicTemplateIndex::add(
const std::vector<pbio::Template::Ptr>& templates,
const std::vector<std::string>& uuids)
255 void* exception =
nullptr;
257 std::vector<pbio::facerec::TemplateImpl*> tempTemplates;
258 std::vector<const char*> tempUuids;
260 tempTemplates.reserve(templates.size());
261 tempUuids.reserve(uuids.size());
265 templates.begin(), templates.end(), std::back_inserter(tempTemplates),
266 [](
pbio::Template::Ptr templ) {
return reinterpret_cast<pbio::facerec::TemplateImpl*
>(templ->_impl); }
268 std::transform(uuids.begin(), uuids.end(), std::back_inserter(tempUuids), [](
const std::string& uuid) {
return uuid.data(); });
270 _dll_handle->DynamicTemplateIndex_add_2(_impl, tempTemplates.data(), tempUuids.data(), templates.size(), &exception);
272 checkException(exception, *_dll_handle);
277 void* exception =
nullptr;
279 _dll_handle->DynamicTemplateIndex_add_3(_impl, templ->_impl, uuid.data(), &exception);
281 checkException(exception, *_dll_handle);
284 inline void DynamicTemplateIndex::add(
const std::vector<pbio::ContextTemplate::Ptr>& templates,
const std::vector<std::string>& uuids)
286 void* exception =
nullptr;
288 std::vector<const void*> tempTemplates;
289 std::vector<const char*> tempUuids;
291 tempTemplates.reserve(templates.size());
292 tempUuids.reserve(uuids.size());
296 templates.begin(), templates.end(), std::back_inserter(tempTemplates),
299 std::transform(uuids.begin(), uuids.end(), std::back_inserter(tempUuids), [](
const std::string& uuid) {
return uuid.data(); });
301 _dll_handle->DynamicTemplateIndex_add_4(_impl, tempTemplates.data(), tempUuids.data(), templates.size(), &exception);
303 checkException(exception, *_dll_handle);
306 inline void DynamicTemplateIndex::remove(
const std::string& uuid)
308 void* exception =
nullptr;
310 _dll_handle->DynamicTemplateIndex_remove_1(_impl, uuid.data(), &exception);
312 checkException(exception, *_dll_handle);
315 inline void DynamicTemplateIndex::remove(
const std::vector<std::string>& uuids)
317 void* exception =
nullptr;
318 std::vector<const char*> data;
320 data.reserve(uuids.size());
322 std::transform(uuids.begin(), uuids.end(), std::back_inserter(data), [](
const std::string& uuid) {
return uuid.data(); });
324 _dll_handle->DynamicTemplateIndex_remove_2(_impl, data.data(), uuids.size(), &exception);
326 checkException(exception, *_dll_handle);
331 void* exception =
nullptr;
333 _dll_handle->DynamicTemplateIndex_concatenate(_impl, otherIndex->_impl, &exception);
335 checkException(exception, *_dll_handle);
338 inline void DynamicTemplateIndex::clear()
340 void* exception =
nullptr;
342 _dll_handle->DynamicTemplateIndex_clear(_impl, &exception);
344 checkException(exception, *_dll_handle);
347 inline DynamicTemplateIndex::~DynamicTemplateIndex()
351 _dll_handle->DynamicTemplateIndex_destructor(_impl);
size_t size() const
Get a number of templates in the index. Thread-safe.
Definition: DynamicTemplateIndex.h:171
LightSmartPtr< Template >::tPtr Ptr
Alias for the type of a smart pointer to Template.
Definition: Template.h:46
Error - the class of exceptions thrown when errors occur.
std::string getUUID(size_t index) const
Get the uuid of the i-th template. Thread-safe.
Definition: DynamicTemplateIndex.h:198
Definition: SmartPtr.h:84
LightSmartPtr< DynamicTemplateIndex >::tPtr Ptr
Alias for the type of a smart pointer to DynamicTemplateIndex.
Definition: DynamicTemplateIndex.h:34
std::string getMethodName() const
Get a method name. Thread-safe.
Definition: DynamicTemplateIndex.h:153
Context is an interface object for storing data and interacting with methods from the Processing Bloc...
Definition: Context.h:48
LightSmartPtr< ContextTemplate >::tPtr Ptr
Alias for the type of a smart pointer to ContextTemplate.
Definition: ContextTemplate.h:47
Interface object for working with the template index.
Definition: DynamicTemplateIndex.h:26