Classes | Public Types | Public Member Functions | Static Public Attributes

JAUS::Events Class Reference

The Events Service manages the creation and maintenance of Event subscriptions. More...

#include <events.h>

Inheritance diagram for JAUS::Events:
JAUS::Service

List of all members.

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 MessageCreateMessage (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.

Detailed Description

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.


Member Enumeration Documentation

Enumerator:
Periodic 
EveryChange 

Definition at line 68 of file events.h.


Constructor & Destructor Documentation

Events::Events (  )

Constructor.

Definition at line 269 of file events.cpp.

Events::~Events (  )

Destructor.

Definition at line 283 of file events.cpp.


Member Function Documentation

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.

Parameters:
[in]reportMessageCodeThe type of data for the event.
[in]idThe ID of the component generating the event that needs to be canceled.
[in]waitTimeMsHow long to wait for a confirm or reject response to be received.
Returns:
True on success, false on failure.

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.

Parameters:
[in]reportMessageCodeThe type of data for the event.
[in]idThe ID of the component generating the event that needs to be canceled.
[in]eventIDSpecific event ID.
[in]waitTimeMsHow long to wait for a confirm or reject response to be received.
Returns:
True on success, false on failure.

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.

Parameters:
[in]timeSinceLastCheckMsNumber of milliseconds since the last time this method was called.

Reimplemented from JAUS::Service.

Definition at line 1445 of file events.cpp.

Message * Events::CreateMessage ( const UShort  messageCode ) const [virtual]

Attempts to create the message desired. Only message supported by this Service can be created by this Service.

Parameters:
[in]messageCodeMessage to create.
Returns:
Pointer to newly allocated Message data, NULL if message is not supported by the Service.

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.

Parameters:
[in]reportTypeThe type of event messages to get info on. set to 0 for any events.
Returns:
List of subscriptions the service has.

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.

Parameters:
[in]reportTypeThe type of event messages to get info on. set to 0 for any events.
Returns:
List of subscriptions the service has.

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.

Parameters:
[in]sourceID of the source of the event to get subscriptions from. Set to 0.0.0 for any source.
[in]reportTypeThe type of event messages to get info on. set to 0 for any events.
Returns:
List of subscriptions the service has.

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.

Parameters:
[in]reportMessageCodeThe type of data for the event.
Returns:
True if the subscription exists, false otherwise.

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.

Parameters:
[in]reportMessageCodeThe type of data for the event.
[in]idThe 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]verifyWithQueryIf true, a Query Events message is sent to the component to verify that the event actually exists.
[in]waitTimeMsHow long to wait in ms for a response to be recevied when verifyWithQuery is true.
Returns:
True if the subscription exists, false otherwise.

Definition at line 869 of file events.cpp.

virtual bool JAUS::Events::IsDiscoverable (  ) const [inline, virtual]

Implements JAUS::Service.

Definition at line 201 of file events.h.

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.

Parameters:
[in]messageMessage 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.

Parameters:
[in]callbackPointer 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.

Parameters:
[in]providerThe component that will provide the event.
[in]queryThe type of data to query (used to determine type of report information desired).
[in]waitTimeMsHow long to wait for a response from the component sending confirmation/rejection.
Returns:
True if subscription created, false otherwise.

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.

Parameters:
[in]providerThe component that will provide the event.
[in]queryThe type of data to query (used to determine type of report information desired).
[in]desiredPeriodicRateThe desired periodic update rate for the event.
[in]minimumPeriodicRateThe minimum periodic rate that you will accept, anything less than this number and the event will be canceled.
[in]waitTimeMsHow long to wait for a response from the component sending confirmation/rejection.
Returns:
True if subscription created, false otherwise.

Definition at line 473 of file events.cpp.

void JAUS::Events::SetEventSubscriptionCheckThreshold ( const Time::Stamp  timeMs = 5000 ) [inline]

Definition at line 209 of file events.h.

void Events::Shutdown (  ) [virtual]

Shutsdown the Service.

Reimplemented from JAUS::Service.

Definition at line 293 of file events.cpp.

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.

Parameters:
[in]reportMessageCodeThe type of data that has changed.
[in]changeOnlyIf 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.

Parameters:
[in]infoThe specific event to trigger.
[in]changeOnlyIf true, only Every Change events are signaled. This is the default behavior.

Definition at line 641 of file events.cpp.


Member Data Documentation

const std::string Events::Name = "urn:jaus:jss:core:Events" [static]

String name of the Service.

Definition at line 66 of file events.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines