PdCom  5.0
Process data communication client
Public Member Functions | Friends | List of all members
PdCom::Variable Class Reference

PdCom Variable interface. More...

#include <Variable.h>

Public Member Functions

 Variable ()=default
 Constructs an empty variable.
 
template<typename T >
std::enable_if<!std::is_arithmetic< T >::value, bool >::type setValue (T const &data, size_t index=0) const
 Write to a variable. More...
 
template<typename T >
std::enable_if< std::is_arithmetic< T >::value, bool >::type setValue (T const &data, size_t index=0) const
 Write to a variable. More...
 
bool setValue (const void *src, TypeInfo::DataType src_type, size_t idx, size_t n) const
 Write to a variable. More...
 
const TypeInfogetTypeInfo () const noexcept
 Get details about the variable type. More...
 
const SizeInfogetSizeInfo () const noexcept
 Get details about the variable shape. More...
 
std::string getPath () const
 The Path of the variable. More...
 
std::string getName () const
 The name of the variable. More...
 
std::string getAlias () const
 The alias of the variable, if set. More...
 
int getTaskId () const
 The task id of the variable. More...
 
bool empty () const noexcept
 Checks whether this instance is empty. More...
 

Friends

class impl::Variable
 

Detailed Description

PdCom Variable interface.

This class represents a variable (signal or parameter). It contains information about the datatype and the shape of a variable.

If you default-construct a Variable instance, it does not contain any information. Calling any other member function than empty() is forbidden. To get a valid variable instance, call Process::find().

Examples:
advanced_example.cpp.

Member Function Documentation

◆ empty()

bool PdCom::Variable::empty ( ) const
inlinenoexcept

Checks whether this instance is empty.

Default-constructed variables are empty per default, calling any other member function than empty() will crash.

Returns
false if this instance is alive.
Examples:
advanced_example.cpp.

◆ getAlias()

std::string PdCom::Variable::getAlias ( ) const

The alias of the variable, if set.

The variable must not be empty!

Returns
the alias.

◆ getName()

std::string PdCom::Variable::getName ( ) const

The name of the variable.

The variable must not be empty!

Returns
the name, without the path components.

◆ getPath()

std::string PdCom::Variable::getPath ( ) const

The Path of the variable.

The variable must not be empty!

Returns
The full path.

◆ getSizeInfo()

const SizeInfo& PdCom::Variable::getSizeInfo ( ) const
noexcept

Get details about the variable shape.

The variable must not be empty!

Returns
Variable shape info.

◆ getTaskId()

int PdCom::Variable::getTaskId ( ) const

The task id of the variable.

The variable must not be empty!

Returns
the task id.

◆ getTypeInfo()

const TypeInfo& PdCom::Variable::getTypeInfo ( ) const
noexcept

Get details about the variable type.

The variable must not be empty!

Returns
Variable type info.

◆ setValue() [1/3]

template<typename T >
std::enable_if<!std::is_arithmetic<T>::value, bool>::type PdCom::Variable::setValue ( T const &  data,
size_t  index = 0 
) const
inline

Write to a variable.

This function is also asynchronous, so the server might still use the old value when this function returns. This overload is for any container of arithmetic types (e.g. std::vector<int>). The variable must not be empty!

T must be a container (must have a size() method and a value_type typedef).

Parameters
dataData.
indexOptional offset. No bounds checking!
Returns
false if the variable is read-only.
Examples:
advanced_example.cpp.

◆ setValue() [2/3]

template<typename T >
std::enable_if<std::is_arithmetic<T>::value, bool>::type PdCom::Variable::setValue ( T const &  data,
size_t  index = 0 
) const
inline

Write to a variable.

This function is also asynchronous, so the server might still use the old value when this function returns. This overload is for any arithmetic type (int, double, etc.). The variable must not be empty!

Parameters
dataData.
indexOptional offset. No bounds checking!
Returns
false if the variable is read-only.

◆ setValue() [3/3]

bool PdCom::Variable::setValue ( const void *  src,
TypeInfo::DataType  src_type,
size_t  idx,
size_t  n 
) const

Write to a variable.

This function is also asynchronous, so the server might still use the old value when this function returns. The variable must not be empty!

Parameters
srcPointer to one or more values.
src_typeType of the source.
idxOptional offset. No bounds checking!
nNumber of values.
Returns
false if the variable is read-only.

The documentation for this class was generated from the following file: