PServiceProcess Class Reference

#include <svcproc.h>

Inheritance diagram for PServiceProcess:

PProcess PThread PObject PHTTPServiceProcess PSecureHTTPServiceProcess List of all members.

Miscellaneous functions

void SetLogLevel (PSystemLog::Level level)
PSystemLog::Level GetLogLevel () const
static PServiceProcessCurrent ()

Public Member Functions

virtual int _main (void *arg=NULL)
 Main function for process, called from real main after initialisation.
 ~PServiceProcess ()
virtual void Terminate ()
Callback functions
virtual PBoolean OnStart ()=0
virtual void OnStop ()
virtual PBoolean OnPause ()
virtual void OnContinue ()
virtual void OnControl ()=0

Protected Member Functions

int InitialiseService ()
void _PXShowSystemWarning (PINDEX num, const PString &str)
void PXOnSignal (int)
void PXOnAsyncSignal (int)

Protected Attributes

PBoolean debugMode
 Flag to indicate service is run in simulation mode.
PSystemLog::Level currentLogLevel
 Current log level for PSYSTEMLOG# calls.
PString systemLogFileName
PString pidFileToRemove
PBoolean isTerminating

Friends

void PSystemLog::Output (PSystemLog::Level, const char *)

Detailed Description

A process type that runs as a "background" service. This may be a service under the Windows NT operating system, or a "daemon" under Unix, or a hidden application under Windows.


Constructor & Destructor Documentation

PServiceProcess::PServiceProcess ( const char *  manuf,
const char *  name,
WORD  majorVersion,
WORD  minorVersion,
CodeStatus  status,
WORD  buildNumber 
)

Create a new service process.

Parameters:
manuf  Name of manufacturer
name  Name of product
majorVersion  Major version number of the product
minorVersion  Minor version number of the product
status  Development status of the product
buildNumber  Build number of the product

PServiceProcess::~PServiceProcess (  ) 

PServiceProcess::PServiceProcess ( const char *  manuf,
const char *  name,
WORD  majorVersion,
WORD  minorVersion,
CodeStatus  status,
WORD  buildNumber 
)

Create a new service process.

Parameters:
manuf  Name of manufacturer
name  Name of product
majorVersion  Major version number of the product
minorVersion  Minor version number of the product
status  Development status of the product
buildNumber  Build number of the product


Member Function Documentation

virtual PBoolean PServiceProcess::OnStart (  )  [pure virtual]

Called when the service is started. This typically initialises the service and returns PTrue if the service is ready to run. The Main()# function is then executed.

Returns:
PTrue if service may start, PFalse if an initialisation failure occurred.

Implemented in PHTTPServiceProcess.

virtual void PServiceProcess::OnStop (  )  [virtual]

Called by the system when the service is stopped. One return from this function there is no guarentee that any more user code will be executed. Any cleaning up or closing of resource must be done in here.

Reimplemented in PHTTPServiceProcess.

virtual PBoolean PServiceProcess::OnPause (  )  [virtual]

Called by the system when the service is to be paused. This will suspend any actions that the service may be executing. Usually this is less expensive in resource allocation etc than stopping and starting the service.

Returns:
PTrue if the service was successfully paused.

Reimplemented in PHTTPServiceProcess.

virtual void PServiceProcess::OnContinue (  )  [virtual]

Resume after the service was paused.

Reimplemented in PHTTPServiceProcess.

virtual void PServiceProcess::OnControl (  )  [pure virtual]

The Control menu option was used in the SysTray menu.

static PServiceProcess& PServiceProcess::Current (  )  [static]

Get the current service process object.

Returns:
Pointer to service process.

Reimplemented from PProcess.

Reimplemented in PHTTPServiceProcess.

void PServiceProcess::SetLogLevel ( PSystemLog::Level  level  )  [inline]

Set the level at which errors are logged. Only messages higher than or equal to the specified level will be logged.

The default is LogError# allowing fatal errors and ordinary\ errors to be logged and warning and information to be ignored.

If in debug mode then the default is LogInfo# allowing all messages to be displayed.

Parameters:
level  New log level

PSystemLog::Level PServiceProcess::GetLogLevel (  )  const [inline]

Get the current level for logging.

Returns:
Log level.

virtual int PServiceProcess::_main ( void *  arg = NULL  )  [virtual]

Main function for process, called from real main after initialisation.

Reimplemented from PProcess.

virtual void PServiceProcess::Terminate (  )  [virtual]

Terminate the process. Usually only used in abnormal abort situation.

Reimplemented from PProcess.

int PServiceProcess::InitialiseService (  )  [protected]

void PServiceProcess::_PXShowSystemWarning ( PINDEX  num,
const PString str 
) [protected, virtual]

Reimplemented from PProcess.

void PServiceProcess::PXOnSignal ( int   )  [protected, virtual]

Reimplemented from PProcess.

void PServiceProcess::PXOnAsyncSignal ( int   )  [protected, virtual]

Reimplemented from PProcess.


Friends And Related Function Documentation

void PSystemLog::Output ( PSystemLog::Level  ,
const char *   
) [friend]


Member Data Documentation

PBoolean PServiceProcess::debugMode [protected]

Flag to indicate service is run in simulation mode.

PSystemLog::Level PServiceProcess::currentLogLevel [protected]

Current log level for PSYSTEMLOG# calls.

PString PServiceProcess::systemLogFileName [protected]

PString PServiceProcess::pidFileToRemove [protected]

PBoolean PServiceProcess::isTerminating [protected]


The documentation for this class was generated from the following file:
Generated on Mon Sep 15 01:21:38 2008 for PTLib by  doxygen 1.5.1