MemoryImage.hpp

A managed set of Bytes to store any kind of data.

Note

Status: ALPHA

class MemoryImage
#include <MemoryImage.hpp>

A helper class for DataMap; tracks a memory image (sequence of bytes).

Public Functions

MemoryImage() = default

Build a default MemoryImage with no initial memory.

inline MemoryImage(size_t in_size)

Build a memory image of a specific size (but uninitialized.)

inline ~MemoryImage()

Destruct a MemoryImage.

inline size_t GetSize() const
inline size_t GetInitSize() const
template<typename T = void>
inline Ptr<T> GetPtr(size_t pos)

Get a typed pointer to a specific position in this image.

template<typename T = void>
inline Ptr<const T> GetPtr(size_t pos) const
template<typename T>
inline T &Get(size_t pos)

Get proper references to an object represented in this image.

template<typename T>
inline const T &Get(size_t pos) const
template<typename T>
inline std::span<T> Get(size_t pos, size_t count)

Get proper spans to sets of same-type objects represented in this image.

template<typename T>
inline std::span<const T> Get(size_t pos, size_t count) const
inline void RawResize(size_t new_size)

Change the size of this memory. Assume all cleanup and setup is done elsewhere.

inline void RawCopy(const MemoryImage &from_memory)

Copy all of the bytes directly from another memory image. Size manipulation must be done beforehand to ensure sufficient space is available.

inline void RawMove(MemoryImage &from_memory)

Steal the memory from the image passed in. Current memory should have been cleaned up and set to null already.

template<typename T, typename ...ARGS>
inline void Construct(size_t id, ARGS&&... args)

Build a new object of the provided type at the memory position indicated.

template<typename T>
inline void Destruct(size_t id)

Destruct an object of provided type at memory position indicated; don’t release memory!

template<typename T>
inline void CopyObj(size_t id, const MemoryImage &from_image)

Copy an object from another MemoryImage with an identical DataLayout.

template<typename T>
inline void MoveObj(size_t id, MemoryImage &from_image)

Move an object from another MemoryImage with an identical DataLayout.

Private Functions

inline void Fuzz()

Private Members

Ptr<std::byte> image = nullptr

Current memory image.

size_t size = 0

Size of current image.

size_t init_to = 0

How far of the current image is initialized?

Friends

friend class DataLayout