Service Class Reference

#include <Service.h>

Inheritance diagram for Service:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 Service (const char *internalServiceName, const char *displayServiceName)
bool Create (const char *userName=0, const char *password=0, const bool autoStart=true, const bool restartOnError=true, const char *longDescription=0, const char *dependencies=0)
bool SetArgs (int argc=0, char **argv=0)
 Sets the arguments to use for this service. On Windows platforms these are stored in the registry.
bool GetArgs (int &argc, char **&argv)
 Gets the arguments to use for this service. On Windows platforms these are stored in the registry.
bool Start (void)
 Starts the service.
bool Stop (void)
 Stops the service.
bool Delete (void)
 Deletes the service.
bool Execute (const bool setCurrentDirectory=true, const bool storeLastDebugPrint=false)
virtual int Main (int argc=0, char **argv=0)=0
void DebugPrint (const char *,...)
 A utility function that allows the user to output debug information as the service is running.

Static Public Member Functions

static bool GetDebugLine (const char *serviceName, std::string &buffer)
 Retrieves the last line from DebugPrint for the service.
static bool GetServiceList (std::list< std::string > &services)
 Gets the list of service names that are installed.

Protected Member Functions

bool NeedToExitMain (void)
 Returns true if the Main function needs to exit. This must be tested fairly regularly by the Main function.
void SetDebugLine (const char *buffer)

Protected Attributes

bool mToStdOut


Detailed Description

Implements a service. Only one instance of this class may be allocated in a process. On Windows platforms the service is executed by the service scheduler. On Linux platforms the service runs as a separate process.

Member Function Documentation

bool Create ( const char *  userName = 0,
const char *  password = 0,
const bool  autoStart = true,
const bool  restartOnError = true,
const char *  longDescription = 0,
const char *  dependencies = 0 
)

Creates and installs a service using this process.

Parameters:
restartOnError If true and the Main function generates an exception this will restart the service.

bool Execute ( const bool  setCurrentDirectory = true,
const bool  storeLastDebugPrint = false 
)

Call this to start running the application as a service

Parameters:
setCurrentDirectory When true the service will set the current process directory to be the directory of the executable. This is to allow compatibility with processes that expect the current directory to be the execution directory. When false and running under Windows the current directory will most likely be something similar to WINDIR% depending on the OS version.
storeLastDebugPrint When true this stores the last debug print line in the registry. Useful as an aid to debugging.

virtual int Main ( int  argc = 0,
char **  argv = 0 
) [pure virtual]

The main work function which must be implemented. Any unhandled exception (such as accessing an invalid memory address) will be caught by this Service class and will usually cause the service to restart if configured.


Generated on Sat Jun 28 22:02:34 2008 for ReplicaNet and RNLobby by  doxygen 1.5.3