20 #ifndef HEDGEHOG_STATIC_MEMORY_MANAGER_H 21 #define HEDGEHOG_STATIC_MEMORY_MANAGER_H 23 #include "abstract_memory_manager.h" 82 template<
class ManagedMemory,
class... Args>
93 template<
class TestManagedMemory,
class... TestArgs>
94 static std::true_type
test(
95 decltype(
new TestManagedMemory((std::declval<TestArgs>())...)));
101 template<
class TestManagedMemory,
class ...TestArgs>
102 static std::false_type
test(...);
105 enum { value = std::is_same_v<decltype(test<ManagedMemory, Args...>(0)), std::true_type> };
108 static_assert(HasConstructor::value,
109 "The Memory that you are trying to manage does not have the right constructor definition.");
135 initialize(std::make_index_sequence<
sizeof...(Args)>());
142 std::shared_ptr<AbstractMemoryManager < ManagedMemory>>
copy()
override {
149 template<
size_t... Is>
152 this->
pool()->begin(), this->
pool()->end(),
153 [
this](std::shared_ptr<ManagedMemory> &emptyShared) {
154 emptyShared = std::make_shared<ManagedMemory>(std::get<Is>(
args_)...);
155 emptyShared->memoryManager(
this);
162 #endif //HEDGEHOG_STATIC_MEMORY_MANAGER_H Derived class from AbstractMemoryManager for statically allocated MemoryData, used for example for GP...
static std::true_type test(decltype(new TestManagedMemory((std::declval< TestArgs >())...)))
True test, testing if a constructor with the right parameters exist and can be called.
std::shared_ptr< AbstractMemoryManager< ManagedMemory > > copy() override
Copy method used for task duplication and execution pipeline.
Abstract interface for Hedgehog's Memory manager.
bool isInitialized() const
Initialized flag accessor.
StaticMemoryManager()=delete
Deleted default constructor.
virtual void initializeMemoryManager()
User-definable initialization step for a memory manager.
void initialized()
Flag the memory manager has initialized.
size_t capacity() const
Capacity accessor.
void initialize(std::index_sequence< Is... >)
Private initialize method to call a specific constructor for the type.
SFINAE construct to test if ManagedMemory has a constructor with Args... as parameter.
void initialize() final
Initialize method, calling the private initialize method with the pack arguments, and the user defina...
std::tuple< Args... > args_
Values to pass to the constructor.
StaticMemoryManager(StaticMemoryManager< ManagedMemory, Args... > &rhs)
Copy constructor used by the copy method.
StaticMemoryManager(size_t const &capacity, Args ... args)
Constructor to use defining the pool capacity and the arguments to give the type constructor.
std::unique_ptr< behavior::Pool< ManagedMemory > > const & pool() const
Inside pool accessor.
std::mutex & memoryManagerMutex()
User api mutex accessor.