xorp

ServiceBase Class Reference

Base class for Services. More...

#include <service.hh>

Inheritance diagram for ServiceBase:
BugCatcher AreaRouter< A > BGPMain Fib2mribNode IfMgrXrlMirror InterfaceMonitor IO< A > IO< A > ProtoState ShowDistancesProcessor ShowRoutesProcessor StaticRoutesNode TestService XrlJobQueue XrlPort XrlPortIO< A > XrlPortManager< A > XrlProcessSpy XrlRedistManager< A > XrlRibNotifier< A >

List of all members.

Public Member Functions

 ServiceBase (const string &name="Unknown")
virtual int startup ()=0
 Start service.
virtual int shutdown ()=0
 Shutdown service.
virtual int reset ()
 Reset service.
virtual int pause ()
 Pause service.
virtual int resume ()
 Resume paused service.
const string & service_name () const
 Get name of service.
ServiceStatus status () const
 Get the current status.
const string & status_note () const
 Get annotation associated with current status.
const char * status_name () const
 Get a character representation of the current service status.
int set_observer (ServiceChangeObserverBase *so)
 Set service status change observer.
int unset_observer (ServiceChangeObserverBase *so)
 Remove service status change observer.

Protected Member Functions

void set_status (ServiceStatus status, const string &note)
 Set current status.
void set_status (ServiceStatus status)
 Set current status and clear status note.

Protected Attributes

string _name
ServiceStatus _status
string _note
ServiceChangeObserverBase_observer

Detailed Description

Base class for Services.

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


Member Function Documentation

int ServiceBase::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 ServiceBase::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.

Reimplemented in ProtoState.

int ServiceBase::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& ServiceBase::service_name ( ) const [inline]

Get name of service.

Returns:
name of service. May be empty if not set in constructor.
int ServiceBase::set_observer ( ServiceChangeObserverBase so)

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.
void ServiceBase::set_status ( ServiceStatus  status) [protected]

Set current status and clear status note.

Parameters:
statusnew status.
void ServiceBase::set_status ( ServiceStatus  status,
const string &  note 
) [protected]

Set current status.

Parameters:
statusnew status.
notecomment on new service status.
virtual int ServiceBase::shutdown ( ) [pure virtual]
virtual int ServiceBase::startup ( ) [pure virtual]
const string& ServiceBase::status_note ( ) const [inline]

Get annotation associated with current status.

The annotation when set is an explanation of the state, ie "waiting for Y"

int ServiceBase::unset_observer ( ServiceChangeObserverBase so)

Remove service status change observer.

Parameters:
soobserver to remove.
Returns:
XORP_OK on success, otherwise XORP_ERROR.

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