58 #ifndef LIB_TYPED_ALLOCATION_MANAGER_H 59 #define LIB_TYPED_ALLOCATION_MANAGER_H 99 size_t numSlots()
const;
109 _TheManager* manager_;
113 operator() (XOX* victim)
117 manager_->destroyElement (victim);
157 Slot(_TheManager* don,
void* mem)
170 template<
class XX,
typename...ARGS>
172 create (ARGS&& ...args)
176 return slot.
build (
new(slot.
storage_) XX (std::forward<ARGS> (args)...) );
197 TRACE (memory,
"allocate «%s»", util::typeStr<XX>().c_str());
198 void* space =
new char[
sizeof(XX)];
205 releaseSlot (
void*
entry)
208 TRACE (memory,
"release «%s»", util::typeStr<XX>().c_str());
209 typedef char Storage[
sizeof(XX)];
210 delete[]
reinterpret_cast<Storage*
> (
entry);
217 destroyElement (XX* entry)
228 WARN (command_dbg,
"dtor of «%s» failed: %s", util::typeStr(entry).c_str()
231 releaseSlot<XX> (
entry);
246 TypedAllocationManager::numSlots()
const 248 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).