class ServiceBase

Base class for Services. More...

 
LOGO
 Annotated List  Files  Globals  Hierarchy  Index  Top

Public Methods

Protected Methods

Protected Members


Detailed Description

This class provides a base for services within Xorp processes. A service instance is an entity that can logically started and stopped and typically needs some asynchronous processing in order to start and stop. An example service within a routing process would be a RIB communicator service, which needs to co-ordinate with the RIB which is within a different process and may be on a different machine.

A service may be started and shutdown by calling startup() and shutdown(). The status of a service may be determined by calling status(). Additional notes on the current status may be obtained by calling status_note().

Synchronous service status changes may be received through the ServiceChangeObserverBase class. Instances of objects derived from this class can register for status change notifications in a Service instance by calling set_observer().

 ServiceBase (const string& name = "Unknown")

ServiceBase

 ~ServiceBase ()

~ServiceBase

[pure virtual]

bool  startup ()

startup

[pure virtual]

Start service. Service should transition from SERVICE_READY to SERVICE_STARTING immediately and onto SERVICE_RUNNING or SERVICE_FAILED in the near future.

Returns: true on success, false on failure.

bool  shutdown ()

shutdown

[pure virtual]

Shutdown service. Service should transition from SERVICE_RUNNING to SERVICE_SHUTTING_DOWN immediately and onto SERVICE_SHUTDOWN or SERVICE_FAILED in the near future.

Returns: true on success, false on failure.

bool  reset ()

reset

[virtual]

Reset service. Service should transition in SERVICE_READY from whichever state it is in.

The default implementation always returns false as there is no default behaviour.

Returns: true on success, false on failure.

bool  pause ()

pause

[virtual]

Pause service. Service should transition from SERVICE_RUNNING to SERVICE_PAUSING and asynchronously into SERVICE_PAUSED.

The default implementation always returns false as there is no default behaviour.

Returns: true on success, false on failure.

bool  resume ()

resume

[virtual]

Resume paused service. Service should transition from SERVICE_PAUSED to SERVICE_PAUSING and asynchronously into SERVICE_RUNNING.

The default implementation always returns false as there is no default behaviour.

Returns: true on success, false on failure.

inline const string&  service_name ()

service_name

[const]

Get name of service.

Returns: name of service. May be empty if not set in constructor.

inline ServiceStatus  status ()

status

[const]

Get the current status.

inline const string&  status_note ()

status_note

[const]

Get annotation associated with current status. The annotation when set is an explanation of the state, ie "waiting for Y"

const char*  status_name ()

status_name

[const]

Get a character representation of the current service status.

bool  set_observer (ServiceChangeObserverBase* so)

set_observer

Set service status change observer. The observer will receive synchronous notifications of changes in service state.

Parameters:

soservice change observer to add.

Returns: true on success, false if an observer is already set.

bool  unset_observer (ServiceChangeObserverBase* so)

unset_observer

Remove service status change observer.

Parameters:

soobserver to remove.

Returns: true on success, false if supplied observer does match the last set observer.

void  set_status (ServiceStatus status, const string& note)

set_status

[protected]

Set current status.

Parameters:

statusnew status.
notecomment on new service status.
void  set_status (ServiceStatus status)

set_status

[protected]

Set current status and clear status note.

Parameters:

statusnew status.
string _name

_name

[protected]

ServiceStatus _status

_status

[protected]

string _note

_note

[protected]

ServiceChangeObserverBase* _observer

_observer

[protected]


Generated by: pavlin on possum.icir.org on Wed Apr 13 21:52:49 2005, using kdoc $.