PTLib  Version 2.14.3
 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  * $Revision: 31373 $
30  * $Author: rjongbloed $
31  * $Date: 2014-02-06 14:46:18 +1100 (Thu, 06 Feb 2014) $
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  unsigned majorVersion,
62  unsigned minorVersion,
64  unsigned buildNumber
65  );
67 
74  virtual void Main();
75 
85  virtual PBoolean OnStart() = 0;
86 
93  virtual void OnStop();
94 
103  virtual PBoolean OnPause();
104 
107  virtual void OnContinue();
108 
111  virtual void OnControl() = 0;
113 
121  static PServiceProcess & Current();
122 
123 
133  void SetLogLevel(
134  PSystemLog::Level level
135  );
136 
142  PSystemLog::Level GetLogLevel() const { return PSystemLog::GetTarget().GetThresholdLevel(); }
144 
145 
146  /* Internal initialisation function called directly from
147  <code>main()</code>. The user should never call this function.
148  */
149  virtual int InternalMain(void * arg = NULL);
150 
151 
152  protected:
153  // Member variables
155 
158 
159 // Include platform dependent part of class
160 #ifdef _WIN32
161 #include "msos/ptlib/svcproc.h"
162 #else
163 #include "unix/ptlib/svcproc.h"
164 #endif
165 };
166 
167 
168 #endif // PTLIB_SERVICEPROCESS_H
169 
170 
171 // End Of File ///////////////////////////////////////////////////////////////