PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
30 #ifndef PTLIB_SERVICEPROCESS_H
31 #define PTLIB_SERVICEPROCESS_H
32 
33 #ifdef P_USE_PRAGMA
34 #pragma interface
35 #endif
36 
37 #include <ptlib/pprocess.h>
38 #include <ptlib/syslog.h>
39 
40 
41 
45 class PServiceProcess : public PProcess
46 {
47  PCLASSINFO(PServiceProcess, PProcess);
48 
49  public:
55  const char * manuf,
56  const char * name,
57  unsigned majorVersion,
58  unsigned minorVersion,
59  CodeStatus status,
60  unsigned patchVersion,
61  unsigned oemVersion = 0
62  );
64 
71  virtual void Main();
72 
82  virtual PBoolean OnStart() = 0;
83 
90  virtual void OnStop();
91 
100  virtual PBoolean OnPause();
101 
104  virtual void OnContinue();
105 
108  virtual void OnControl();
110 
118  static PServiceProcess & Current();
119 
120 #if P_SYSTEMLOG
121 
130  void SetLogLevel(
131  PSystemLog::Level level
132  );
133 
139  PSystemLog::Level GetLogLevel() const { return PSystemLog::GetTarget().GetThresholdLevel(); }
140 #endif
141 
142 
143 
144  /* Internal initialisation function called directly from
145  <code>main()</code>. The user should never call this function.
146  */
147  virtual int InternalMain(void * arg = NULL);
148 
149 
150  virtual bool IsServiceProcess() const;
151 
152 
153  protected:
154  // Member variables
156 
159 
160 // Include platform dependent part of class
161 #ifdef _WIN32
162 #include "msos/ptlib/svcproc.h"
163 #else
164 #include "unix/ptlib/svcproc.h"
165 #endif
166 };
167 
168 
169 #endif // PTLIB_SERVICEPROCESS_H
170 
171 
172 // End Of File ///////////////////////////////////////////////////////////////
virtual void OnControl()
The Control menu option was used in the SysTray menu.
bool m_debugMode
Flag to indicate service is run in simulation mode.
Definition: svcproc.h:158
virtual void OnContinue()
Resume after the service was paused.
This class represents an operating system process.
Definition: pprocess.h:106
A process type that runs as a &quot;background&quot; service.
Definition: svcproc.h:45
virtual PBoolean OnStart()=0
Called when the service is started.
bool PBoolean
Definition: object.h:174
virtual void Main()
User override function for the main execution routine of the thread.
virtual PBoolean OnPause()
Called by the system when the service is to be paused.
PServiceProcess(const char *manuf, const char *name, unsigned majorVersion, unsigned minorVersion, CodeStatus status, unsigned patchVersion, unsigned oemVersion=0)
Create a new service process.
virtual bool IsServiceProcess() const
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.
PSyncPoint m_exitMain
Definition: svcproc.h:155
static PServiceProcess & Current()
Get the current service process object.
CodeStatus
Release status for the program.
Definition: pprocess.h:114
This class defines a thread synchronisation object.
Definition: syncpoint.h:63