PdCom  4.2
Process data communication client
Public Member Functions | Public Attributes | List of all members
PdCom::Variable::Subscription Class Referenceabstract

Subscription class. More...

#include <Variable.h>

Public Member Functions

 Subscription (Process *process, int id, const Variable *v, int decimation, const uint64_t *const *time, const char *const *data)
 Constructor.
 
virtual void cancel () const =0
 Cancel subscription. More...
 
bool poll () const
 Poll a subscription. More...
 
template<typename T >
void getValue (T *val, size_t index, size_t nelem) const
 Retrieve subscriptions value in any data type. More...
 
std::string getStringValue (char delimiter=',') const
 Get the entire value as a linear string. More...
 
void print (std::ostream &os, char delimiter) const
 Write the value to std::ostream. More...
 

Public Attributes

Process *const process
 pointer to process
 
const int id
 id supplied during Process::subscribe()
 
const Variable *const variable
 Actual variable.
 
const int decimation
 Subscription decimation.
 
const uint64_t *const *const time_ns
 Time of value in nanoseconds since epoch. More...
 

Detailed Description

Subscription class.

The library passes on this class to Subscriber as a result of a successful variable subscribe().

This class is used to query various properties of the Subscription as well as a method to get the variable's value in any data type by calling getValue(), getStringValue() and print().

The value of a subscription is always accessible (doesn't SEGV), but it is not always sensible to call it outside of Subscriber::newValue() or Subscriber::newGroupValue().

To cancel a subscription, issue cancel() on it. cancel() is safe from within newValue() or newGroupValue().

Signals that are subscribed with an intermittent interval < 0 are only updated after issuing poll().

Examples:
example.cpp.

Member Function Documentation

◆ cancel()

virtual void PdCom::Variable::Subscription::cancel ( ) const
pure virtual

Cancel subscription.

Calling cancel() is safe from within Subscriber::newValue() and Subscriber::newGroupValue().

◆ getStringValue()

std::string PdCom::Variable::Subscription::getStringValue ( char  delimiter = ',') const

Get the entire value as a linear string.

Parameters
delimiterdelimiter between vector elements
Examples:
example.cpp.

◆ getValue()

template<typename T >
void PdCom::Variable::Subscription::getValue ( T *  val,
size_t  index,
size_t  nelem 
) const

Retrieve subscriptions value in any data type.

Parameters
valvalue buffer to write to. Must be at least nelem long
indexstarting index
nelemnumber of elements to retrieve

◆ poll()

bool PdCom::Variable::Subscription::poll ( ) const

Poll a subscription.

This is only available for signals when request interval < 0, otherwise an error value is returned.

The value is available during Subscriber::newValue().

Returns
true on failure

◆ print()

void PdCom::Variable::Subscription::print ( std::ostream &  os,
char  delimiter 
) const

Write the value to std::ostream.

This allows the user finer control of double variables.

Parameters
osstd::ostream output stream
delimiterdelimiter between vector elements

Member Data Documentation

◆ time_ns

const uint64_t* const* const PdCom::Variable::Subscription::time_ns

Time of value in nanoseconds since epoch.

Use double dereferencing to access the value, eg.

double time = 1.0e-9 * **subscription->time_ns;
Examples:
example.cpp.

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