|
WSF
|
WsfXIO_Publisher Provides a basic Publish/Subscribe mechanism. More...
#include <WsfXIO_Publisher.hpp>
Public Types | |
| using | SubscriptionId = GenUniqueId |
| using | SubscribeCallbackList = UtCallbackListN<void(const WsfXIO_PublishKey&)> |
| using | SubscribeCallback = SubscribeCallbackList::CallbackType |
Public Member Functions | |
| WsfXIO_Publisher (WsfXIO_Interface *aInterfacePtr) | |
| void | Unpublish (const WsfXIO_PublishKey &aKey) |
| Remove a previously published publication. | |
| template<typename T> | |
| void | Publish (const WsfXIO_PublishKey &aKey, const T &aData) |
| Publish some data using a key. | |
| bool | Unsubscribe (const SubscriptionId &aSubscriptionId) |
| SubscribeCallback * | Subscribe (const WsfXIO_PublishFilter &aFilter, SubscribeCallback *aCallbackPtr) |
| SubscribeCallback * | Subscribe (SubscriptionId &aSubscriptionId, const WsfXIO_PublishFilter &aFilter, SubscribeCallback *aCallbackPtr) |
| template<typename C> | |
| std::unique_ptr< SubscribeCallback > | Subscribe (const WsfXIO_PublishFilter &aFilter, MemberFnPtr< C > aMethodPtr, C *aThisPtr) |
| template<typename C> | |
| std::unique_ptr< SubscribeCallback > | Subscribe (SubscriptionId &aSubscriptionId, const WsfXIO_PublishFilter &aFilter, MemberFnPtr< C > aMethodPtr, C *aThisPtr) |
| std::unique_ptr< SubscribeCallback > | Subscribe (const WsfXIO_PublishFilter &aFilter, NonMemberFnPtr aFunctionPtr) |
| std::unique_ptr< SubscribeCallback > | Subscribe (SubscriptionId &aSubscriptionId, const WsfXIO_PublishFilter &aFilter, NonMemberFnPtr aFunctionPtr) |
| std::unique_ptr< SubscribeCallback > | Subscribe (const WsfXIO_PublishFilter &aFilter, const SubscribeCallback::FunctionType &aFunc) |
| std::unique_ptr< SubscribeCallback > | Subscribe (SubscriptionId &aSubscriptionId, const WsfXIO_PublishFilter &aFilter, const SubscribeCallback::FunctionType &aFunc) |
| template<typename T> | |
| bool | GetData (const WsfXIO_PublishKey aKey, T &aData) |
| void | SetDebugLevel (int aDebugLevel) |
WsfXIO_Publisher Provides a basic Publish/Subscribe mechanism.
Example:
WsfTrack someTrack; WsfXIO_Publisher& publisher = xioInterface->GetPublisher();
publish someTrack using this data as a key Keys can have up to 4 fields – each being a string or an integer. WsfXIO_PublishKey key("my_data", "track-data", 54);
Any datatype may be published as long as it can be serialized. Some examples of valid data are: int, double, WsfTrack, or std::vector<std::pair<int, WsfTrackId> > Publish() may be called subsequent times to update the data publisher.Publish(key, someTrack);
...
subscribe to publications with keys containing this data, "*" is a wildcard: Publications can be received from any connected application WsfXIO_PublishFilter keyFilter("my_data", "track-data", "*"); A Callback is invoked when a publication is received publisher.Subscribe(keyFilter, RecvTrackSubscription);
...
This is called when a publication is received void RecvTrackSubscription(const WsfXIO_PublishKey& aKey) { Parameter to GetData() must be the same as Publish(), otherwise GetData() results in undefined behavior WsfTrack trackData; publisher.GetData(aKey, trackData); }
| using WsfXIO_Publisher::SubscribeCallback = SubscribeCallbackList::CallbackType |
| using WsfXIO_Publisher::SubscribeCallbackList = UtCallbackListN<void(const WsfXIO_PublishKey&)> |
| using WsfXIO_Publisher::SubscriptionId = GenUniqueId |
| WsfXIO_Publisher::WsfXIO_Publisher | ( | WsfXIO_Interface * | aInterfacePtr | ) |
|
inline |
Read data from a received publication.
| aKey | The key of the publication |
| aData | The data being received from the publication. |
References ok.
Referenced by WsfXIO_PublisherHelper::GetPublishedData().
|
inline |
Publish some data using a key.
References Publish().
Referenced by Publish(), WsfXIO_PublisherHelper::Publish(), and UT_DEFINE_SCRIPT_METHOD().
|
inline |
|
inline |
References Subscribe().
|
inline |
References Subscribe().
|
inline |
References Subscribe().
| WsfXIO_Publisher::SubscribeCallback * WsfXIO_Publisher::Subscribe | ( | const WsfXIO_PublishFilter & | aFilter, |
| SubscribeCallback * | aCallbackPtr ) |
Subscribe to data being published in another application. Data published with keys that match aFilter will trigger the returned callback. GetData() is used to get the published data.
References Subscribe().
Referenced by Subscribe(), Subscribe(), Subscribe(), Subscribe(), Subscribe(), Subscribe(), Subscribe(), and WsfXIO_PublisherHelper::Subscribe().
|
inline |
References Subscribe().
|
inline |
References Subscribe().
|
inline |
References Subscribe().
| WsfXIO_Publisher::SubscribeCallback * WsfXIO_Publisher::Subscribe | ( | SubscriptionId & | aSubscriptionId, |
| const WsfXIO_PublishFilter & | aFilter, | ||
| SubscribeCallback * | aCallbackPtr ) |
| void WsfXIO_Publisher::Unpublish | ( | const WsfXIO_PublishKey & | aKey | ) |
Remove a previously published publication.
References WsfXIO_PublishKey::HasWildcards().
Referenced by UT_DEFINE_SCRIPT_METHOD().
| bool WsfXIO_Publisher::Unsubscribe | ( | const SubscriptionId & | aSubscriptionId | ) |
Remove the specified subscription.
| aSubscriptionId | The subscription unique provided by the 'Subscribe' method. |
References WsfXIO_SubscriptionPkt::mCancel, WsfXIO_SubscriptionPkt::mKeyFilters, WsfXIO_SubscriptionPkt::mSubscriptionIds, and success.
Referenced by WsfXIO_PublisherHelper::Unsubscribe().