WSF
WsfXIO_PublisherHelper Class Reference

#include <WsfXIO_PublisherHelper.hpp>

Public Types

typedef WsfXIO_PublishKey PublisherKey
typedef WsfXIO_Publisher::SubscriptionId SubscriptionId
typedef WsfXIO_PublishFilter SubscriptionFilter
typedef WsfXIO_Publisher::SubscribeCallback SubscriptionCallback
typedef std::map< SubscriptionId, WsfXIO_Publisher::SubscribeCallback * > Subscriptions

Public Member Functions

 WsfXIO_PublisherHelper (WsfXIO_Interface *aInterfacePtr, WsfSimulation &aSimulation)
virtual ~WsfXIO_PublisherHelper ()
void SetStateDirty (double aSimTime=-1.0)
void Publish (const PublisherKey &aKey, const std::string &aData)
bool GetPublishedData (const PublisherKey &aKey, std::string &aData) const
bool HasSubscription (const SubscriptionId &aSubscriptionId) const
SubscriptionId Subscribe (const SubscriptionFilter &aSubscriptionFilter, SubscriptionCallback *aSubscriptionCallbackPtr)
bool Unsubscribe (const SubscriptionId &aSubscriptionId)

Protected Member Functions

virtual void PublishState (double aSimTime)

Friends

class PublishEvent

Detailed Description

This is a helper class that simplifies the interface to the WsfXIO_Publisher class. It uses an std::string as the message type. It can be used as a base class for dynamic plugins that would like to use XIO as a communication mechanism. Simply derive from WsfXIO_PublisherHelper or create an instance of it. You can receive remote messages by subscribing with a filter and callback using 'Subscribe'. You can publish messages by calling 'Publish'. If this class doesn't meet your needs, you can use WsfXIO_Publisher directly.

Member Typedef Documentation

◆ PublisherKey

◆ SubscriptionCallback

◆ SubscriptionFilter

◆ SubscriptionId

◆ Subscriptions

Constructor & Destructor Documentation

◆ WsfXIO_PublisherHelper()

WsfXIO_PublisherHelper::WsfXIO_PublisherHelper ( WsfXIO_Interface * aInterfacePtr,
WsfSimulation & aSimulation )

◆ ~WsfXIO_PublisherHelper()

WsfXIO_PublisherHelper::~WsfXIO_PublisherHelper ( )
virtual

References Unsubscribe().

Member Function Documentation

◆ GetPublishedData()

bool WsfXIO_PublisherHelper::GetPublishedData ( const PublisherKey & aKey,
std::string & aData ) const

Retrieves the published data given a key.

Parameters
aKeyThe key to retrieve the data with.
aDataThe data that is returned by reference.
Returns
Returns 'true' if data was retrieved.

References WsfXIO_Publisher::GetData().

◆ HasSubscription()

bool WsfXIO_PublisherHelper::HasSubscription ( const SubscriptionId & aSubscriptionId) const

Check to see if a subscription already exists.

Parameters
aSubscriptionIdThe subscription id to check.
Returns
Returns 'true' if the subscription exists.

◆ Publish()

void WsfXIO_PublisherHelper::Publish ( const PublisherKey & aKey,
const std::string & aData )

Publish a message with the specified key.

Parameters
aKeyThe key to associate the message with.
aDataThe contents of the message.

References WsfXIO_Publisher::Publish().

◆ PublishState()

virtual void WsfXIO_PublisherHelper::PublishState ( double aSimTime)
inlineprotectedvirtual

Referenced by SetStateDirty().

◆ SetStateDirty()

void WsfXIO_PublisherHelper::SetStateDirty ( double aSimTime = -1.0)

References PublishState(), and simTime.

◆ Subscribe()

WsfXIO_PublisherHelper::SubscriptionId WsfXIO_PublisherHelper::Subscribe ( const SubscriptionFilter & aSubscriptionFilter,
SubscriptionCallback * aSubscriptionCallbackPtr )

Create a new subscription with the specified filter.

Parameters
aSubscriptionFilterThe filter to match against any published messages.
aSubscriptionCallbackPtrThe callback to trigger when a publication that matches the filter is received.
Returns
Returns the subscription id.
Note
You can use new UtCallbackN<R(Args...)> to simplify the creation of the callback.
This class manages the memory of the SubscriptionCallback.

References WsfXIO_Publisher::Subscribe().

◆ Unsubscribe()

bool WsfXIO_PublisherHelper::Unsubscribe ( const SubscriptionId & aSubscriptionId)

Cancel the specified subscription.

Parameters
aSubscriptionIdThe subscription id to cancel.
Returns
Returns 'true' if the subscription was canceled.

References WsfXIO_Publisher::Unsubscribe().

Referenced by ~WsfXIO_PublisherHelper().

◆ PublishEvent

friend class PublishEvent
friend

References PublishEvent.

Referenced by PublishEvent.


The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved