DataLayout.hpp

A mapping of names to variables stored in a MemoryImage.

Note

Status: ALPHA

class DataLayout
#include <DataLayout.hpp>

A helper class for DataMap; tracks how data is organized in a MemoryImage.

Public Functions

DataLayout() = default
inline DataLayout(const DataLayout &_in)
inline ~DataLayout()
DataLayout &operator=(const DataLayout&) = delete
DataLayout &operator=(DataLayout&&) = delete
inline void IncMaps()
inline void DecMaps()
inline size_t GetNumMaps() const
inline bool IsLocked() const
inline bool HasName(const std::string &name) const

Determine if we have a variable by a given name.

inline bool HasID(size_t id) const

Determine if we have an ID.

template<typename T>
inline bool IsType(size_t id) const

Determine if we have the correct type of a specific variable ID.

template<typename T>
inline bool Has(size_t id, size_t count = 1) const
template<typename T>
inline bool Has(const std::string &name, size_t count = 1) const
template<typename T, typename KEY_T>
inline std::string DiagnoseHas(KEY_T key, size_t count = 1) const
inline size_t GetImageSize() const

Return the number of bytes in the default image.

inline size_t GetID(const std::string &name) const

Lookup the unique idea for an entry.

inline TypeID GetType(size_t id) const

Lookup the type of an entry by ID.

inline size_t GetCount(size_t id) const
inline bool IsNumeric(size_t id) const

Determine is entry is some form of numeric type.

inline bool IsNumeric(const std::string &name) const
inline void Lock()

Prevent this layout from being modified.

template<typename T>
inline size_t Add(MemoryImage &base_memory, const std::string &name, const T &default_value, const std::string &desc = "", const std::string &notes = "", const size_t count = 1)

Add a new variable with a specified type, name and value.

inline void DestructImage(MemoryImage &image) const

Run destructors on all objects in a memory image (but otherwise leave it intact.)

inline void ClearImage(MemoryImage &image) const

Destruct and delete all memory associated in the provided image.

inline void CopyImage(const MemoryImage &from_image, MemoryImage &to_image) const
inline void MoveImageContents(MemoryImage &from_image, MemoryImage &to_image) const

Protected Types

using copy_fun_t = std::function<void(const MemoryImage&, MemoryImage&)>

Collect all of the constructors and destructors that we need to worry about.

using move_fun_t = std::function<void(MemoryImage&, MemoryImage&)>
using destruct_fun_t = std::function<void(MemoryImage&)>

Protected Attributes

std::unordered_map<std::string, size_t> id_map

Lookup vector positions by name.

std::unordered_map<size_t, SettingInfo> setting_map

Lookup setting info by id.

size_t image_size

What size image is expected?

size_t num_maps = 1

How many DataMaps use this layout?

bool is_locked = false

Can this layout still be modified?

vector<copy_fun_t> copy_constructors
vector<move_fun_t> move_constructors
vector<destruct_fun_t> destructors
struct SettingInfo
#include <DataLayout.hpp>

Public Members

TypeID type

Type name as converted to string by typeid()

std::string name

Name of this setting.

std::string desc

Full description of this setting.

std::string notes

Any additional notes about this setting.

size_t count

Number of objects in this entry.

bool is_log

Is this setting a current value or a log of all values?