31#ifndef SRC_VAULT_MEM_EXTENT_FAMILY_H_
32#define SRC_VAULT_MEM_EXTENT_FAMILY_H_
57 template<
typename T,
size_t siz>
70 template<
typename T,
size_t siz>
85 using SIZ = std::integral_constant<size_t,siz>;
110 auto* rawStorage = this->get();
111 ENSURE (rawStorage !=
nullptr);
112 return static_cast<Extent&
> (rawStorage->array());
164 if (
index >= prevStart)
181 size_t prevIdx =
index;
187 while (
index != prevIdx);
189 throw err::Logic {
"Unable to fix-up an iterator after Extent allocation. "
190 "Reference position obsolete or unknown to the memory manager."};
212 extents_.reserve (expectedMaxExtents);
237 auto mid = p + oldSiz;
238 auto last = p + oldSiz + addSiz;
240 std::rotate (first, mid,
last);
278 REQUIRE (not
empty());
348 return address ==
extents_[idx].get();
355 return unConst(
this)->extents_[idx].access();
361 size_t resultSiz =
slotCnt()+addCnt;
362 size_t requiredSpace = resultSiz *
sizeof(
Extent);
363 if (requiredSpace > ALLOC_SAFETY_LIMIT)
364 throw err::Fatal{
"Raw allocation exceeds safety limit: "
367 ,err::LUMIERA_ERROR_CAPACITY};
383 template<
typename T,
size_t siz>
396 template<
typename T,
size_t siz>
397 inline ExtentDiagnostic<T,siz>
Decorator-Adapter to make a »*State Core*« iterable as Lumiera Forward Iterator.
Derived specific exceptions within Lumiera's exception hierarchy.
Any copy and copy construction prohibited.
ExtentFamily< T, siz > ExFam
Memory manager to provide a sequence of Extents for cyclic usage.
size_t incWrap(size_t idx, size_t inc=1)
increment index, but wrap at array end.
size_t activeSlotCnt() const
friend iterator end(ExtentFamily &exFam)
static const size_t EXCESS_ALLOC
number of excess new extents to add whenever new storage is required
iterator last()
positioned to the last / latest storage extent opened
friend iterator begin(ExtentFamily &exFam)
void openNew(size_t cnt=1)
claim next cnt extents, possibly allocate.
bool matchPos(size_t idx, void *address)
void dropOld(size_t cnt)
discard oldest cnt extents
void reserve(size_t expectedMaxExtents)
size_t freeSlotCnt() const
Extent & access(size_t idx) const
std::unique_ptr< lib::UninitialisedStorage< T, siz > > _UniqueStoragePtr
bool isValidPos(size_t idx) const
iterator begin()
iterate over all the currently active Extents
std::vector< Storage > Extents
ExtentFamily(size_t initialCnt=1)
lib::IterableDecorator< IdxLink > iterator
allow transparent iteration of Extents, with the ability to expand storage
void ___sanityCheckAllocSize(size_t addCnt)
bool canAccomodate(size_t addCnt) const
Helper template(s) for creating Lumiera Forward Iterators.
Implementation namespace for support and library code.
LumieraError< LERR_(LOGIC)> Logic
string showSize(size_t val) noexcept
OBJ * unConst(const OBJ *)
shortcut to save some typing when having to define const and non-const variants of member functions
const size_t ALLOC_SAFETY_LIMIT
ExtentDiagnostic< T, siz > watch(ExtentFamily< T, siz > &extentFamily)
Vault-Layer implementation namespace root.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
logical structure of a memory Extent
std::integral_constant< size_t, siz > SIZ
Iteration »State Core« based on Extents index position.
void expandAlloc(size_t cnt=1)
bool operator==(IdxLink const &oi) const
void validatePos(Extent *knownTarget)
Ensure this iterator is still in-sync with expected target position; attempt to re-establish proper s...
Entry in the Extents management datastructure.
Extent & access()
access projected Extent storage type
A raw memory block with proper alignment and array access.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Basic set of definitions and includes commonly used together (Vault).