#include "TaskInjectStorage.h" #include #include #include "Storage.h" #include "StorageProvider.h" TaskInjectStorage::TaskInjectStorage( std::shared_ptr storageProvider, std::weak_ptr target ) : m_storageProvider(storageProvider) , m_target(target) { } void TaskInjectStorage::doEnter(std::shared_ptr blackboard) { } Task::TaskState TaskInjectStorage::doUpdate(std::shared_ptr blackboard) { if (m_storageProvider->getStorageCount() > 0) { std::shared_ptr source = m_storageProvider->consumeLargestStorage(); if (source) { if (std::shared_ptr target = m_target.lock()) { target->inject(source.get()); return STATE_SUCCESS; } } } else { std::this_thread::sleep_for(std::chrono::milliseconds(25)); } return STATE_FAILURE; } void TaskInjectStorage::doExit(std::shared_ptr blackboard) { } void TaskInjectStorage::doReset(std::shared_ptr blackboard) { }