| 343 | |
| 344 | template<typename T> |
| 345 | bool VolatileRepository<T>::DeSerialize(std::vector<std::shared_ptr<core::SerializableComponent>> &store, size_t &max_size, std::function<std::shared_ptr<core::SerializableComponent>()> lambda) { |
| 346 | size_t requested_batch = max_size; |
| 347 | max_size = 0; |
| 348 | for (auto ent : value_vector_) { |
| 349 | // let the destructor do the cleanup |
| 350 | RepoValue<T> repo_value; |
| 351 | |
| 352 | if (ent->getValue(repo_value)) { |
| 353 | std::shared_ptr<core::SerializableComponent> newComponent = lambda(); |
| 354 | // we've taken ownership of this repo value |
| 355 | newComponent->DeSerialize(repo_value.getBuffer(), repo_value.getBufferSize()); |
| 356 | |
| 357 | store.push_back(newComponent); |
| 358 | |
| 359 | current_size_ -= repo_value.getBufferSize(); |
| 360 | |
| 361 | if (max_size++ >= requested_batch) { |
| 362 | break; |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | if (max_size > 0) { |
| 367 | return true; |
| 368 | } else { |
| 369 | return false; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | template<typename T> |
| 374 | bool VolatileRepository<T>::DeSerialize(std::vector<std::shared_ptr<core::SerializableComponent>> &store, size_t &max_size) { |