PTLib  Version 2.10.10
svcproc.h
Go to the documentation of this file.
1 /*
2  * svcproc.h
3  *
4  * Service Process (daemon) class.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25  * All Rights Reserved.
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 24177 $
30  * $Author: rjongbloed $
31  * $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
32  */
33 
34 #ifndef PTLIB_SERVICEPROCESS_H
35 #define PTLIB_SERVICEPROCESS_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 #include <ptlib/pprocess.h>
42 #include <ptlib/syslog.h>
43 
44 
45 
49 class PServiceProcess : public PProcess
50 {
51  PCLASSINFO(PServiceProcess, PProcess);
52 
53  public:
59  const char * manuf,
60  const char * name,
61  WORD majorVersion,
62  WORD minorVersion,
64  WORD buildNumber
65  );
67 
77  virtual PBoolean OnStart() = 0;
78 
83  virtual void OnStop();
84 
93  virtual PBoolean OnPause();
94 
97  virtual void OnContinue();
98 
101  virtual void OnControl() = 0;
103 
111  static PServiceProcess & Current();
112 
113 
124  PSystemLog::Level level
126 
134 
135 
136  /* Internal initialisation function called directly from
137  <code>main()</code>. The user should never call this function.
138  */
139  virtual int InternalMain(void * arg = NULL);
140 
141 
142  protected:
143  // Member variables
146 
147 // Include platform dependent part of class
148 #ifdef _WIN32
149 #include "msos/ptlib/svcproc.h"
150 #else
151 #include "unix/ptlib/svcproc.h"
152 #endif
153 };
154 
155 
156 #endif // PTLIB_SERVICEPROCESS_H
157 
158 
159 // End Of File ///////////////////////////////////////////////////////////////
WORD buildNumber
Definition: pprocess.h:715
Level
define the different error log levels
Definition: syslog.h:54
CodeStatus status
Definition: pprocess.h:714
WORD minorVersion
Definition: pprocess.h:713
virtual void OnContinue()
Resume after the service was paused.
This class represents an operating system process.
Definition: pprocess.h:227
BOOL PBoolean
Definition: object.h:102
PSystemLog::Level GetLogLevel() const
Get the current level for logging.
Definition: svcproc.h:132
WORD majorVersion
Definition: pprocess.h:712
PBoolean debugMode
Flag to indicate service is run in simulation mode.
Definition: svcproc.h:145
A process type that runs as a "background" service.
Definition: svcproc.h:49
virtual PBoolean OnStart()=0
Called when the service is started.
PSystemLog::Level GetThresholdLevel() const
Get the current level for logging.
Definition: syslog.h:148
virtual void OnControl()=0
The Control menu option was used in the SysTray menu.
virtual PBoolean OnPause()
Called by the system when the service is to be paused.
static PSystemLogTarget & GetTarget()
Get the current target/destination for system logging.
virtual int InternalMain(void *arg=NULL)
Main function for process, called from real main after initialisation.
virtual void OnStop()
Called by the system when the service is stopped.
void SetLogLevel(PSystemLog::Level level)
Set the level at which errors are logged.
Definition: svcproc.h:123
void SetThresholdLevel(PSystemLog::Level level)
Set the level at which errors are logged.
Definition: syslog.h:139
static PServiceProcess & Current()
Get the current service process object.
CodeStatus
Release status for the program.
Definition: pprocess.h:235
PServiceProcess(const char *manuf, const char *name, WORD majorVersion, WORD minorVersion, CodeStatus status, WORD buildNumber)
Create a new service process.