-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
rscapp.cpp
152 lines (137 loc) · 5.11 KB
/
rscapp.cpp
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//==============================================================================
//
// rscapp.cpp
//
// Copyright (C) 2013-2022 Greg Utas
//
// This file is part of the Robust Services Core (RSC).
//
// RSC is free software: you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later
// version.
//
// RSC is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License along
// with RSC. If not, see <http://www.gnu.org/licenses/>.
//
//------------------------------------------------------------------------------
#include <ostream>
#include <system_error>
#include "Debug.h"
#include "FileSystem.h"
#include "Log.h"
#include "MainArgs.h"
#include "RootThread.h"
#include "SignalException.h"
#include "Singleton.h"
#include "SysConsole.h"
#include "SysTypes.h"
//------------------------------------------------------------------------------
//
// CreateModules() creates the module for each application that can be enabled,
// and each of those modules also creates the modules on which it depends.
// Each module resides in its own static library, and all the files that
// belong to that library reside in a folder with the same name. The following
// table summarizes module dependencies (@ = an application)
//
// dependencies
// namespace module library nb nt ct nw sb st mb cb pb cn
// --------- ------ ------- -----------------------------
// NodeBase NbModule nb
// NodeTools NtModule nt **
// NetworkBase NwModule nw **
// CodeTools CtModule @ ct ** **
// SessionBase SbModule sb ** **
// SessionTools StModule st ** ** ** **
// MediaBase MbModule mb ** ** **
// CallBase CbModule cb ** ** ** ** ** **
// PotsBase PbModule pb ** ** ** ** ** ** **
// ControlNode CnModule @ cn ** ** **
// RoutingNode RnModule @ rn ** ** ** ** **
// AccessNode AnModule @ an ** ** ** ** ** **
// ServiceNode SnModule @ sn ** ** ** ** ** **
// OperationsNode OnModule @ on ** ** ** ** ** ** **
// Diplomacy DipModule @ dip ** **
// none rscapp.cpp none the desired subset of applications
//
// By default, only NtModule is included in this build. To include other
// applications, remove the appropriate //& comments. To include your own
// application,
// (a) create its module in CreateModules, below;
// (b) have its module pass a symbol to the base Module constructor; and
// (c) add that symbol to the OptionalModules configuration parameter in
// the configuration file (by default, rsc/input/element.config.txt)
// (d) remove a symbol from OptionalModules if you don't create its module
//
//& #include "AnModule.h"
//& #include "CnModule.h"
//& #include "CtModule.h"
//& #include "DipModule.h"
#include "NtModule.h"
//& #include "OnModule.h"
//& #include "RnModule.h"
//& #include "SnModule.h"
using namespace NodeBase;
using namespace NodeTools;
//& using namespace CodeTools;
//& using namespace OperationsNode;
//& using namespace ControlNode;
//& using namespace RoutingNode;
//& using namespace ServiceNode;
//& using namespace AccessNode;
//& using namespace Diplomacy;
//------------------------------------------------------------------------------
static void CreateModules()
{
Debug::ft("CreateModules");
Singleton<NtModule>::Instance();
//& Singleton<CtModule>::Instance();
//& Singleton<OnModule>::Instance();
//& Singleton<CnModule>::Instance();
//& Singleton<RnModule>::Instance();
//& Singleton<SnModule>::Instance();
//& Singleton<AnModule>::Instance();
//& Singleton<DipModule>::Instance();
}
//------------------------------------------------------------------------------
main_t main(int argc, char* argv[])
{
Debug::ft("main");
auto& outdev = SysConsole::Out();
try
{
// Echo and save the arguments. Create the desired
// modules and finish initializing the system.
//
outdev << "ROBUST SERVICES CORE" << CRLF;
MainArgs::EchoAndSaveArgs(argc, argv);
FileSystem::DisableFileOutput(true);
CreateModules();
return RootThread::Main();
}
catch(SignalException& sex)
{
return Log::TrapInMain(&sex, &sex, 0, sex.Stack());
}
catch(Exception& ex)
{
return Log::TrapInMain(&ex, &ex, 0, ex.Stack());
}
catch(std::system_error& se)
{
return Log::TrapInMain(nullptr, &se, se.code().value(), nullptr);
}
catch(std::exception& e)
{
return Log::TrapInMain(nullptr, &e, 0, nullptr);
}
catch(...)
{
return Log::TrapInMain(nullptr, nullptr, 0, nullptr);
}
}