45std::vector<std::string>
47 std::vector<std::string> ids;
52std::vector<std::string>
53Route::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();
70Route::getParameter(
const std::string& routeID,
const std::string& param) {
71 const MSRoute* r = getRoute(routeID);
80Route::setParameter(
const std::string& routeID,
const std::string& key,
const std::string& value) {
87Route::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;
100 MSRoute* route =
new MSRoute(routeID, edges,
true,
nullptr, stops);
103 throw TraCIException(
"Could not add route '" + routeID +
"'.");
112Route::getRoute(
const std::string&
id) {
115 throw TraCIException(
"Route '" +
id +
"' is not known");
121std::shared_ptr<VariableWrapper>
122Route::makeWrapper() {
123 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
128Route::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
131 return wrapper->wrapStringList(objID, variable, getIDList());
133 return wrapper->wrapInt(objID, variable, getIDCount());
135 return wrapper->wrapStringList(objID, variable, getEdges(objID));
138 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->
readString()));
141 return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, paramData->
readString()));
std::vector< const MSEdge * > ConstMSEdgeVector
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
#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....
const ConstMSEdgeVector & getEdges() const
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
static void insertIDs(std::vector< std::string > &into)
virtual 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.
virtual std::string readString()
virtual int readUnsignedByte()
TRACI_CONST int VAR_EDGES
TRACI_CONST int TRACI_ID_LIST
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_PARAMETER_WITH_KEY