67 #ifndef LIB_TYPED_ALLOCATION_MANAGER_H 68 #define LIB_TYPED_ALLOCATION_MANAGER_H 108 size_t numSlots()
const;
118 _TheManager* manager_;
122 operator() (XOX* victim)
126 manager_->destroyElement (victim);
166 Slot(_TheManager* don,
void* mem)
179 template<
class XX,
typename...ARGS>
181 create (ARGS&& ...args)
185 return slot.
build (
new(slot.
storage_) XX (std::forward<ARGS> (args)...) );
206 TRACE (memory,
"allocate «%s»", util::typeStr<XX>().c_str());
207 void* space =
new char[
sizeof(XX)];
214 releaseSlot (
void*
entry)
217 TRACE (memory,
"release «%s»", util::typeStr<XX>().c_str());
218 typedef char Storage[
sizeof(XX)];
219 delete[]
reinterpret_cast<Storage*
> (
entry);
226 destroyElement (XX* entry)
237 WARN (command_dbg,
"dtor of «%s» failed: %s", util::typeStr(entry).c_str()
240 releaseSlot<XX> (
entry);
255 TypedAllocationManager::numSlots()
const 257 return allocCnt_.get<XX>();
Creating series of type-based contexts.
Utility providing a set of counters, each tied to a specific type.
void *const storage_
pointer to the allocated storage with sizeof(XOX) bytes
AnyPair entry(Query< TY > const &query, typename WrapReturn< TY >::Wrapper &obj)
helper to simplify creating mock table entries, wrapped correctly
shared_ptr< XOX > build(XOX *toTrack)
build a refcounting smart-ptr, complete with back-link to the manager for de-allocation ...
This header is for including and configuring NoBug.
Implementation namespace for support and library code.
a token representing a newly opened slot capable for holding an object of type XOX ...
lumiera_err lumiera_error(void)
Get and clear current error state.
opaque link to the manager, to be used by handles and smart-ptrs to trigger preconfigured destruction...
Foundation for a custom allocation manager, tracking the created objects by smart-ptrs.
Lumiera error handling (C++ interface).