OmniEvents
OmniEvents::Service Class Reference

Singleton class that contains various methods for running a Windows service. More...

#include <daemon_windows.h>

Public Member Functions

 Service ()
 
 ~Service ()
 
void start (int &argc, char **&argv)
 
void tracefile (const char *val)
 Set _tracefile.
 
void pidfile (const char *val)
 Set _pidfile.
 
void foreground (bool val)
 Set _foreground.
 
void daemonize ()
 Redirects output streams to tracefile.
 
void runningOk ()
 Called to signal that all startup operations have completed OK.
 
void shutdown ()
 Exit handler set with on_exit() - shuts down the service.
 

Static Public Member Functions

static void log (const char *message)
 Callback, used as a parameter to omniORB::setLogFunction().
 
static void ctrlHandler (DWORD controlCode)
 Handles control codes from the Service Control Manager.
 

Private Member Functions

void Service::setArgcArgv (int &argc, char **&argv)
 
void install (int argc, char **argv) const
 
void uninstall () const
 
void readParameters ()
 Populates _parameters from the Registry.
 
void writeParameters (int argc, char **argv) const
 Writes args 2+ to the Registry.
 
bool Service::setServiceStatus (DWORD currentState, DWORD win32ExitCode, DWORD serviceSpecificExitCode, DWORD checkPoint, DWORD waitHint)
 

Private Attributes

char_tracefile
 The tracefile name (if any).
 
const char_regSubKey
 
bool _serviceRunning
 
int _callCount
 
char_parameters
 Stores parameters read from the registry.
 
char ** _argv
 Replacement argv array, read from registry.
 
std::ostream * _logstream
 
SERVICE_STATUS_HANDLE _serviceStatusHandle
 Windows thing.
 

Detailed Description

Singleton class that contains various methods for running a Windows service.

Definition at line 40 of file daemon_windows.h.

Constructor & Destructor Documentation

◆ Service()

OmniEvents::Service::Service ( )

Definition at line 180 of file daemon_windows.cc.

◆ ~Service()

OmniEvents::Service::~Service ( )

Definition at line 192 of file daemon_windows.cc.

References _argv, _logstream, _parameters, and _tracefile.

Member Function Documentation

◆ ctrlHandler()

void OmniEvents::Service::ctrlHandler ( DWORD  controlCode)
static

Handles control codes from the Service Control Manager.

Definition at line 340 of file daemon_windows.cc.

References OmniEvents_Orb_bumpTraceLevel(), OmniEvents_Orb_shutdown(), and OmniEvents::service.

Referenced by start().

◆ daemonize()

void OmniEvents::Service::daemonize ( )

Redirects output streams to tracefile.

Definition at line 292 of file daemon_windows.cc.

References _logstream, _tracefile, log(), omniORB::setLogFunction(), and OmniEvents::shutdown0().

◆ foreground()

void OmniEvents::Service::foreground ( bool  val)

Set _foreground.

Definition at line 216 of file daemon_windows.cc.

References log().

◆ install()

void OmniEvents::Service::install ( int  argc,
char **  argv 
) const
private

◆ log()

void OmniEvents::Service::log ( const char message)
static

Callback, used as a parameter to omniORB::setLogFunction().

Definition at line 334 of file daemon_windows.cc.

References _logstream, and OmniEvents::service.

Referenced by daemonize(), foreground(), OmniEvents::Win::perror(), and pidfile().

◆ pidfile()

void OmniEvents::Service::pidfile ( const char val)

Set _pidfile.

Definition at line 209 of file daemon_windows.cc.

References log().

◆ readParameters()

void OmniEvents::Service::readParameters ( )
private

Populates _parameters from the Registry.

Definition at line 485 of file daemon_windows.cc.

References _parameters, _regSubKey, HERE, OmniEvents::Win::perror(), and OmniEvents::RegistryKey::queryValueStr().

Referenced by start().

◆ runningOk()

void OmniEvents::Service::runningOk ( )

Called to signal that all startup operations have completed OK.

Definition at line 309 of file daemon_windows.cc.

References _serviceRunning, and Service::setServiceStatus().

◆ Service::setArgcArgv()

void OmniEvents::Service::Service::setArgcArgv ( int argc,
char **&  argv 
)
private

Referenced by start().

◆ Service::setServiceStatus()

bool OmniEvents::Service::Service::setServiceStatus ( DWORD  currentState,
DWORD  win32ExitCode,
DWORD  serviceSpecificExitCode,
DWORD  checkPoint,
DWORD  waitHint 
)
private

Referenced by runningOk(), shutdown(), and start().

◆ shutdown()

void OmniEvents::Service::shutdown ( )

Exit handler set with on_exit() - shuts down the service.

Definition at line 319 of file daemon_windows.cc.

References _logstream, _serviceRunning, and Service::setServiceStatus().

◆ start()

◆ tracefile()

void OmniEvents::Service::tracefile ( const char val)

Set _tracefile.

Definition at line 202 of file daemon_windows.cc.

References _tracefile.

◆ uninstall()

void OmniEvents::Service::uninstall ( ) const
private

Definition at line 448 of file daemon_windows.cc.

References HERE, PACKAGE_NAME, OmniEvents::Win::perror(), and OmniEvents::service.

Referenced by start().

◆ writeParameters()

void OmniEvents::Service::writeParameters ( int  argc,
char **  argv 
) const
private

Writes args 2+ to the Registry.

Definition at line 502 of file daemon_windows.cc.

References _regSubKey, HERE, OmniEvents::Win::perror(), and OmniEvents::RegistryKey::setValueStr().

Referenced by install(), and start().

Member Data Documentation

◆ _argv

char** OmniEvents::Service::_argv
private

Replacement argv array, read from registry.

Definition at line 75 of file daemon_windows.h.

Referenced by ~Service().

◆ _callCount

int OmniEvents::Service::_callCount
private

Definition at line 73 of file daemon_windows.h.

Referenced by start().

◆ _logstream

std::ostream* OmniEvents::Service::_logstream
private

Definition at line 76 of file daemon_windows.h.

Referenced by daemonize(), log(), shutdown(), and ~Service().

◆ _parameters

char* OmniEvents::Service::_parameters
private

Stores parameters read from the registry.

Definition at line 74 of file daemon_windows.h.

Referenced by readParameters(), start(), and ~Service().

◆ _regSubKey

const char* OmniEvents::Service::_regSubKey
private

Definition at line 71 of file daemon_windows.h.

Referenced by install(), readParameters(), and writeParameters().

◆ _serviceRunning

bool OmniEvents::Service::_serviceRunning
private

Definition at line 72 of file daemon_windows.h.

Referenced by runningOk(), shutdown(), and start().

◆ _serviceStatusHandle

SERVICE_STATUS_HANDLE OmniEvents::Service::_serviceStatusHandle
private

Windows thing.

Definition at line 77 of file daemon_windows.h.

Referenced by start().

◆ _tracefile

char* OmniEvents::Service::_tracefile
private

The tracefile name (if any).

Definition at line 70 of file daemon_windows.h.

Referenced by daemonize(), tracefile(), and ~Service().


The documentation for this class was generated from the following files: