Commit 4ab4167b authored by Martin Kröning's avatar Martin Kröning

Pass window title on MapApp construction

parent d7e8027f
......@@ -10,7 +10,7 @@ class Junction;
class Map {
public:
explicit Map(std::istream &is);
Map(std::istream &is, const std::string &windowTitle);
void simulate(std::chrono::seconds duration, double speedFactor,
double frequency);
......
......@@ -7,7 +7,7 @@ struct MapApp;
class MapAppABIWrapper {
public:
MapAppABIWrapper();
MapAppABIWrapper(const std::string &windowTitle);
virtual ~MapAppABIWrapper();
void addJunction(double x, double y);
void addRoad(const std::string &laneThereName,
......
......@@ -14,7 +14,8 @@
#include <utility>
#include <vector>
Map::Map(std::istream &is) : time(0) {
Map::Map(std::istream &is, const std::string &windowTitle)
: time(0), mapApp(windowTitle) {
std::string type;
while (is >> type) {
if (type == "KREUZUNG") {
......
......@@ -3,7 +3,8 @@
#include <string>
#include <vector>
MapAppABIWrapper::MapAppABIWrapper() : mapApp(mapAppCreate()) {}
MapAppABIWrapper::MapAppABIWrapper(const std::string &windowTitle)
: mapApp(mapAppCreate(windowTitle.c_str())) {}
MapAppABIWrapper::~MapAppABIWrapper() {
mapAppDestroy(mapApp);
......
......@@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
std::string durationString;
double timescale;
double refreshRate;
std::string filename;
std::string nativePathname;
po::options_description visibleOptions("Allowed options");
visibleOptions.add_options()(
......@@ -27,8 +27,8 @@ int main(int argc, char *argv[]) {
"help", "display this help and exit");
po::options_description hiddenOptions("Hidden options");
hiddenOptions.add_options()("input-file", po::value<std::string>(&filename),
"input file");
hiddenOptions.add_options()(
"input-file", po::value<std::string>(&nativePathname), "input file");
po::options_description allOptions;
allOptions.add(visibleOptions).add(hiddenOptions);
......@@ -53,9 +53,9 @@ int main(int argc, char *argv[]) {
}
if (variablesMap.count("input-file") > 0) {
std::ifstream istrm(filename);
std::ifstream istrm(nativePathname);
if (istrm.is_open()) {
Map map(istrm);
Map map(istrm, "pi2-demo - " + nativePathname);
std::istringstream buffer(durationString);
int hours;
......@@ -74,7 +74,7 @@ int main(int argc, char *argv[]) {
map.simulate(duration, timescale, refreshRate);
std::cout << "Simulation done!" << std::endl;
} else {
std::cout << "Failed to open " << filename << std::endl;
std::cout << "Failed to open " << nativePathname << std::endl;
return 1;
}
} else {
......
......@@ -22,7 +22,7 @@ class ListBoxRow;
class MapApp {
public:
MapApp();
MapApp(std::string windowTitle);
virtual ~MapApp();
void addJunction(double x, double y);
void addRoad(std::string laneThereName, std::string laneBackName,
......
......@@ -15,7 +15,7 @@ struct MapApp;
/// You *have* to call mapAppDestroy(MapApp *) to avoid memory leaks.
///
/// \returns A pointer to the created MapApp
MapApp *mapAppCreate();
MapApp *mapAppCreate(const char *windowTitle);
/// Destroys \p mapApp and frees its memory.
void mapAppDestroy(MapApp *mapApp);
......
......@@ -28,13 +28,13 @@
const std::vector<std::string> MapApp::zoomLevels = {"60%", "80%", "100%"};
MapApp::MapApp()
MapApp::MapApp(std::string windowTitle)
: app(Gtk::Application::create()),
mapArea(junctions, roads, nameVehicleMap), listBox(nullptr),
durationLabel(nullptr), laneLabel(nullptr),
lanePositionPercentageLabel(nullptr), speedLabel(nullptr),
remainingFuelLabel(nullptr), zoomComboBoxText(nullptr) {
win.set_title("pi2-demo");
win.set_title(std::move(windowTitle));
auto builder =
Gtk::Builder::create_from_resource("/pi2-view/pi2-view.glade", "box");
......
......@@ -11,7 +11,9 @@
#include <valarray>
#include <vector>
gsl::owner<MapApp *> mapAppCreate() { return new MapApp(); }
gsl::owner<MapApp *> mapAppCreate(gsl::czstring<> windowTitle) {
return new MapApp(windowTitle);
}
void mapAppDestroy(gsl::owner<MapApp *> mapApp) { delete mapApp; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment