class ServiceBase

Base class for Services. More...

Contains pure virtuals
Definition#include <service.hh>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

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 ()

ServiceBase

 ~ServiceBase ()

~ServiceBase

[pure virtual]

void  startup ()

startup

[pure virtual]

Start service. Service should transition from READY to STARTING immediately and onto RUNNING or FAILED in the near future.

void  shutdown ()

shutdown

[pure virtual]

Shutdown service. Service should transition from RUNNING to SHUTTING_DOWN immediately and onto SHUTDOWN or FAILED in the near future.

bool  reset ()

reset

[virtual]

Reset service. Service should transition in 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 RUNNING to PAUSING and asynchronously into 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 PAUSED to PAUSING and asynchronously into RUNNING.

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

Returns: true on success, false on failure.

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.

ServiceStatus _status

_status

[protected]

string _note

_note

[protected]

ServiceChangeObserverBase* _observer

_observer

[protected]


Generated by: pavlin on possum.icir.org on Thu Nov 6 23:46:46 2003, using kdoc 2.0a54+XORP.