F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
MemAllocator.hpp
Go to the documentation of this file.
1 
16 #ifndef TYPES_MEMALLOCATOR_HPP_
17 #define TYPES_MEMALLOCATOR_HPP_
18 
19 #include <Fw/FPrimeBasicTypes.hpp>
21 #include <cstddef>
22 
23 namespace Fw {
24 
46 class MemAllocator {
47  public:
63  virtual void* allocate(const FwEnumStoreType identifier,
64  FwSizeType& size,
65  bool& recoverable,
66  FwSizeType alignment = alignof(std::max_align_t)) = 0;
67 
75  virtual void deallocate(const FwEnumStoreType identifier, void* ptr) = 0;
76 
87  void* allocate(const FwEnumStoreType identifier,
88  FwSizeType& size,
89  FwSizeType alignment = alignof(std::max_align_t));
90 
103  void* checkedAllocate(const FwEnumStoreType identifier,
104  FwSizeType& size,
105  bool& recoverable,
106  FwSizeType alignment = alignof(std::max_align_t));
107 
121  void* checkedAllocate(const FwEnumStoreType identifier,
122  FwSizeType& size,
123  FwSizeType alignment = alignof(std::max_align_t));
124 
125  protected:
126  MemAllocator();
127  virtual ~MemAllocator();
128 
129  private:
132 };
133 
135  public:
136  // Constructor which will register itself as the singleton
138  ~MemAllocatorRegistry() = default;
139 
144 
154 
162 
170 
171  private:
174 
176  static MemAllocatorRegistry* s_registry;
177 };
178 } /* namespace Fw */
179 
180 #endif /* TYPES_MEMALLOCATOR_HPP_ */
virtual void * allocate(const FwEnumStoreType identifier, FwSizeType &size, bool &recoverable, FwSizeType alignment=alignof(std::max_align_t))=0
PlatformSizeType FwSizeType
I32 FwEnumStoreType
virtual ~MemAllocator()
static MemAllocatorRegistry & getInstance()
get the singleton registry
MemAllocator & getAnAllocator(const MemoryAllocation::MemoryAllocatorType type)
void * checkedAllocate(const FwEnumStoreType identifier, FwSizeType &size, bool &recoverable, FwSizeType alignment=alignof(std::max_align_t))
Memory Allocation base class.
MemAllocator & getAllocator(const MemoryAllocation::MemoryAllocatorType type)
virtual void deallocate(const FwEnumStoreType identifier, void *ptr)=0
Implementation of malloc based allocator.
void registerAllocator(const MemoryAllocation::MemoryAllocatorType type, MemAllocator &allocator)
register an allocator for the given type