A Service defines a JAUS Service which contains an identifier, version, message set, protocol, and associated information. More...
#include <service.h>
Classes | |
class | ID |
ID is the Service Identifier information for a Service. It is a globally unique string that identifies a specific Service Definition. Since a Service mandates a message set and associated protocol, the Service Identifier and version number are sufficient to identify the service interface. Service Identifiers are based on a Uniform Resource Identifier (URI), and are specified for each service by the SAE JAUS standard. More... | |
Public Types | |
typedef std::map< std::string, Service * > | Map |
typedef Mutex::ScopedPtr< Service > | Ptr |
Public Member Functions | |
Service (const ID &serviceIdentifier, const ID &parentServiceIdentifier) | |
Constructor. | |
virtual | ~Service () |
Destructor. | |
virtual void | Initialize () |
virtual void | Shutdown () |
virtual bool | IsDiscoverable () const =0 |
virtual bool | LoadSettings (const std::string &filename) |
virtual bool | Send (const Message *message, const int broadcastFlags=NoBroadcast) const |
Sends a JAUS message. | |
virtual bool | Send (const Message *message, Message *response, const unsigned int waitTimeMs=DefaultWaitMs) const |
Sends a JAUS message, and blocks until a response is received. | |
virtual bool | Send (const Message *message, Message::List &possibleResponses, const unsigned int waitTimeMs=Service::DefaultWaitMs) const |
Sends a JAUS message, and blocks until a response is received. You must pass pointers to the response message object by adding them to the list passed. | |
virtual void | Receive (const Message *message) |
Processes messages passed-to or received by this Service. | |
virtual Message * | CreateMessage (const UShort messageCode) const =0 |
ID | GetServiceID () const |
bool | SetComponentID (const Address &id) |
Sets the component ID of the Service. | |
Address | GetComponentID () const |
bool | InheritsFrom (const Service::ID &id) const |
Checks to see if the Service inherits from the given Service. | |
bool | AddChildService (Service *childService) |
Add a Service this inherits from (i.e. is child of) this Service. | |
bool | SetParentService (Service *parentService) |
Sets a pointer to the Service that this Service inherits from. | |
Service * | GetParentService () |
const Service * | GetParentService () const |
Service * | GetChildService (const Service::ID &id=Service::ID()) |
const Service * | GetChildService (const Service::ID &id=Service::ID()) const |
Service::ID::Set | GetServices () const |
Gets a set of all the Service information for this Service and its child services. Services that are marked as not discoverable through the IsDiscoverable() method are not put in this set. Also, if the service is set in a synchronize mode, it is not discoverable either. This only applies if your class is using the Sensor interface. | |
virtual void | EnableDebugMessages (const bool on=true) |
virtual void | CheckServiceStatus (const unsigned int timeSinceLastCheckMs) |
void | EnableService (const bool enable) |
bool | IsEnabled () const |
virtual void | RecursiveShutdown () |
Performs a recursive shutdown where all child services are shutdown from the bottom up (lowest leaf) followed by this service. | |
void | SetComponent (Component *component) |
Sets a pointer to the component the Service belongs to. | |
Component * | GetComponent () |
const Component * | GetComponent () const |
virtual void | PrintStatus () const |
void | SignalServiceToShutdown (const bool enable=true) |
bool | IsServiceShuttingDown () const |
Static Public Attributes | |
static const int | NoBroadcast = 0 |
static const int | LocalBroadcast = 1 |
static const int | GlobalBroadcast = 2 |
static const unsigned int | DefaultWaitMs = 100 |
Protected Member Functions | |
void | PushMessageToChildren (const Message *message) |
If the message is not supported by this Service, use this method to pass it to all children to this Service. | |
Map | GetChildServices () |
Recursively gets all child services. | |
const Map | GetChildServices () const |
Recursively gets all child services. | |
Transport * | GetTransportService () |
const Transport * | GetTransportService () const |
Protected Attributes | |
volatile bool | mDebugMessagesFlag |
If true, show debugging messages. | |
Address | mComponentID |
ID of the JAUS component the transport is for. | |
Component * | mpComponent |
Pointer to the component the service belongs to. | |
volatile bool | mShutdownServiceFlag |
If true, service must shutdown. | |
Static Protected Attributes | |
static Mutex | mDebugMessagesMutex |
Mutex to lock console for message display. | |
Friends | |
class | Transport |
A Service defines a JAUS Service which contains an identifier, version, message set, protocol, and associated information.
Definition at line 61 of file service.h.
typedef std::map<std::string, Service*> JAUS::Service::Map |
typedef Mutex::ScopedPtr<Service> JAUS::Service::Ptr |
Service::~Service | ( | ) | [virtual] |
Destructor.
Definition at line 230 of file service.cpp.
bool Service::AddChildService | ( | Service * | childService ) |
Add a Service this inherits from (i.e. is child of) this Service.
[in] | childService | The child Service to add. |
Definition at line 395 of file service.cpp.
virtual void JAUS::Service::CheckServiceStatus | ( | const unsigned int | timeSinceLastCheckMs ) | [inline, virtual] |
Reimplemented in JAUS::AccessControl, JAUS::Discovery, JAUS::Events, JAUS::Management, JAUS::SubsystemCommand, JAUS::ControlDevice, JAUS::Joystick, and JAUS::Keyboard.
Implemented in JAUS::AccessControl, JAUS::Discovery, JAUS::Events, JAUS::Liveness, JAUS::Management, JAUS::TimeService, JAUS::Transport, JAUS::AudioSensor, JAUS::SubsystemCommand, JAUS::ControlDevice, JAUS::Microcontroller, JAUS::RangeSensor, JAUS::RangeSubscriber, JAUS::VideoSubscriber, JAUS::VisualSensor, JAUS::GlobalWaypointDriver, JAUS::GlobalWaypointListDriver, JAUS::ListDriver, JAUS::LocalWaypointDriver, JAUS::LocalWaypointListDriver, JAUS::PrimitiveDriver, JAUS::ListManager, JAUS::AccelerationStateSensor, JAUS::GlobalPoseSensor, JAUS::LocalPoseSensor, and JAUS::VelocityStateSensor.
virtual void JAUS::Service::EnableDebugMessages | ( | const bool | on = true ) |
[inline, virtual] |
Reimplemented in JAUS::JTCPClient.
void JAUS::Service::EnableService | ( | const bool | enable ) | [inline] |
const Service * Service::GetChildService | ( | const Service::ID & | id = Service::ID() ) |
const |
Definition at line 506 of file service.cpp.
Service * Service::GetChildService | ( | const Service::ID & | id = Service::ID() ) |
Definition at line 486 of file service.cpp.
Service::Map Service::GetChildServices | ( | ) | [protected] |
Recursively gets all child services.
Definition at line 660 of file service.cpp.
const Service::Map Service::GetChildServices | ( | ) | const [protected] |
Recursively gets all child services.
Definition at line 689 of file service.cpp.
const Component* JAUS::Service::GetComponent | ( | ) | const [inline] |
Service * Service::GetParentService | ( | ) |
Definition at line 462 of file service.cpp.
const Service * Service::GetParentService | ( | ) | const |
Definition at line 473 of file service.cpp.
Service::ID::Set Service::GetServices | ( | ) | const |
Gets a set of all the Service information for this Service and its child services. Services that are marked as not discoverable through the IsDiscoverable() method are not put in this set. Also, if the service is set in a synchronize mode, it is not discoverable either. This only applies if your class is using the Sensor interface.
Definition at line 531 of file service.cpp.
const Transport* JAUS::Service::GetTransportService | ( | ) | const [inline, protected] |
Transport* JAUS::Service::GetTransportService | ( | ) | [inline, protected] |
bool Service::InheritsFrom | ( | const Service::ID & | id ) | const |
virtual void JAUS::Service::Initialize | ( | ) | [inline, virtual] |
Reimplemented in JAUS::Discovery, JAUS::Management, and JAUS::SubsystemCommand.
virtual bool JAUS::Service::IsDiscoverable | ( | ) | const [pure virtual] |
Implemented in JAUS::AccessControl, JAUS::Discovery, JAUS::Events, JAUS::Liveness, JAUS::Management, JAUS::TimeService, JAUS::Transport, JAUS::AudioSensor, JAUS::SubsystemCommand, JAUS::ControlDevice, JAUS::Microcontroller, JAUS::RangeSensor, JAUS::RangeSubscriber, JAUS::VideoSubscriber, JAUS::VisualSensor, JAUS::GlobalWaypointDriver, JAUS::ListDriver, JAUS::LocalWaypointDriver, JAUS::PrimitiveDriver, JAUS::ListManager, JAUS::AccelerationStateSensor, JAUS::GlobalPoseSensor, JAUS::LocalPoseSensor, and JAUS::VelocityStateSensor.
bool JAUS::Service::IsServiceShuttingDown | ( | ) | const [inline] |
virtual bool JAUS::Service::LoadSettings | ( | const std::string & | filename ) | [inline, virtual] |
Reimplemented in JAUS::AccessControl, JAUS::Discovery, JAUS::JTCPClient, JAUS::JUDP, JAUS::ControlDevice, JAUS::Joystick, and JAUS::Keyboard.
virtual void JAUS::Service::PrintStatus | ( | ) | const [inline, virtual] |
Reimplemented in JAUS::AccessControl, JAUS::Discovery, JAUS::Events, JAUS::Management, JAUS::SubsystemCommand, JAUS::ControlDevice, JAUS::Microcontroller, JAUS::GlobalWaypointDriver, JAUS::GlobalWaypointListDriver, JAUS::LocalWaypointDriver, JAUS::LocalWaypointListDriver, JAUS::PrimitiveDriver, JAUS::AccelerationStateSensor, JAUS::GlobalPoseSensor, JAUS::LocalPoseSensor, and JAUS::VelocityStateSensor.
void Service::PushMessageToChildren | ( | const Message * | message ) | [protected] |
If the message is not supported by this Service, use this method to pass it to all children to this Service.
[in] | message | The message to push to child Services. |
Definition at line 624 of file service.cpp.
void Service::Receive | ( | const Message * | message ) | [virtual] |
Processes messages passed-to or received by this Service.
Whenever a Service receives a message, this method is called. New Services must overload this method to add processing capabilities.
If the service does not support the Message, then it must use the PushMessageToChildren method to pass it to inheriting Services that do support it (this is the default behavior of the method).
Reimplemented in JAUS::AccessControl, JAUS::Discovery, JAUS::Events, JAUS::Liveness, JAUS::Management, JAUS::TimeService, JAUS::Transport, JAUS::AudioSensor, JAUS::SubsystemCommand, JAUS::ControlDevice, JAUS::Microcontroller, JAUS::RangeSensor, JAUS::RangeSubscriber, JAUS::VideoSubscriber, JAUS::VisualSensor, JAUS::GlobalWaypointDriver, JAUS::GlobalWaypointListDriver, JAUS::ListDriver, JAUS::LocalWaypointDriver, JAUS::LocalWaypointListDriver, JAUS::PrimitiveDriver, JAUS::ListManager, JAUS::AccelerationStateSensor, JAUS::GlobalPoseSensor, JAUS::LocalPoseSensor, and JAUS::VelocityStateSensor.
Definition at line 332 of file service.cpp.
void Service::RecursiveShutdown | ( | ) | [virtual] |
Performs a recursive shutdown where all child services are shutdown from the bottom up (lowest leaf) followed by this service.
This type of shutdown is necessary to make sure that lower level serives shutdown before their parent services do. Failure to do so may result in disabling a service capability needed by a child service to perform safe cleanup.
Definition at line 575 of file service.cpp.
bool Service::Send | ( | const Message * | message, |
Message * | response, | ||
const unsigned int | waitTimeMs = DefaultWaitMs |
||
) | const [virtual] |
Sends a JAUS message, and blocks until a response is received.
[in] | message | JAUS Message to send. |
[out] | response | Pointer to message that is the response to the message sent which will read received data. |
[in] | waitTimeMs | How long to wait in ms for a response to be received. |
Reimplemented in JAUS::Transport.
Definition at line 277 of file service.cpp.
bool Service::Send | ( | const Message * | message, |
const int | broadcastFlags = NoBroadcast |
||
) | const [virtual] |
Sends a JAUS message.
[in] | message | JAUS Message to send. |
[in] | broadcastFlags | Values to use to signify if message should be sent using any broadcast options (e.g. multicast). 0 = no options, 1 = local broadcast, 2 = global broadcast. |
Reimplemented in JAUS::Transport.
Definition at line 254 of file service.cpp.
bool Service::Send | ( | const Message * | message, |
Message::List & | possibleResponses, | ||
const unsigned int | waitTimeMs = Service::DefaultWaitMs |
||
) | const [virtual] |
Sends a JAUS message, and blocks until a response is received. You must pass pointers to the response message object by adding them to the list passed.
[in] | message | JAUS Message to send. |
[out] | possibleResponses | Lists of messages that are possible responses to the message sent. For example Create Event can be responded with Confirm or Reject Event Request. |
[in] | waitTimeMs | How long to wait in ms for a response to be received. |
Reimplemented in JAUS::Transport.
Definition at line 306 of file service.cpp.
void Service::SetComponent | ( | Component * | component ) |
Sets a pointer to the component the Service belongs to.
When called, the component pointer to passed to all child services also.
[in] | component | Pointer to component Service belongs to. |
Definition at line 597 of file service.cpp.
bool Service::SetComponentID | ( | const Address & | id ) |
bool Service::SetParentService | ( | Service * | parentService ) |
Sets a pointer to the Service that this Service inherits from.
[in] | parentService | Parent to this Service. |
Definition at line 443 of file service.cpp.
virtual void JAUS::Service::Shutdown | ( | ) | [inline, virtual] |
void JAUS::Service::SignalServiceToShutdown | ( | const bool | enable = true ) |
[inline] |
const unsigned int JAUS::Service::DefaultWaitMs = 100 [static] |
const int JAUS::Service::GlobalBroadcast = 2 [static] |
const int JAUS::Service::LocalBroadcast = 1 [static] |
Address JAUS::Service::mComponentID [protected] |
volatile bool JAUS::Service::mDebugMessagesFlag [protected] |
Mutex Service::mDebugMessagesMutex [static, protected] |
Component* JAUS::Service::mpComponent [protected] |
volatile bool JAUS::Service::mShutdownServiceFlag [protected] |
const int JAUS::Service::NoBroadcast = 0 [static] |