/* * Copyright (c) 2025 Fraunhofer IESE. All rights reserved. * * Authors: * Iron Prando da Silva */ #include "poolcontroller.h" #include PoolController::PoolController(const uint poolSize, const std::vector& dependencies) : mDependencies(mAuxSortInput(dependencies)) { mPoolSize = poolSize; } void PoolController::clear() { mPool.clear(); mCount = 0; } void PoolController::push(DBDependencyEntry dep) { mPool.push_back(dep); mCount++; } void PoolController::increment() { mCount++; } void PoolController::merge(std::vector& depEntries) { if (mCount >= mPoolSize) { depEntries.insert(depEntries.end(), mPool.begin(), mPool.end()); } } uint PoolController::getBusyTime(const StringMapper& phaseName) { PoolEntry v{phaseName, 0}; auto entryIt = std::lower_bound(mDependencies.begin(), mDependencies.end(), v, [](const PoolEntry& e1, const PoolEntry& e2) { return e1.first < e2.first; }); if (entryIt->first == phaseName) { return entryIt->second; } else { return 0; } } std::vector PoolController::mAuxSortInput(std::vector vec) { std::sort(vec.begin(), vec.end(), [](const PoolEntry& e1, const PoolEntry& e2) { return e1.first < e2.first; }); return vec; }