Eclipse SUMO - Simulation of Urban MObility
libsumocpp2c.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2020-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // Implementation of the libsumo c++ to c wrapper
19 /****************************************************************************/
20 
21 #include <stdlib.h>
22 #include <libsumo/TraCIDefs.h>
23 #include <libsumo/Simulation.h>
25 #include <libsumo/Vehicle.h>
26 #include <sstream>
27 
28 #include "libsumocpp2c.h"
29 
30 void
31 libsumo_load(char* callOptions) {
32 
33  std::cout << "Calling libsumo with the following options:" << std::endl;
34  std::cout << "\"" << callOptions << "\"" << std::endl;
35 
36  // Tokenize the string, because Simulation::load expects a vector
37  std::vector<std::string> options;
38  std::stringstream ss(callOptions);
39  std::string temp_str;
40  while (std::getline(ss, temp_str, ' ')) {
41  options.push_back(temp_str);
42  }
43 
44  try {
45  libsumo::Simulation::load(options);
46  } catch (const libsumo::TraCIException& e) {
47  std::cerr << "libsumo::Simulation::load() failed - reason: " << e.what() << std::endl;
48  abort();
49  }
50 }
51 
52 int
54  return libsumo::Vehicle::getIDCount();
55 }
56 
57 void
59  libsumo::Simulation::close();
60 }
61 
62 void
63 libsumo_step(double time) {
64  libsumo::Simulation::step(time);
65 }
void libsumo_load(char *callOptions)
int libsumo_vehicle_getIDCount()
void libsumo_close()
void libsumo_step(double time)