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]

int  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: XORP_OK on success, otherwise XORP_ERROR.

int  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: XORP_OK on success, otherwise XORP_ERROR.

int  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: XORP_OK on success, otherwise XORP_ERROR.

int  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: XORP_OK on success, otherwise XORP_ERROR.

int  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: XORP_OK on success, otherwise XORP_ERROR.

const string&  service_name ()

service_name

[const]

Get name of service.

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

ServiceStatus  status ()

status

[const]

Get the current status.

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.

int  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: XORP_OK on success, otherwise XORP_ERROR.

int  unset_observer (ServiceChangeObserverBase* so)

unset_observer

Remove service status change observer.

Parameters:

soobserver to remove.

Returns: XORP_OK on success, otherwise XORP_ERROR.

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 kobe.xorp.net on Wed Jan 7 19:10:36 2009, using kdoc 2.0a54+XORP.