OSDN Git Service

initial files
[iptd/iPTd_R3.git] / src / Raym / Service.h
1 /**\r
2  * @file Service.h\r
3  *\r
4  */\r
5 \r
6 #pragma once\r
7 \r
8 #ifdef _WIN32\r
9 #include <windows.h>\r
10 #endif\r
11 \r
12 #include "Raym/Object.h"\r
13 \r
14 namespace Raym\r
15 {\r
16 \r
17 class Service : public Object\r
18 {\r
19 private:\r
20     LPWSTR  _serviceName;\r
21     SERVICE_STATUS_HANDLE   _serviceStatus;\r
22 \r
23 protected:\r
24     Service();\r
25     ~Service();\r
26 \r
27 public:\r
28     static Service *alloc();\r
29     virtual Service *init(LPWSTR serviceName);\r
30     void serviceMain(DWORD dwArgc, PTSTR *pszArgv);\r
31     bool setServiceStatus(SERVICE_STATUS *ss);\r
32     virtual void start();\r
33     virtual void stop();\r
34 \r
35     void sleep();\r
36     void shutdown();\r
37     void cancelShutdown();\r
38     bool setWakeSchedule(int year, int month, int day, int hour, int min);\r
39     void resetWakeSchedule();\r
40 \r
41     static const char *GetHomeDirectory();\r
42     static const char *GetExecutePath();\r
43     static const char *GetPublicDirectory();\r
44 \r
45     // Win32 サービスのエントリポイント\r
46     static int main(Service *(*allocator)(), LPWSTR serviceName, int argc, char *argv[]);\r
47 };\r
48 \r
49 } // Raym\r
50 \r
51 #define ServiceMain(SVCCLASS, SVCNAME, ARGC, ARGV) Raym::Service::main((Raym::Service *(*)())SVCCLASS::alloc, SVCNAME, ARGC, ARGV)\r