CellModules
main.cpp
Go to the documentation of this file.
1
#include <
mecacell/mecacell.h
>
2
// #include <mecacellviewer/viewer.h>
3
#include "
scenarios/Scenario.hpp
"
4
#include "../modules/extraModules/sql/include/pluginSQL/PluginSQL.hpp"
5
#include <fstream>
6
7
using namespace
std
;
8
9
nlohmann::json
loadJsonConfig
(
const
string
&inputFileName)
10
{
11
//cout << "Reading Configuration File: " << inputFileName << endl;
12
nlohmann::json
config;
13
ifstream i(inputFileName,ifstream::in);
14
i >> config;
15
i.close();
16
return
config;
17
}
18
19
int
main
(
int
argc,
char
*argv[]) {
20
using
scenario_t
=
Scenario
;
21
22
string
configPath = argc > 1 ? argv[1] :
"../config/viewer.json"
;
23
nlohmann::json
configuration =
loadJsonConfig
(configPath);
24
25
scenario_t
scenario;
26
27
PluginSQL::PluginSQL<Cell>
pluginSQL(configuration[
"main"
],
true
);
28
scenario.
getWorld
().registerPlugin(pluginSQL);
29
30
scenario.
init
(configuration);
31
32
while
(!scenario.
stop
()){
33
scenario.
loop
();
34
}
35
return
0;
36
37
// MecacellViewer::Viewer<scenario_t> viewer(scenario);
38
// return viewer.exec();
39
}
Scenario.hpp
Defines the Scenario class for managing the simulation scenario.
PluginSQL::PluginSQL
Definition:
PluginSQL.hpp:13
Scenario
Manages the simulation scenario.
Definition:
Scenario.hpp:24
Scenario::getWorld
World & getWorld()
Gets the world of the scenario.
Definition:
Scenario.hpp:51
Scenario::init
void init(nlohmann::json config)
Initializes the scenario with a configuration.
Definition:
Scenario.hpp:159
Scenario::loop
void loop()
Runs the main loop of the scenario.
Definition:
Scenario.hpp:173
Scenario::stop
bool stop()
Checks if the scenario should stop.
Definition:
Scenario.hpp:185
nlohmann::basic_json
a class to store JSON values
Definition:
json.hpp:12931
mecacell.h
std
Provides common mathematical functions and vector operations.
Definition:
std.hpp:4
main
int main(int argc, char *argv[])
Definition:
main.cpp:19
loadJsonConfig
nlohmann::json loadJsonConfig(const string &inputFileName)
Definition:
main.cpp:9
src
main.cpp
Generated by
1.9.4