PdCom
5.3
Process data communication client
|
PdCom Subscription interface. More...
#include <Subscription.h>
Public Types | |
enum | State { Invalid = 0, Pending, Active } |
Public Member Functions | |
Subscription ()=default | |
Default constructor for an empty subscription. | |
Subscription (Subscription &&) noexcept | |
Subscription & | operator= (Subscription &&) noexcept |
Subscription (Subscriber &subscriber, const Variable &variable, const Selector &selector={}) | |
Constructor for a known variable. More... | |
Subscription (Subscriber &subscriber, Process &process, const std::string &path, const Selector &selector={}) | |
Constructor for an unknown variable. More... | |
void | poll () |
Poll values from the server. More... | |
const void * | getData () const |
Get the data Pointer. More... | |
Variable | getVariable () const |
Access the subscribed variable. More... | |
void | print (std::ostream &os, char delimiter) const |
Print the value(s). More... | |
bool | empty () const noexcept |
Check whether the subscription is default-constructed. More... | |
State | getState () const noexcept |
Get the current state. More... | |
Process * | getProcess () const |
Get the assigned Process. More... | |
std::string | getPath () const |
Get the path of the subscribed variable. More... | |
Public Member Functions inherited from PdCom::DataDeserializer< Subscription > | |
std::enable_if<!std::is_arithmetic< T >::value, void >::type | getValue (T &dest, size_t offset=0) const |
Copy the values into a custom buffer. More... | |
std::enable_if< std::is_arithmetic< T >::value, void >::type | getValue (T &dest, size_t offset=0) const |
Copy the values into a custom buffer. More... | |
void | getValue (T(&dest)[M][N]) const |
void | getValue (T(&dest)[N], size_t offset=0) const |
T | getValue () const |
PdCom Subscription interface.
This class represents a subscription to a variable. It is updated either on a periodic base, on an external event (e.g. the value has changed) or as requested with poll(). The type of transmission can be selected by creating an appropriate Subscriber object.
To cancel a subscription, you have to delete the corresponding subscription instance.
Calling getState() is always allowed, the other member functions need the subscription to be Active.
PdCom::Subscription::Subscription | ( | Subscriber & | subscriber, |
const Variable & | variable, | ||
const Selector & | selector = {} |
||
) |
Constructor for a known variable.
subscriber | Subscriber which will recieve the status updates. |
variable | The variable to subscribe. |
selector | Select parts of multi-dimensional variables. |
invalid_subscription | Subscription is already known to be invalid. |
PdCom::Subscription::Subscription | ( | Subscriber & | subscriber, |
Process & | process, | ||
const std::string & | path, | ||
const Selector & | selector = {} |
||
) |
Constructor for an unknown variable.
subscriber | Subscriber which will recieve the status updates. |
process | The process. |
path | Path of the variable to subscribe. |
selector | Select parts of multi-dimensional variables. |
invalid_subscription | Subscription is already known to be invalid. |
|
inlinenoexcept |
Check whether the subscription is default-constructed.
const void* PdCom::Subscription::getData | ( | ) | const |
Get the data Pointer.
The subscription has to be Active
.
std::string PdCom::Subscription::getPath | ( | ) | const |
Get the path of the subscribed variable.
This also works in Pending and Invalid state.
|
inlinenoexcept |
Variable PdCom::Subscription::getVariable | ( | ) | const |
Access the subscribed variable.
The subscription must not be empty().
void PdCom::Subscription::poll | ( | ) |
Poll values from the server.
The subscription has to be Active
.
void PdCom::Subscription::print | ( | std::ostream & | os, |
char | delimiter | ||
) | const |
Print the value(s).
os | Stream to print into. |
delimiter | Delimiter which separates the values. |