00001 /* 00002 * svcproc.h 00003 * 00004 * Service Process (daemon) class. 00005 * 00006 * Portable Windows Library 00007 * 00008 * Copyright (c) 1993-1998 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Portable Windows Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Portions are Copyright (C) 1993 Free Software Foundation, Inc. 00025 * All Rights Reserved. 00026 * 00027 * Contributor(s): ______________________________________. 00028 * 00029 * $Revision: 24177 $ 00030 * $Author: rjongbloed $ 00031 * $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $ 00032 */ 00033 00034 #ifndef PTLIB_SERVICEPROCESS_H 00035 #define PTLIB_SERVICEPROCESS_H 00036 00037 #ifdef P_USE_PRAGMA 00038 #pragma interface 00039 #endif 00040 00041 #include <ptlib/pprocess.h> 00042 #include <ptlib/syslog.h> 00043 00044 00045 00049 class PServiceProcess : public PProcess 00050 { 00051 PCLASSINFO(PServiceProcess, PProcess); 00052 00053 public: 00058 PServiceProcess( 00059 const char * manuf, 00060 const char * name, 00061 WORD majorVersion, 00062 WORD minorVersion, 00063 CodeStatus status, 00064 WORD buildNumber 00065 ); 00067 00077 virtual PBoolean OnStart() = 0; 00078 00083 virtual void OnStop(); 00084 00093 virtual PBoolean OnPause(); 00094 00097 virtual void OnContinue(); 00098 00101 virtual void OnControl() = 0; 00103 00111 static PServiceProcess & Current(); 00112 00113 00123 void SetLogLevel( 00124 PSystemLog::Level level 00125 ) { PSystemLog::GetTarget().SetThresholdLevel(level); } 00126 00132 PSystemLog::Level GetLogLevel() const { return PSystemLog::GetTarget().GetThresholdLevel(); } 00134 00135 00136 /* Internal initialisation function called directly from 00137 <code>main()</code>. The user should never call this function. 00138 */ 00139 virtual int InternalMain(void * arg = NULL); 00140 00141 00142 protected: 00143 // Member variables 00145 PBoolean debugMode; 00146 00147 // Include platform dependent part of class 00148 #ifdef _WIN32 00149 #include "msos/ptlib/svcproc.h" 00150 #else 00151 #include "unix/ptlib/svcproc.h" 00152 #endif 00153 }; 00154 00155 00156 #endif // PTLIB_SERVICEPROCESS_H 00157 00158 00159 // End Of File ///////////////////////////////////////////////////////////////