Struct Variable

Struct Documentation

struct Variable

Common variable definition type Used internally by AgentData and MessageData

Public Functions

template<typename T>
inline Variable(unsigned int _elements, const T)

Constructs a new variable

Note

Cannot explicitly specify template args of constructor, so we take redundant arg for implicit template

Note

This constructor does not set default value

Parameters
  • _elements – The number of elements, this will be 1 unless the variable is an array

  • TAny variable of the type for template argument T, the value of the variable is not used

Template Parameters

T – The type of the variable, it’s size and std::type_index are derived from this

template<typename T, std::size_t N>
inline explicit Variable(const std::array<T, N> &_default_value)

Constructs a new variable

Parameters

_default_value – The default value to be used for the variable

Template Parameters
  • T – The type of the variable, it’s size and std::type_index are derived from this

  • N – The number of elements, this will be 1 unless the variable is an array

template<typename T>
inline explicit Variable(const unsigned int &N, const std::vector<T> &_default_value)

Constructs a new variable

Parameters
  • _default_value – The default value to be used for the variable

  • N – The number of elements, this will be 1 unless the variable is an array

Template Parameters

T – The type of the variable, it’s size and std::type_index are derived from this

inline ~Variable()

Destructor, frees memory

inline Variable(const Variable &other)

Copy constructor

Public Members

const std::type_index type

Unique identifier of the variables type as returned by std::type_index(typeid())

const size_t type_size

Size of the type in bytes as returned by sizeof() (e.g. float == 4 bytes)

const unsigned int elements

The number of elements, this will be 1 unless the variable is an array

const std::unique_ptr<GenericMemoryVector> memory_vector

Holds the variables memory vector type so we can dynamically create them with clone()

void *const default_value

Default value for new agents