45std::vector<std::string>
48 std::vector<std::string> ids;
53std::vector<std::string>
54Route::getEdges(
const std::string& routeID) {
56 std::vector<std::string> ids;
57 for (ConstMSEdgeVector::const_iterator i = r->getEdges().begin(); i != r->getEdges().end(); ++i) {
58 ids.push_back((*i)->getID());
66 return (
int)getIDList().size();
71Route::getParameter(
const std::string& routeID,
const std::string& param) {
73 return r->getParameter(param,
"");
81Route::setParameter(
const std::string& routeID,
const std::string& key,
const std::string& value) {
88Route::add(
const std::string& routeID,
const std::vector<std::string>& edgeIDs) {
90 if (edgeIDs.size() == 0) {
91 throw TraCIException(
"Cannot add route '" + routeID +
"' without edges.");
93 for (std::vector<std::string>::const_iterator ei = edgeIDs.begin(); ei != edgeIDs.end(); ++ei) {
95 if (edge ==
nullptr) {
96 throw TraCIException(
"Unknown edge '" + *ei +
"' in route.");
98 edges.push_back(edge);
100 const std::vector<SUMOVehicleParameter::Stop> stops;
101 ConstMSRoutePtr route = std::make_shared<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
std::shared_ptr< const MSRoute > ConstMSRoutePtr
#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....
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
static void insertIDs(std::vector< std::string > &into)
static bool dictionary(const std::string &id, ConstMSRoutePtr route)
Adds a route to the dictionary.
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