45 std::vector<std::string>
47 std::vector<std::string> ids;
52 std::vector<std::string>
53 Route::getEdges(
const std::string& routeID) {
54 const MSRoute* r = getRoute(routeID);
55 std::vector<std::string> ids;
56 for (ConstMSEdgeVector::const_iterator i = r->
getEdges().begin(); i != r->
getEdges().end(); ++i) {
57 ids.push_back((*i)->getID());
65 return (
int)getIDList().size();
70 Route::getParameter(
const std::string& routeID,
const std::string& param) {
71 const MSRoute* r = getRoute(routeID);
80 Route::setParameter(
const std::string& routeID,
const std::string& key,
const std::string& value) {
87 Route::add(
const std::string& routeID,
const std::vector<std::string>& edgeIDs) {
89 if (edgeIDs.size() == 0) {
90 throw TraCIException(
"Cannot add route '" + routeID +
"' without edges.");
92 for (std::vector<std::string>::const_iterator ei = edgeIDs.begin(); ei != edgeIDs.end(); ++ei) {
94 if (edge ==
nullptr) {
95 throw TraCIException(
"Unknown edge '" + *ei +
"' in route.");
97 edges.push_back(edge);
99 const std::vector<SUMOVehicleParameter::Stop> stops;
101 throw TraCIException(
"Could not add route.");
110 Route::getRoute(
const std::string&
id) {
113 throw TraCIException(
"Route '" +
id +
"' is not known");
119 std::shared_ptr<VariableWrapper>
120 Route::makeWrapper() {
121 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
126 Route::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper) {
129 return wrapper->wrapStringList(objID, variable, getIDList());
131 return wrapper->wrapInt(objID, variable, getIDCount());
133 return wrapper->wrapStringList(objID, variable, getEdges(objID));
std::vector< const MSEdge * > ConstMSEdgeVector
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
A road/street connecting two junctions.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
static void insertIDs(std::vector< std::string > &into)
const ConstMSEdgeVector & getEdges() const
const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
C++ TraCI client API implementation.
TRACI_CONST int VAR_EDGES
TRACI_CONST int TRACI_ID_LIST
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
std::map< std::string, SubscriptionResults > ContextSubscriptionResults