svcproc.h
Go to the documentation of this file.
/*
* svcproc.h
*
* Service Process (daemon) class.
*
* Portable Windows Library
*
* Copyright (c) 1993-1998 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Portions are Copyright (C) 1993 Free Software Foundation, Inc.
* All Rights Reserved.
*
* Contributor(s): ______________________________________.
*
* $Revision: 24177 $
* $Author: rjongbloed $
* $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
*/
#ifndef PTLIB_SERVICEPROCESS_H
#define PTLIB_SERVICEPROCESS_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <ptlib/pprocess.h>
#include <ptlib/syslog.h>
class PServiceProcess : public PProcess
{
PCLASSINFO(PServiceProcess, PProcess);
public:
PServiceProcess(
const char * manuf,
const char * name,
WORD majorVersion,
WORD minorVersion,
CodeStatus status,
WORD buildNumber
);
virtual PBoolean OnStart() = 0;
virtual void OnStop();
virtual PBoolean OnPause();
virtual void OnContinue();
virtual void OnControl() = 0;
static PServiceProcess & Current();
void SetLogLevel(
PSystemLog::Level level
) { PSystemLog::GetTarget().SetThresholdLevel(level); }
PSystemLog::Level GetLogLevel() const { return PSystemLog::GetTarget().GetThresholdLevel(); }
/* Internal initialisation function called directly from
<code>main()</code>. The user should never call this function.
*/
virtual int InternalMain(void * arg = NULL);
protected:
// Member variables
PBoolean debugMode;
// Include platform dependent part of class
#ifdef _WIN32
#include "msos/ptlib/svcproc.h"
#else
#include "unix/ptlib/svcproc.h"
#endif
};
#endif // PTLIB_SERVICEPROCESS_H
// End Of File ///////////////////////////////////////////////////////////////
PProcess::buildNumber
WORD buildNumber
Definition: pprocess.h:715
PSystemLog::Level
Level
define the different error log levels
Definition: syslog.h:54
PProcess::status
CodeStatus status
Definition: pprocess.h:714
PProcess::minorVersion
WORD minorVersion
Definition: pprocess.h:713
pprocess.h
PServiceProcess::OnContinue
virtual void OnContinue()
Resume after the service was paused.
PProcess
This class represents an operating system process.
Definition: pprocess.h:227
PBoolean
BOOL PBoolean
Definition: object.h:102
PServiceProcess::GetLogLevel
PSystemLog::Level GetLogLevel() const
Get the current level for logging.
Definition: svcproc.h:132
PProcess::majorVersion
WORD majorVersion
Definition: pprocess.h:712
PServiceProcess::debugMode
PBoolean debugMode
Flag to indicate service is run in simulation mode.
Definition: svcproc.h:145
PServiceProcess
A process type that runs as a "background" service.
Definition: svcproc.h:49
syslog.h
PServiceProcess::OnStart
virtual PBoolean OnStart()=0
Called when the service is started.
PSystemLogTarget::GetThresholdLevel
PSystemLog::Level GetThresholdLevel() const
Get the current level for logging.
Definition: syslog.h:148
PServiceProcess::OnControl
virtual void OnControl()=0
The Control menu option was used in the SysTray menu.
PServiceProcess::OnPause
virtual PBoolean OnPause()
Called by the system when the service is to be paused.
PSystemLog::GetTarget
static PSystemLogTarget & GetTarget()
Get the current target/destination for system logging.
PServiceProcess::InternalMain
virtual int InternalMain(void *arg=NULL)
Main function for process, called from real main after initialisation.
PServiceProcess::OnStop
virtual void OnStop()
Called by the system when the service is stopped.
PServiceProcess::SetLogLevel
void SetLogLevel(PSystemLog::Level level)
Set the level at which errors are logged.
Definition: svcproc.h:123
PSystemLogTarget::SetThresholdLevel
void SetThresholdLevel(PSystemLog::Level level)
Set the level at which errors are logged.
Definition: syslog.h:139
PServiceProcess::Current
static PServiceProcess & Current()
Get the current service process object.
PProcess::CodeStatus
CodeStatus
Release status for the program.
Definition: pprocess.h:235
PServiceProcess::PServiceProcess
PServiceProcess(const char *manuf, const char *name, WORD majorVersion, WORD minorVersion, CodeStatus status, WORD buildNumber)
Create a new service process.