Template Class Var_T#

Inheritance Relationships#

Base Type#

Class Documentation#

template<typename T>
class Var_T : public Karana::Core::Var#

Templated Var class.

Template Parameters:

T – The type of data the Var holds.

Public Functions

inline Var_T(std::string_view name, const Var_T<T> &other, std::string_view description)#

Rename Var_T constructor for Var_T<T>. The constructor is not meant to be called directly. Please use the corresponding create(…) method instead to create an instance.

Parameters:
  • name – The name of the Var_T<T>

  • other – The Var_T<T> to copy the callable and quantity from.

  • description – A description of the Var.

template<class F>
inline Var_T(std::string_view name, const F &f, int vector_size, std::string_view description, std::string_view quantity = "")#

Var_T constructor for Var_T<km::Vec>. The constructor is not meant to be called directly. Please use the corresponding create(…) method instead to create an instance.

Template Parameters:

F – Templated callable type that produces km::Vec.

Parameters:
  • name – The name of the Var_T<km::Vec>

  • f – The callable that produces km::Vec.

  • vector_size – The size of the km::Vec that the callable produces. This must always be the same size.

  • description – A description of the Var.

  • quantity – The quantity of the Var.

template<class F>
inline Var_T(std::string_view name, const F &f, int vector_size, std::string_view description, std::string_view quantity = "")

Var_T constructor for Var_T<km::VecInt>. The constructor is not meant to be called directly. Please use the corresponding create(…) method instead to create an instance.

Template Parameters:

F – Templated callable type that produces km::VecInt.

Parameters:
  • name – The name of the Var_T<km::VecInt>

  • f – The callable that produces km::VecInt.

  • vector_size – The size of the km::VecInt that the callable produces. This must always be the same size.

  • description – A description of the Var.

  • quantity – The quantity of the Var.

template<class F>
inline Var_T(std::string_view name, const F &f, int matrix_rows, int matrix_cols, std::string_view description, std::string_view quantity = "")#

Var_T constructor for Var_T<km::Mat>. The constructor is not meant to be called directly. Please use the corresponding create(…) method instead to create an instance.

Template Parameters:

F – Templated callable type that produces km::Mat.

Parameters:
  • name – The name of the Var_T<km::Mat>

  • f – The callable that produces km::Mat.

  • matrix_rows – The number of rows in the km::Mat that the callable produces. The matrix that the callable produces must always be the same size.

  • matrix_cols – The number of cols in the km::Mat that the callable produces. The matrix that the callable produces must always be the same size.

  • description – A description of the Var.

  • quantity – The quantity of the Var.

template<class F>
inline Var_T(std::string_view name, const F &f, std::string_view description, std::string_view quantity = "")#

Var_T constructor for Var_T<T>. The constructor is not meant to be called directly. Please use the corresponding create(…) method instead to create an instance.

Template Parameters:

F – Templated callable type that produces type T.

Parameters:
  • name – The name of the Var_T<T>

  • f – The callable that produces type T.

  • description – A description of the Var.

  • quantity – The quantity of the Var.

inline T operator()() const#

Return the value that the Var contains.

Returns:

The value that the Var contains.

inline std::function<T()> getPlottingFunction() const#

Return the plotting function associated with this Var.

Returns:

The plotting function associated with this Var.

inline std::function<void(char*)> getLoggingFunction() const#

Return the logging function associated with this Var.

Returns:

The logging function associated with this Var.

inline size_t getSize() const#

Get the size in bytes for this Var.

Returns:

The size in bytes for this Var.

inline int getVectorSize() const#

Get the size of the vector that this Var holds.

Returns:

The size of the vector that this Var holds.

inline const std::pair<int, int> &getMatrixSize() const#

Get the size of the matrix that this Var holds.

Returns:

The size of the matrix that this Var holds.

inline virtual std::string dumpString(std::string_view prefix) const override#

Get the value this Var holds as a string.

Parameters:

prefix – The prefix to put in front of each output line.

Returns:

The string representation of this Var.

inline virtual VarType getType() const override#

Get the VarType for this Var.

Returns:

The VarType for this Var.

Public Static Functions

template<class F>
static inline Karana::Core::ks_ptr<Var_T> create(std::string_view name, const F &f, int vector_size, std::string_view description, std::string_view quantity = "")#

Create a new instance of Var_T<km::Vec>.

Template Parameters:

F – Templated callable type that produces km::Vec.

Parameters:
  • name – The name of the new Var_T<km::Vec>

  • f – The callable that produces km::Vec.

  • vector_size – The size of the km::Vec that the callable produces. This must always be the same size.

  • description – A description of the Var.

  • quantity – The quantity of the Var.

Returns:

The newly created instance of Var_T<km::Vec>.

template<class F>
static inline Karana::Core::ks_ptr<Var_T> create(std::string_view name, const F &f, int vector_size, std::string_view description, std::string_view quantity = "")

Create a new instance of Var_T<km::VecInt>.

Template Parameters:

F – Templated callable type that produces km::VecInt.

Parameters:
  • name – The name of the new Var_T<km::VecInt>

  • f – The callable that produces km::VecInt.

  • vector_size – The size of the km::VecInt that the callable produces. This must always be the same size.

  • description – A description of the Var.

  • quantity – The quantity of the Var.

Returns:

The newly created instance of Var_T<km::VecInt>.

template<class F>
static inline Karana::Core::ks_ptr<Var_T> create(std::string_view name, const F &f, int matrix_rows, int matrix_cols, std::string_view description, std::string_view quantity = "")#

Create a new instance of Var_T<km::Mat>.

Template Parameters:

F – Templated callable type that produces km::Mat.

Parameters:
  • name – The name of the Var_T<km::Mat>

  • f – The callable that produces km::Mat.

  • matrix_rows – The number of rows in the km::Mat that the callable produces. The matrix that the callable produces must always be the same size.

  • matrix_cols – The number of cols in the km::Mat that the callable produces. The matrix that the callable produces must always be the same size.

  • description – A description of the Var.

  • quantity – The quantity of the Var.

Returns:

The newly created instance of Var_T<km::Mat>.

template<class F>
static inline Karana::Core::ks_ptr<Var_T> create(std::string_view name, const F &f, std::string_view description, std::string_view quantity = "")#

Create a new instance of Var_T<T>.

Template Parameters:

F – Templated callable type that produces type T.

Parameters:
  • name – The name of the Var_T<T>

  • f – The callable that produces type T.

  • description – A description of the Var.

  • quantity – The quantity of the Var.

Returns:

The newly created instance of Var_T<T>.

static inline Karana::Core::ks_ptr<Var_T<T>> create(std::string_view name, const Karana::Core::ks_ptr<Var_T<T>> &other, std::string_view description)#

Rename Var_T constructor.

This constructor keeps the same function, size, etc., but takes a new name and description.

Parameters:
  • name – The name of the Var_T<T>

  • other – The Var_T<T> to copy the callable and quantity from.

  • description – A description of the Var.

Returns:

The newly created instance of Var_T<T>.

Protected Attributes

std::function<T()> _fn#

The function used to produce the value for the Var.

VarType _type#

The VarType for this Var.

std::function<void(char *buf)> _logging_fn#

The logging function associated with the Var.

This takes runs the _fn, converts it to bytes, and copies the bytes into the provided buffer.

size_t _size#

The size in bytes for this Var.

int _vector_size = 0#

The vector size for Var_T<km::Vec>.

std::pair<int, int> _matrix_size = {0, 0}#

The matrix size for Var_T<km::Mat>.