This repository has been archived by the owner on Oct 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
gcc_main.h
107 lines (89 loc) · 2.23 KB
/
gcc_main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "misc.h"
#include "compiler_specific_func.h"
#include "engine.h"
///
#define ID_MENUITEM_reloadBegin _APS_NEXT_COMMAND_VALUE
// global variable
extern int __argc;
extern _TCHAR** __targv;
class Mayu
{
Engine m_engine; /// engine
tomsgstream m_log; /** log stream (output to log
dialog's edit) */
Setting *m_setting; /// current setting
time_t m_startTime; /// mayu started at ...
public:
/// load setting
bool load()
{
Setting *newSetting = new Setting;
// check args
for (int i = 1; i < __argc; ++ i)
{
// set symbol
if (__targv[i][0] == _T('-') && __targv[i][1] == _T('D'))
newSetting->m_symbols.insert(__targv[i] + 2);
else if (_tcsicmp(__targv[i], "-v") == 0 || _tcsicmp(__targv[i], "--verbose") == 0)
m_log.setDebugLevel(1);
}
#if defined(WIN32)
newSetting->m_symbols.insert("WINDOWS");
#elif defined(__linux__)
newSetting->m_symbols.insert("LINUX");
#elif defined(__APPLE__)
newSetting->m_symbols.insert("MAC");
#endif
// load setting
if (!SettingLoader(&m_log, &m_log).load(newSetting))
{
delete newSetting;
Acquire a(&m_log, 0);
m_log << _T("error: failed to load.") << std::endl;
return false;
}
m_log << _T("successfully loaded.") << std::endl;
while (!m_engine.setSetting(newSetting))
#if defined(__linux__)
sleep(1);
# elif defined(__APPLE__)
sleep(1);
#endif
delete m_setting;
m_setting = newSetting;
return true;
}
Mayu()
:
#if defined(__linux__) || defined(__APPLE__)
m_log(),
#endif
m_setting(NULL),
m_engine(m_log)
{
#ifdef _DEBUG
m_log.setDebugLevel(1);
#else
#endif
time(&m_startTime);
#if 0
HomeDirectories pathes;
ggetHomeDirectories(&pathes);
for (HomeDirectories::iterator i = pathes.begin(); i != pathes.end(); ++ i)
if (SetCurrentDirectory(i->c_str()))
break;
#endif
}
///
~Mayu()
{
// stop keyboard handler thread
m_engine.stop();
// remove setting;
delete m_setting;
}
void taskLoop()
{
m_engine.start();
}
};