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);
104 void save(
const std::string& filePath,
bool allowOverwrite)
const;
131 const DHPtr _dll_handle;
133 int32_t refcounter4light_shared_ptr;
147 inline DynamicTemplateIndex::DynamicTemplateIndex(
const DHPtr& dll_handle,
void* impl,
bool weak) :
148 _dll_handle(dll_handle),
157 std::ostringstream name_stream;
158 pbio::stl_wraps::WrapOStreamImpl name_stream_wrap(name_stream);
160 void* exception =
nullptr;
162 _dll_handle->DynamicTemplateIndex_getMethodName(
165 pbio::stl_wraps::WrapOStream::write_func,
168 checkException(exception, *_dll_handle);
170 return name_stream.str();
175 void* exception =
nullptr;
177 const size_t size = _dll_handle->DynamicTemplateIndex_size(
181 checkException(exception, *_dll_handle);
186 inline size_t DynamicTemplateIndex::capacity()
const
188 void* exception =
nullptr;
190 size_t capacity = _dll_handle->DynamicTemplateIndex_capacity(
195 checkException(exception, *_dll_handle);
202 void* exception =
nullptr;
203 std::ostringstream name_stream;
204 pbio::stl_wraps::WrapOStreamImpl name_stream_wrap(name_stream);
206 _dll_handle->DynamicTemplateIndex_at_by_index(
210 pbio::stl_wraps::WrapOStream::write_func,
213 checkException(exception, *_dll_handle);
215 return name_stream.str();
220 void* exception =
nullptr;
222 void* implementation = _dll_handle->DynamicTemplateIndex_at_by_uuid(
227 checkException(exception, *_dll_handle);
229 return ContextTemplate::Ptr::make(_dll_handle, implementation);
234 void* exception =
nullptr;
236 void* implementation = _dll_handle->DynamicTemplateIndex_get(
241 checkException(exception, *_dll_handle);
243 return ContextTemplate::Ptr::make(_dll_handle, implementation);
248 void* exception =
nullptr;
250 _dll_handle->DynamicTemplateIndex_add_1(_impl, static_cast<pbio::facerec::TemplateImpl*>(templ->_impl), uuid.data(), &exception);
252 checkException(exception, *_dll_handle);
255 inline void DynamicTemplateIndex::add(
const std::vector<pbio::Template::Ptr>& templates,
const std::vector<std::string>& uuids)
257 void* exception =
nullptr;
259 std::vector<pbio::facerec::TemplateImpl*> tempTemplates;
260 std::vector<const char*> tempUuids;
262 tempTemplates.reserve(templates.size());
263 tempUuids.reserve(uuids.size());
267 templates.begin(), templates.end(), std::back_inserter(tempTemplates),
268 [](
pbio::Template::Ptr templ) {
return reinterpret_cast<pbio::facerec::TemplateImpl*
>(templ->_impl); }
270 std::transform(uuids.begin(), uuids.end(), std::back_inserter(tempUuids), [](
const std::string& uuid) {
return uuid.data(); });
272 _dll_handle->DynamicTemplateIndex_add_2(_impl, tempTemplates.data(), tempUuids.data(), templates.size(), &exception);
274 checkException(exception, *_dll_handle);
279 void* exception =
nullptr;
281 _dll_handle->DynamicTemplateIndex_add_3(_impl, templ->_impl, uuid.data(), &exception);
283 checkException(exception, *_dll_handle);
286 inline void DynamicTemplateIndex::add(
const std::vector<pbio::ContextTemplate::Ptr>& templates,
const std::vector<std::string>& uuids)
288 void* exception =
nullptr;
290 std::vector<const void*> tempTemplates;
291 std::vector<const char*> tempUuids;
293 tempTemplates.reserve(templates.size());
294 tempUuids.reserve(uuids.size());
298 templates.begin(), templates.end(), std::back_inserter(tempTemplates),
301 std::transform(uuids.begin(), uuids.end(), std::back_inserter(tempUuids), [](
const std::string& uuid) {
return uuid.data(); });
303 _dll_handle->DynamicTemplateIndex_add_4(_impl, tempTemplates.data(), tempUuids.data(), templates.size(), &exception);
305 checkException(exception, *_dll_handle);
308 inline void DynamicTemplateIndex::remove(
const std::string& uuid)
310 void* exception =
nullptr;
312 _dll_handle->DynamicTemplateIndex_remove_1(_impl, uuid.data(), &exception);
314 checkException(exception, *_dll_handle);
317 inline void DynamicTemplateIndex::remove(
const std::vector<std::string>& uuids)
319 void* exception =
nullptr;
320 std::vector<const char*> data;
322 data.reserve(uuids.size());
324 std::transform(uuids.begin(), uuids.end(), std::back_inserter(data), [](
const std::string& uuid) {
return uuid.data(); });
326 _dll_handle->DynamicTemplateIndex_remove_2(_impl, data.data(), uuids.size(), &exception);
328 checkException(exception, *_dll_handle);
333 void* exception =
nullptr;
335 _dll_handle->DynamicTemplateIndex_concatenate(_impl, otherIndex->_impl, &exception);
337 checkException(exception, *_dll_handle);
340 inline void DynamicTemplateIndex::clear()
342 void* exception =
nullptr;
344 _dll_handle->DynamicTemplateIndex_clear(_impl, &exception);
346 checkException(exception, *_dll_handle);
349 inline void DynamicTemplateIndex::save(
const std::string& filePath,
bool allowOverwrite)
const
351 void* exception =
nullptr;
353 _dll_handle->DynamicTemplateIndex_save(_impl, filePath.data(), allowOverwrite, &exception);
355 checkException(exception, *_dll_handle);
358 inline DynamicTemplateIndex::~DynamicTemplateIndex()
362 _dll_handle->DynamicTemplateIndex_destructor(_impl);
size_t size() const
Получить количество шаблонов в индексе. Потокобезопасный.
Definition: DynamicTemplateIndex.h:173
LightSmartPtr< Template >::tPtr Ptr
Псевдоним для типа умного указателя на Template.
Definition: Template.h:46
Error - класс исключений, выбрасываемых при возникновении ошибок.
std::string getUUID(size_t index) const
Получить uuid i-го шаблона. Потокобезопасный.
Definition: DynamicTemplateIndex.h:200
Definition: SmartPtr.h:84
LightSmartPtr< DynamicTemplateIndex >::tPtr Ptr
Псевдоним для типа умного указателя на DynamicTemplateIndex.
Definition: DynamicTemplateIndex.h:34
std::string getMethodName() const
Получить имя метода. Потокобезопасный.
Definition: DynamicTemplateIndex.h:155
Context - интерфейсный объект для хранения данных и взаимодействия с методами из Processing Block API...
Definition: Context.h:48
LightSmartPtr< ContextTemplate >::tPtr Ptr
Псевдоним для типа умного указателя на ContextTemplate.
Definition: ContextTemplate.h:47
Интерфейсный объект для работы с индексом шаблонов.
Definition: DynamicTemplateIndex.h:26