Alternate e697dbe9c5997e35395fe158628dd8c5209481da
for Visual Studio 2022 and Windows 11.
読み取り中…
検索中…
一致する文字列を見つけられません
ConsoleDriver.cpp
[詳解]
1
5
6#include "pch.h"
7#include "ConsoleDriver.h"
8#include "DesignPattern.hpp"
9#include "TString.h"
10#include "Console.h"
12#include "File.h"
13#include "FileUtility.h"
14
18
19volatile bool __loopKeep = true;
20
25int _tmain (int argc, TCHAR* argv[])
26{
27 _tprintf (_T ("main(%d, TCHAR*) IN.\n"), argc);
28
29 if (argc == 3)
30 {
31 _configFile = argv[2];
32 BOOL bCheck = alt::FileUtility::IsExist (_configFile.Ctr ());
33 if (!bCheck)
34 {
35 _tprintf (_T ("Can't find config file.\n"));
36 return 1;
37 }
38
39 lstrcpy (_action.Ptr (), argv[1]);
40 }
41
42 if (argc == 2)
43 {
46 if (!bCheck)
47 {
48 _tprintf (_T ("Can't find config file.\n"));
49 return 1;
50 }
51
52 lstrcpy (_action.Ptr (), argv[1]);
53 }
54
55 if (argc == 1)
56 {
59 if (!bCheck)
60 {
61 _tprintf (_T ("Can't find config file.\n"));
62 return 1;
63 }
64
65 DWORD dwRet = ::GetPrivateProfileString (SECTION_GENERAL, KEYWORD_ACTION, nullptr, _action.Ptr (), MAX_PATH, _configFile.Ctr ());
66 if (dwRet == 0)
67 {
68 _tprintf (_T ("Can't find action.\n"));
69 return 1;
70 }
71 }
72
73 Init ();
74
75 auto target = _strategy.Get (_action.Ptr ());
76 if (target)
77 {
78 target ();
79 }
80 else
81 {
82 _tprintf (_T ("Invalid Parameter %s\n"), _action.Ctr ());
83 return 2;
84 }
85
86 _tprintf (_T ("main(%d, TCHAR*) OUT.\n"), argc);
87 return 0;
88}
89
92void Init ()
93{
94 _tprintf (_T ("Init() IN.\n"));
95
97
98 _tprintf (_T ("Init() OUT.\n"));
99}
100
102{
103 _tprintf (_T ("DrivePipelineFactoryHandler(%d) IN.\n"), dwType);
104
105 BOOL ret = false;
106
107 timeEndPeriod (1);
108
109 switch (dwType)
110 {
111 case 0: // Ctrl + C
112 case 1: // Ctrl + Break
113 __loopKeep = false;
114 ret = TRUE; // 終了させません。
115 break;
116
117 case 2: // Console Close
118 case 3: // Log off
119 case 4: // Shut down
120 ret = FALSE; // 次に委ねます。
121 break;
122 }
123
124 _tprintf (_T ("DrivePipelineFactoryHandler(%d) OUT.\n"), dwType);
125 return ret;
126}
127
129{
130 _tprintf (_T ("DrivePipelineFactory() IN.\n"));
131
132 timeBeginPeriod (1);
133
134 bool ret;
135
136 auto factory = new alt::FactoryMethod::PipelineFactoryMethod ();
137 auto manager = (alt::FactoryMethod::ProductManager*)factory->Buildup ();
138 auto config = new alt::FactoryMethod::Config ();
139 ret = config->Load (_configFile.Ctr ());
140 if (ret == false)
141 {
142 _tprintf (_T ("Error:config->Load()\n"));
143 return;
144 }
145
146 manager->Init (config);
147
148 while (__loopKeep)
149 {
150 manager->Start ();
151
152 Sleep (30000); // 30秒
153
154 manager->Stop ();
155
156 Sleep (3000); // 3秒
157 }
158
159 manager->Exit ();
160
161 Sleep (10000); // 10秒
162
163 _tprintf (_T ("DrivePipelineFactory() OUT.\n"));
164}
コンソールに関するWindowsAPIを集約したクラス
void Init()
ストラテジーの初期化を行います。
alt::TString _configFile
BOOL DrivePipelineFactoryHandler(DWORD dwType)
volatile bool __loopKeep
int _tmain(int argc, TCHAR *argv[])
エントリーポイント(メイン関数)です。
alt::skeleton::Strategy< alt::TString, std::function< void()> > _strategy
void DrivePipelineFactory()
alt::TString _action(MAX_PATH)
Consoleからシステムを起動します。
#define CONFIG_FILE
Definition: ConsoleDriver.h:10
#define SECTION_PIPELINE_FACTORY
Definition: ConsoleDriver.h:15
#define KEYWORD_ACTION
Definition: ConsoleDriver.h:13
#define SECTION_GENERAL
Definition: ConsoleDriver.h:12
種々のデザインパターンの実装クラス
ファイルIOに関するWindowsAPIを集約したクラス
ファイルハンドルを伴わないファイルIOに関するWindowsAPIを集約した クラス
文字列に関するWindowsAPIを集約したクラス
プリコンパイル済みヘッダー ファイルです。
static BOOL APIENTRY IsExist(LPCTSTR name)
ディレクトリ・ファイルの存在確認
文字列に関するWindowsAPIを集約したクラス
Definition: TString.h:17
LPCTSTR APIENTRY Ctr() const
内部で確保している文字列ポインタを取得します。
Definition: TString.h:46
LPTSTR APIENTRY Ptr() const
内部で確保している文字列ポインタを取得します。
Definition: TString.h:42