coral
A C++ library for distributed co-simulation
Public Member Functions | List of all members
coral::bus::VariablePublisher Class Reference

A class which handles publishing of variable values on the network. More...

#include "coral/bus/variable_io.hpp"

Public Member Functions

 VariablePublisher ()
 Default constructor. More...
 
void Bind (const coral::net::Endpoint &endpoint)
 Binds to a local endpoint. More...
 
coral::net::Endpoint BoundEndpoint () const
 Returns the endpoint bound to by the last Bind() call. More...
 
void Publish (coral::model::StepID stepID, coral::model::SlaveID slaveID, coral::model::VariableID variableID, coral::model::ScalarValue value)
 Publishes the value of a single variable. More...
 

Detailed Description

A class which handles publishing of variable values on the network.

Constructor & Destructor Documentation

coral::bus::VariablePublisher::VariablePublisher ( )

Default constructor.

Note that Bind() must be called before any variables may be published.

Member Function Documentation

void coral::bus::VariablePublisher::Bind ( const coral::net::Endpoint endpoint)

Binds to a local endpoint.

Parameters
[in]endpointThe endpoint, in the format tcp://<interface>:<port>, where "interface" may be "*" to signify all network interfaces, and "port" may be "*" to signify an OS-assigned (ephemeral) port.
Precondition
Bind() has not been called previously on this instance.
coral::net::Endpoint coral::bus::VariablePublisher::BoundEndpoint ( ) const

Returns the endpoint bound to by the last Bind() call.

This is useful when the port number was specified as '*', as this will return the actual port number as part of the endpoint address.

Precondition
Bind() has been called successfully on this instance.
void coral::bus::VariablePublisher::Publish ( coral::model::StepID  stepID,
coral::model::SlaveID  slaveID,
coral::model::VariableID  variableID,
coral::model::ScalarValue  value 
)

Publishes the value of a single variable.

While this is not enforced by the present function, the recipient (i.e., the VariableSubscriber) requires that all subscribed-to variables be published for any given time step, and that the time step ID never decreases.

Parameters
[in]stepIDTime step ID
[in]slaveIDSlave ID
[in]variableIDVariable ID (which is paired with the slave ID to form a "global" variable ID before sending)
[in]valueThe variable value
Precondition
Bind() has been called successfully on this instance.

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