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

JAUS::Service Class Reference

A Service defines a JAUS Service which contains an identifier, version, message set, protocol, and associated information. More...

#include <service.h>

Inheritance diagram for JAUS::Service:
JAUS::Events JAUS::Events::Child JAUS::Transport JAUS::AccelerationStateSensor JAUS::AccessControl JAUS::AccessControl::Child JAUS::AudioSensor JAUS::Discovery JAUS::Liveness JAUS::RangeSensor JAUS::VelocityStateSensor JAUS::VisualSensor JAUS::JTCPClient JAUS::JUDP

List of all members.

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< ServicePtr

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 MessageCreateMessage (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.
ServiceGetParentService ()
const ServiceGetParentService () const
ServiceGetChildService (const Service::ID &id=Service::ID())
const ServiceGetChildService (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.
ComponentGetComponent ()
const ComponentGetComponent () 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.
TransportGetTransportService ()
const TransportGetTransportService () const

Protected Attributes

volatile bool mDebugMessagesFlag
 If true, show debugging messages.
Address mComponentID
 ID of the JAUS component the transport is for.
ComponentmpComponent
 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

Detailed Description

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.


Member Typedef Documentation

typedef std::map<std::string, Service*> JAUS::Service::Map

Definition at line 97 of file service.h.

typedef Mutex::ScopedPtr<Service> JAUS::Service::Ptr

Definition at line 98 of file service.h.


Constructor & Destructor Documentation

Service::Service ( const ID serviceIdentifier,
const ID parentServiceIdentifier 
)

Constructor.

Parameters:
[in]serviceIdentifierThe Service ID information.
[in]parentServiceIdentifierService ID of the parent Service to this Service class. Who this Service inherits from.

Definition at line 213 of file service.cpp.

Service::~Service (  ) [virtual]

Destructor.

Definition at line 230 of file service.cpp.


Member Function Documentation

bool Service::AddChildService ( Service childService )

Add a Service this inherits from (i.e. is child of) this Service.

Parameters:
[in]childServiceThe child Service to add.
Returns:
True on success, false on failure.

Definition at line 395 of file service.cpp.

virtual void JAUS::Service::CheckServiceStatus ( const unsigned int  timeSinceLastCheckMs ) [inline, virtual]
virtual Message* JAUS::Service::CreateMessage ( const UShort  messageCode ) const [pure virtual]
virtual void JAUS::Service::EnableDebugMessages ( const bool  on = true ) [inline, virtual]

Reimplemented in JAUS::JTCPClient.

Definition at line 148 of file service.h.

void JAUS::Service::EnableService ( const bool  enable ) [inline]

Definition at line 152 of file service.h.

const Service * Service::GetChildService ( const Service::ID id = Service::ID() ) const
Parameters:
[in]idID of the child Service to get a pointer to.
Returns:
A pointer to the child Service.

Definition at line 506 of file service.cpp.

Service * Service::GetChildService ( const Service::ID id = Service::ID() )
Parameters:
[in]idID of the child Service to get a pointer to.
Returns:
A pointer to the child Service.

Definition at line 486 of file service.cpp.

Service::Map Service::GetChildServices (  ) [protected]

Recursively gets all child services.

Returns:
Map of all children to the Service.

Definition at line 660 of file service.cpp.

const Service::Map Service::GetChildServices (  ) const [protected]

Recursively gets all child services.

Returns:
Map of all children to the Service.

Definition at line 689 of file service.cpp.

Component* JAUS::Service::GetComponent (  ) [inline]

Definition at line 160 of file service.h.

const Component* JAUS::Service::GetComponent (  ) const [inline]

Definition at line 162 of file service.h.

Address JAUS::Service::GetComponentID (  ) const [inline]

Definition at line 130 of file service.h.

Service * Service::GetParentService (  )
Returns:
A pointer to the parent service.

Definition at line 462 of file service.cpp.

const Service * Service::GetParentService (  ) const
Returns:
A pointer to the parent service.

Definition at line 473 of file service.cpp.

ID JAUS::Service::GetServiceID (  ) const [inline]

Definition at line 126 of file service.h.

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.

Returns:
List of service information.

Definition at line 531 of file service.cpp.

const Transport* JAUS::Service::GetTransportService (  ) const [inline, protected]

Definition at line 176 of file service.h.

Transport* JAUS::Service::GetTransportService (  ) [inline, protected]

Definition at line 175 of file service.h.

bool Service::InheritsFrom ( const Service::ID id ) const

Checks to see if the Service inherits from the given Service.

Parameters:
[in]idID of the Service to check for direct inheritance from.
Returns:
True if the Service inhertis from the ID of the provided Service, false otherwise.

Definition at line 375 of file service.cpp.

virtual void JAUS::Service::Initialize (  ) [inline, virtual]

Reimplemented in JAUS::Discovery, JAUS::Management, and JAUS::SubsystemCommand.

Definition at line 104 of file service.h.

virtual bool JAUS::Service::IsDiscoverable (  ) const [pure virtual]
bool JAUS::Service::IsEnabled (  ) const [inline]

Definition at line 154 of file service.h.

bool JAUS::Service::IsServiceShuttingDown (  ) const [inline]

Definition at line 168 of file service.h.

virtual bool JAUS::Service::LoadSettings ( const std::string &  filename ) [inline, virtual]
virtual void JAUS::Service::PrintStatus (  ) const [inline, virtual]
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.

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

Parameters:
[in]messageJAUS Message data to process.

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.

Parameters:
[in]messageJAUS Message to send.
[out]responsePointer to message that is the response to the message sent which will read received data.
[in]waitTimeMsHow long to wait in ms for a response to be received.
Returns:
True on success, false on failure.

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.

Parameters:
[in]messageJAUS Message to send.
[in]broadcastFlagsValues 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.
Returns:
True on success, false on failure.

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.

Parameters:
[in]messageJAUS Message to send.
[out]possibleResponsesLists of messages that are possible responses to the message sent. For example Create Event can be responded with Confirm or Reject Event Request.
[in]waitTimeMsHow long to wait in ms for a response to be received.
Returns:
True on success, false on failure.

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.

Parameters:
[in]componentPointer to component Service belongs to.

Definition at line 597 of file service.cpp.

bool Service::SetComponentID ( const Address id )

Sets the component ID of the Service.

Parameters:
[in]idComponent ID the Service belongs to.
Returns:
True if valid ID, false otherwise.

Definition at line 346 of file service.cpp.

bool Service::SetParentService ( Service parentService )

Sets a pointer to the Service that this Service inherits from.

Parameters:
[in]parentServiceParent to this Service.
Returns:
True on success, false on failure.

Definition at line 443 of file service.cpp.

virtual void JAUS::Service::Shutdown (  ) [inline, virtual]
void JAUS::Service::SignalServiceToShutdown ( const bool  enable = true ) [inline]

Definition at line 166 of file service.h.


Friends And Related Function Documentation

friend class Transport [friend]

Definition at line 63 of file service.h.


Member Data Documentation

const unsigned int JAUS::Service::DefaultWaitMs = 100 [static]

Definition at line 96 of file service.h.

const int JAUS::Service::GlobalBroadcast = 2 [static]

Definition at line 95 of file service.h.

const int JAUS::Service::LocalBroadcast = 1 [static]

Definition at line 94 of file service.h.

ID of the JAUS component the transport is for.

Definition at line 179 of file service.h.

volatile bool JAUS::Service::mDebugMessagesFlag [protected]

If true, show debugging messages.

Definition at line 178 of file service.h.

Mutex Service::mDebugMessagesMutex [static, protected]

Mutex to lock console for message display.

Definition at line 177 of file service.h.

Pointer to the component the service belongs to.

Definition at line 180 of file service.h.

volatile bool JAUS::Service::mShutdownServiceFlag [protected]

If true, service must shutdown.

Definition at line 181 of file service.h.

const int JAUS::Service::NoBroadcast = 0 [static]

Definition at line 93 of file service.h.


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