LibraryLink Utilities  3.0.1
Modern C++ wrapper over LibraryLink and WSTP
LLU::PrimitiveWrapper< T > Class Template Reference

Description

template<MArgumentType T>
class LLU::PrimitiveWrapper< T >

Small class that wraps a reference to MArgument and provides proper API to work with this MArgument.

Template Parameters
T- any value of type MArgumentType

#include <MArgument.h>

Public Types

using value_type = Argument::CType< T >
 This is the actual type of data stored in arg. More...
 

Public Member Functions

 PrimitiveWrapper (MArgument &a)
 Construct PrimitiveWrapper from a reference to MArgument. More...
 
value_typeget ()
 Get the value stored in MArgument. More...
 
const value_typeget () const
 Get the read-only value stored in MArgument. More...
 
value_typegetAddress () const
 Get address of the value stored in MArgument. More...
 
void set (value_type newValue)
 Set new value of type T in MArgument. More...
 
void addToDataStore (DataStore ds, const std::string &name, MArgumentType actualType=T) const
 Add arg to the DataStore ds inside a node named name The optional parameter should only be used by explicit specialization of this function for T equal to MArgumentType::MArgument. More...
 

Static Public Member Functions

static void addDataStoreNode (DataStore ds, std::string_view name, value_type val)
 Add val to the DataStore ds inside a node named name This is a static method because there is no MArgument involved. More...
 
static void addDataStoreNode (DataStore ds, value_type val)
 Add val to the DataStore ds inside an unnamed node This is a static method because there is no MArgument involved. More...
 

Type aliases documentation

◆ value_type

template<MArgumentType T>
using LLU::PrimitiveWrapper< T >::value_type = Argument::CType<T>

This is the actual type of data stored in arg.

Constructor & Destructor Documentation

◆ PrimitiveWrapper()

template<MArgumentType T>
LLU::PrimitiveWrapper< T >::PrimitiveWrapper ( MArgument &  a)
inlineexplicit

Construct PrimitiveWrapper from a reference to MArgument.

Parameters
a- reference to MArgument

Member Function Documentation

◆ addDataStoreNode() [1/2]

template<MArgumentType T>
static void LLU::PrimitiveWrapper< T >::addDataStoreNode ( DataStore  ds,
std::string_view  name,
value_type  val 
)
static

Add val to the DataStore ds inside a node named name This is a static method because there is no MArgument involved.

Parameters
ds- DataStore with values of type T
name- name for the new node in the DataStore
val- value of the new node in the DataStore

◆ addDataStoreNode() [2/2]

template<MArgumentType T>
static void LLU::PrimitiveWrapper< T >::addDataStoreNode ( DataStore  ds,
value_type  val 
)
static

Add val to the DataStore ds inside an unnamed node This is a static method because there is no MArgument involved.

Parameters
ds- DataStore with values of type T
val- value of the new node in the DataStore

◆ addToDataStore()

template<MArgumentType T>
void LLU::PrimitiveWrapper< T >::addToDataStore ( DataStore  ds,
const std::string &  name,
MArgumentType  actualType = T 
) const

Add arg to the DataStore ds inside a node named name The optional parameter should only be used by explicit specialization of this function for T equal to MArgumentType::MArgument.

Parameters
ds- DataStore with values of type T
name- name for the new node in the DataStore
actualType- actual type of the value stored, it is always T except in generic case where T is MArgumentType::MArgument

◆ get() [1/2]

template<MArgumentType T>
value_type& LLU::PrimitiveWrapper< T >::get ( )

Get the value stored in MArgument.

Returns
Reference to the value stored in MArgument

◆ get() [2/2]

template<MArgumentType T>
const value_type& LLU::PrimitiveWrapper< T >::get ( ) const

Get the read-only value stored in MArgument.

Returns
Const reference to the value stored in MArgument

◆ getAddress()

template<MArgumentType T>
value_type* LLU::PrimitiveWrapper< T >::getAddress ( ) const

Get address of the value stored in MArgument.

Every MArgument actually stores a pointer.

Returns
Pointer to the value stored in MArgument

◆ set()

template<MArgumentType T>
void LLU::PrimitiveWrapper< T >::set ( value_type  newValue)

Set new value of type T in MArgument.

Memory management is entirely user's responsibility.

Parameters
newValue- new value to be written to MArgument arg