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);
127 const DHPtr _dll_handle;
129 int32_t refcounter4light_shared_ptr;
143 inline DynamicTemplateIndex::DynamicTemplateIndex(
const DHPtr& dll_handle,
void* impl,
bool weak) :
144 _dll_handle(dll_handle),
153 std::ostringstream name_stream;
154 pbio::stl_wraps::WrapOStreamImpl name_stream_wrap(name_stream);
156 void* exception =
nullptr;
158 _dll_handle->DynamicTemplateIndex_getMethodName(
161 pbio::stl_wraps::WrapOStream::write_func,
164 checkException(exception, *_dll_handle);
166 return name_stream.str();
171 void* exception =
nullptr;
173 const size_t size = _dll_handle->DynamicTemplateIndex_size(
177 checkException(exception, *_dll_handle);
182 inline size_t DynamicTemplateIndex::capacity()
const
184 void* exception =
nullptr;
186 size_t capacity = _dll_handle->DynamicTemplateIndex_capacity(
191 checkException(exception, *_dll_handle);
198 void* exception =
nullptr;
199 std::ostringstream name_stream;
200 pbio::stl_wraps::WrapOStreamImpl name_stream_wrap(name_stream);
202 _dll_handle->DynamicTemplateIndex_at_by_index(
206 pbio::stl_wraps::WrapOStream::write_func,
209 checkException(exception, *_dll_handle);
211 return name_stream.str();
216 void* exception =
nullptr;
218 void* implementation = _dll_handle->DynamicTemplateIndex_at_by_uuid(
223 checkException(exception, *_dll_handle);
225 return ContextTemplate::Ptr::make(_dll_handle, implementation);
230 void* exception =
nullptr;
232 void* implementation = _dll_handle->DynamicTemplateIndex_get(
237 checkException(exception, *_dll_handle);
239 return ContextTemplate::Ptr::make(_dll_handle, implementation);
244 void* exception =
nullptr;
246 _dll_handle->DynamicTemplateIndex_add_1(_impl, static_cast<pbio::facerec::TemplateImpl*>(templ->_impl), uuid.data(), &exception);
248 checkException(exception, *_dll_handle);
251 inline void DynamicTemplateIndex::add(
const std::vector<pbio::Template::Ptr>& templates,
const std::vector<std::string>& uuids)
253 void* exception =
nullptr;
255 std::vector<pbio::facerec::TemplateImpl*> tempTemplates;
256 std::vector<const char*> tempUuids;
258 tempTemplates.reserve(templates.size());
259 tempUuids.reserve(uuids.size());
263 templates.begin(), templates.end(), std::back_inserter(tempTemplates),
264 [](
pbio::Template::Ptr templ) {
return reinterpret_cast<pbio::facerec::TemplateImpl*
>(templ->_impl); }
266 std::transform(uuids.begin(), uuids.end(), std::back_inserter(tempUuids), [](
const std::string& uuid) {
return uuid.data(); });
268 _dll_handle->DynamicTemplateIndex_add_2(_impl, tempTemplates.data(), tempUuids.data(), templates.size(), &exception);
270 checkException(exception, *_dll_handle);
275 void* exception =
nullptr;
277 _dll_handle->DynamicTemplateIndex_add_3(_impl, templ->_impl, uuid.data(), &exception);
279 checkException(exception, *_dll_handle);
282 inline void DynamicTemplateIndex::add(
const std::vector<pbio::ContextTemplate::Ptr>& templates,
const std::vector<std::string>& uuids)
284 void* exception =
nullptr;
286 std::vector<const void*> tempTemplates;
287 std::vector<const char*> tempUuids;
289 tempTemplates.reserve(templates.size());
290 tempUuids.reserve(uuids.size());
294 templates.begin(), templates.end(), std::back_inserter(tempTemplates),
297 std::transform(uuids.begin(), uuids.end(), std::back_inserter(tempUuids), [](
const std::string& uuid) {
return uuid.data(); });
299 _dll_handle->DynamicTemplateIndex_add_4(_impl, tempTemplates.data(), tempUuids.data(), templates.size(), &exception);
301 checkException(exception, *_dll_handle);
304 inline void DynamicTemplateIndex::remove(
const std::string& uuid)
306 void* exception =
nullptr;
308 _dll_handle->DynamicTemplateIndex_remove_1(_impl, uuid.data(), &exception);
310 checkException(exception, *_dll_handle);
313 inline void DynamicTemplateIndex::remove(
const std::vector<std::string>& uuids)
315 void* exception =
nullptr;
316 std::vector<const char*> data;
318 data.reserve(uuids.size());
320 std::transform(uuids.begin(), uuids.end(), std::back_inserter(data), [](
const std::string& uuid) {
return uuid.data(); });
322 _dll_handle->DynamicTemplateIndex_remove_2(_impl, data.data(), uuids.size(), &exception);
324 checkException(exception, *_dll_handle);
329 void* exception =
nullptr;
331 _dll_handle->DynamicTemplateIndex_concatenate(_impl, otherIndex->_impl, &exception);
333 checkException(exception, *_dll_handle);
336 inline DynamicTemplateIndex::~DynamicTemplateIndex()
340 _dll_handle->DynamicTemplateIndex_destructor(_impl);
size_t size() const
Get a number of templates in the index. Thread-safe.
Definition: DynamicTemplateIndex.h:169
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:196
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:151
Context is an interface object for storing data and interacting with methods from the Processing Bloc...
Definition: Context.h:52
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