The Events Service manages the creation and maintenance of Event subscriptions. More...
#include <events.h>
Classes | |
class | Callback |
Method to put hooks into Event Service to be notified when a new event has been received. More... | |
class | Child |
Defines the interface for Services that inherit from the Events Service. More... | |
class | Subscription |
Describes information about an Event that is being produced or subscribed to by the Component. More... | |
Public Types | |
enum | Type { Periodic = 0, EveryChange } |
Public Member Functions | |
Events () | |
Constructor. | |
~Events () | |
Destructor. | |
virtual void | Shutdown () |
Shutsdown the Service. | |
bool | RequestEveryChangeEvent (const Address &provider, const Message *query, const unsigned int waitTimeMs=Service::DefaultWaitMs) |
Requests an Every Change event subscription from the component specified. | |
bool | RequestPeriodicEvent (const Address &provider, const Message *query, const double desiredPeriodicRate=1.0, const double minimumPeriodicRate=0.9, const unsigned int waitTimeMs=DefaultWaitMs) |
Requests an Periodic event subscription from the component specified. | |
void | SignalEvent (const UShort reportMessageCode, const bool changeOnly=true) |
Signals to the Event Service that the type of data has changed and any EveryChange type events should be generated. | |
void | SignalEvent (const Subscription &info, const bool changeOnly=true) |
Signals to the Event Service that the type of data has changed and any EveryChange type events should be generated. | |
bool | CancelSubscription (const Address &id, const UShort reportMessageCode, const unsigned int waitTimeMs=Service::DefaultWaitMs) |
Method used to cancel any existing subscriptions from a component. | |
bool | CancelSubscription (const Address &id, const UShort reportMessageCode, Byte eventID, const unsigned int waitTimeMs) |
Method used to cancel any existing subscriptions from a component. | |
bool | HaveSubscription (const UShort reportMessageCode, const Address &id, const bool verifyWithQuery=false, const unsigned int waitTimeMs=Service::DefaultWaitMs) const |
Method used to confirm, or check to see if an event subscription exists. | |
bool | HaveSubscribers (const UShort reportMessageCode) const |
Method used to check if there are subscribers for a type of event. | |
virtual bool | IsDiscoverable () const |
virtual void | Receive (const Message *message) |
Processes message received by the Service. If not supported, then message is passed to inheriting services. | |
virtual Message * | CreateMessage (const UShort messageCode) const |
Attempts to create the message desired. Only message supported by this Service can be created by this Service. | |
virtual void | CheckServiceStatus (const unsigned int timeSinceLastCheckMs) |
Method called periodically by external classes and is used to verify subscriptions are still valid. | |
void | SetEventSubscriptionCheckThreshold (const Time::Stamp timeMs=5000) |
Subscription::List | GetSubscriptions (const Address &source=Address(), const UShort reportType=0) const |
Gets a list of event subscriptions. | |
Subscription::List | GetSubscriptions (const UShort reportType) const |
Gets a list of event subscriptions. | |
Subscription::List | GetProducedEvents (const UShort reportType) const |
Gets a list of event subscriptions being produced by this service. | |
void | RegisterCallback (Events::Callback *callback) |
Method to register a callback for an event. | |
virtual void | PrintStatus () const |
Prints status info about the Service to the console. | |
Static Public Attributes | |
static const std::string | Name = "urn:jaus:jss:core:Events" |
String name of the Service. |
The Events Service manages the creation and maintenance of Event subscriptions.
This service allows clients to subscribe to changes in the information provided by report messages supported by services that derive from this service. When a client succesfully creates an event, an "Internal Event" occurs when the event creation critera are met, and as a result the matching Event is sent to the subscribing client.
Definition at line 63 of file events.h.
enum JAUS::Events::Type |
Events::Events | ( | ) |
Constructor.
Definition at line 269 of file events.cpp.
Events::~Events | ( | ) |
Destructor.
Definition at line 283 of file events.cpp.
bool Events::CancelSubscription | ( | const Address & | id, |
const UShort | reportMessageCode, | ||
const unsigned int | waitTimeMs = Service::DefaultWaitMs |
||
) |
Method used to cancel any existing subscriptions from a component.
If the reportMessageCode is set to 0, then all subscriptions from the specified component are canceled.
[in] | reportMessageCode | The type of data for the event. |
[in] | id | The ID of the component generating the event that needs to be canceled. |
[in] | waitTimeMs | How long to wait for a confirm or reject response to be received. |
Definition at line 709 of file events.cpp.
bool Events::CancelSubscription | ( | const Address & | id, |
const UShort | reportMessageCode, | ||
Byte | eventID, | ||
const unsigned int | waitTimeMs | ||
) |
Method used to cancel any existing subscriptions from a component.
If the reportMessageCode is set to 0, then all subscriptions from the specified component are canceled.
[in] | reportMessageCode | The type of data for the event. |
[in] | id | The ID of the component generating the event that needs to be canceled. |
[in] | eventID | Specific event ID. |
[in] | waitTimeMs | How long to wait for a confirm or reject response to be received. |
Definition at line 788 of file events.cpp.
void Events::CheckServiceStatus | ( | const unsigned int | timeSinceLastCheckMs ) | [virtual] |
Method called periodically by external classes and is used to verify subscriptions are still valid.
[in] | timeSinceLastCheckMs | Number of milliseconds since the last time this method was called. |
Reimplemented from JAUS::Service.
Definition at line 1445 of file events.cpp.
Attempts to create the message desired. Only message supported by this Service can be created by this Service.
[in] | messageCode | Message to create. |
Implements JAUS::Service.
Definition at line 1397 of file events.cpp.
Events::Subscription::List Events::GetProducedEvents | ( | const UShort | reportType ) | const |
Gets a list of event subscriptions being produced by this service.
It's possible to filter by source and by message report type. If source is a 0 ID (invalid), then all event producers are considered, otherwise event producers with matching ID as source.
To filter by type, set reportType to a non 0 value, and only events of the type will be returned.
[in] | reportType | The type of event messages to get info on. set to 0 for any events. |
Definition at line 1574 of file events.cpp.
Events::Subscription::List Events::GetSubscriptions | ( | const UShort | reportType ) | const |
Gets a list of event subscriptions.
It's possible to filter by source and by message report type. If source is a 0 ID (invalid), then all event producers are considered, otherwise event producers with matching ID as source.
To filter by type, set reportType to a non 0 value, and only events of the type will be returned.
[in] | reportType | The type of event messages to get info on. set to 0 for any events. |
Definition at line 1537 of file events.cpp.
Events::Subscription::List Events::GetSubscriptions | ( | const Address & | source = Address() , |
const UShort | reportType = 0 |
||
) | const |
Gets a list of event subscriptions.
It's possible to filter by source and by message report type. If source is a 0 ID (invalid), then all event producers are considered, otherwise event producers with matching ID as source.
To filter by type, set reportType to a non 0 value, and only events of the type will be returned.
[in] | source | ID of the source of the event to get subscriptions from. Set to 0.0.0 for any source. |
[in] | reportType | The type of event messages to get info on. set to 0 for any events. |
Definition at line 1496 of file events.cpp.
bool Events::HaveSubscribers | ( | const UShort | reportMessageCode ) | const |
Method used to check if there are subscribers for a type of event.
[in] | reportMessageCode | The type of data for the event. |
Definition at line 921 of file events.cpp.
bool Events::HaveSubscription | ( | const UShort | reportMessageCode, |
const Address & | id, | ||
const bool | verifyWithQuery = false , |
||
const unsigned int | waitTimeMs = Service::DefaultWaitMs |
||
) | const |
Method used to confirm, or check to see if an event subscription exists.
[in] | reportMessageCode | The type of data for the event. |
[in] | id | The ID of the component providing the event. If set to 0.0.0.0 then any component with the type of event is checked. |
[in] | verifyWithQuery | If true, a Query Events message is sent to the component to verify that the event actually exists. |
[in] | waitTimeMs | How long to wait in ms for a response to be recevied when verifyWithQuery is true. |
Definition at line 869 of file events.cpp.
virtual bool JAUS::Events::IsDiscoverable | ( | ) | const [inline, virtual] |
Implements JAUS::Service.
void Events::PrintStatus | ( | ) | const [virtual] |
Prints status info about the Service to the console.
Reimplemented from JAUS::Service.
Definition at line 681 of file events.cpp.
void Events::Receive | ( | const Message * | message ) | [virtual] |
Processes message received by the Service. If not supported, then message is passed to inheriting services.
This Service supports the following message: Cancel Event, Confirm Event Request, Create Event, Event, Query Events, Reject Event Request, Report Events, UpdateEvent.
[in] | message | Message data to process. |
Reimplemented from JAUS::Service.
Definition at line 954 of file events.cpp.
void Events::RegisterCallback | ( | Events::Callback * | callback ) |
Method to register a callback for an event.
[in] | callback | Pointer to callback instance (is not deleted by service). |
Definition at line 1599 of file events.cpp.
bool Events::RequestEveryChangeEvent | ( | const Address & | provider, |
const Message * | query, | ||
const unsigned int | waitTimeMs = Service::DefaultWaitMs |
||
) |
Requests an Every Change event subscription from the component specified.
[in] | provider | The component that will provide the event. |
[in] | query | The type of data to query (used to determine type of report information desired). |
[in] | waitTimeMs | How long to wait for a response from the component sending confirmation/rejection. |
Definition at line 361 of file events.cpp.
bool Events::RequestPeriodicEvent | ( | const Address & | provider, |
const Message * | query, | ||
const double | desiredPeriodicRate = 1.0 , |
||
const double | minimumPeriodicRate = 0.9 , |
||
const unsigned int | waitTimeMs = DefaultWaitMs |
||
) |
Requests an Periodic event subscription from the component specified.
[in] | provider | The component that will provide the event. |
[in] | query | The type of data to query (used to determine type of report information desired). |
[in] | desiredPeriodicRate | The desired periodic update rate for the event. |
[in] | minimumPeriodicRate | The minimum periodic rate that you will accept, anything less than this number and the event will be canceled. |
[in] | waitTimeMs | How long to wait for a response from the component sending confirmation/rejection. |
Definition at line 473 of file events.cpp.
void JAUS::Events::SetEventSubscriptionCheckThreshold | ( | const Time::Stamp | timeMs = 5000 ) |
[inline] |
void Events::Shutdown | ( | ) | [virtual] |
void Events::SignalEvent | ( | const UShort | reportMessageCode, |
const bool | changeOnly = true |
||
) |
Signals to the Event Service that the type of data has changed and any EveryChange type events should be generated.
Any time your report data changes, and your Service is a child of the Event Service, you should signal the change in the data using this method.
[in] | reportMessageCode | The type of data that has changed. |
[in] | changeOnly | If true, only Every Change events are signaled. This is the default behavior. |
Definition at line 596 of file events.cpp.
void Events::SignalEvent | ( | const Subscription & | info, |
const bool | changeOnly = true |
||
) |
Signals to the Event Service that the type of data has changed and any EveryChange type events should be generated.
Any time your report data changes, and your Service is a child of the Event Service, you can signal the change in the data using this method.
[in] | info | The specific event to trigger. |
[in] | changeOnly | If true, only Every Change events are signaled. This is the default behavior. |
Definition at line 641 of file events.cpp.
const std::string Events::Name = "urn:jaus:jss:core:Events" [static] |