CellModules
main.cpp
Go to the documentation of this file.
1#include <mecacell/mecacell.h>
2// #include <mecacellviewer/viewer.h>
4#include "../modules/extraModules/sql/include/pluginSQL/PluginSQL.hpp"
5#include <fstream>
6
7using namespace std;
8
9nlohmann::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
19int 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}
Defines the Scenario class for managing the simulation scenario.
Manages the simulation scenario.
Definition: Scenario.hpp:24
World & getWorld()
Gets the world of the scenario.
Definition: Scenario.hpp:51
void init(nlohmann::json config)
Initializes the scenario with a configuration.
Definition: Scenario.hpp:159
void loop()
Runs the main loop of the scenario.
Definition: Scenario.hpp:173
bool stop()
Checks if the scenario should stop.
Definition: Scenario.hpp:185
a class to store JSON values
Definition: json.hpp:12931
Provides common mathematical functions and vector operations.
Definition: std.hpp:4
int main(int argc, char *argv[])
Definition: main.cpp:19
nlohmann::json loadJsonConfig(const string &inputFileName)
Definition: main.cpp:9