LCOV - code coverage report
Current view: top level - src/libsumo - TraCIDefs.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 36.7 % 324 119
Test Date: 2026-09-20 15:45:03 Functions: 38.8 % 49 19

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2012-2026 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              : /****************************************************************************/
      14              : /// @file    TraCIDefs.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Mario Krumnow
      17              : /// @author  Michael Behrisch
      18              : /// @author  Robert Hilbrich
      19              : /// @date    30.05.2012
      20              : ///
      21              : // C++ TraCI client API implementation
      22              : /****************************************************************************/
      23              : #pragma once
      24              : // we do not include config.h here, since we should be independent of a special sumo build
      25              : // but we want to avoid certain warnings in MSVC see config.h.cmake for details
      26              : #ifdef _MSC_VER
      27              : #pragma warning(push)
      28              : #pragma warning(disable: 4514 4820)
      29              : #endif
      30              : 
      31              : #include <libsumo/TraCIConstants.h>
      32              : #include <vector>
      33              : #include <limits>
      34              : #include <map>
      35              : #include <string>
      36              : #include <stdexcept>
      37              : #include <sstream>
      38              : #include <memory>
      39              : #include <cstring>
      40              : 
      41              : 
      42              : // ===========================================================================
      43              : // common declarations
      44              : // ===========================================================================
      45              : namespace libsumo {
      46              : class VariableWrapper;
      47              : }
      48              : namespace tcpip {
      49              : class Storage;
      50              : }
      51              : 
      52              : 
      53              : // ===========================================================================
      54              : // global definitions
      55              : // ===========================================================================
      56              : #ifdef LIBTRACI
      57              : #define LIBSUMO_NAMESPACE libtraci
      58              : #else
      59              : #define LIBSUMO_NAMESPACE libsumo
      60              : #endif
      61              : 
      62              : #define LIBSUMO_SUBSCRIPTION_API \
      63              : static void subscribe(const std::string& objectID, const std::vector<int>& varIDs = std::vector<int>({-1}), \
      64              :                       double begin = libsumo::INVALID_DOUBLE_VALUE, double end = libsumo::INVALID_DOUBLE_VALUE, const libsumo::TraCIResults& parameters = libsumo::TraCIResults()); \
      65              : static void unsubscribe(const std::string& objectID); \
      66              : static void subscribeContext(const std::string& objectID, int domain, double dist, const std::vector<int>& varIDs = std::vector<int>({-1}), \
      67              :                              double begin = libsumo::INVALID_DOUBLE_VALUE, double end = libsumo::INVALID_DOUBLE_VALUE, const libsumo::TraCIResults& parameters = libsumo::TraCIResults()); \
      68              : static void unsubscribeContext(const std::string& objectID, int domain, double dist); \
      69              : static const libsumo::SubscriptionResults getAllSubscriptionResults(); \
      70              : static const libsumo::TraCIResults getSubscriptionResults(const std::string& objectID); \
      71              : static const libsumo::ContextSubscriptionResults getAllContextSubscriptionResults(); \
      72              : static const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string& objectID); \
      73              : static void subscribeParameterWithKey(const std::string& objectID, const std::string& key, double beginTime = libsumo::INVALID_DOUBLE_VALUE, double endTime = libsumo::INVALID_DOUBLE_VALUE); \
      74              : static const int DOMAIN_ID; \
      75              : static int domainID() { return DOMAIN_ID; }
      76              : 
      77              : #define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM) \
      78              : const int CLASS::DOMAIN_ID(libsumo::CMD_GET_##DOM##_VARIABLE); \
      79              : void \
      80              : CLASS::subscribe(const std::string& objectID, const std::vector<int>& varIDs, double begin, double end, const libsumo::TraCIResults& parameters) { \
      81              :     libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_VARIABLE, objectID, varIDs, begin, end, parameters); \
      82              : } \
      83              : void \
      84              : CLASS::unsubscribe(const std::string& objectID) { \
      85              :     libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_VARIABLE, objectID, std::vector<int>(), libsumo::INVALID_DOUBLE_VALUE, libsumo::INVALID_DOUBLE_VALUE, libsumo::TraCIResults()); \
      86              : } \
      87              : void \
      88              : CLASS::subscribeContext(const std::string& objectID, int domain, double dist, const std::vector<int>& varIDs, double begin, double end, const TraCIResults& parameters) { \
      89              :     libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_CONTEXT, objectID, varIDs, begin, end, parameters, domain, dist); \
      90              : } \
      91              : void \
      92              : CLASS::unsubscribeContext(const std::string& objectID, int domain, double dist) { \
      93              :     libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_CONTEXT, objectID, std::vector<int>(), libsumo::INVALID_DOUBLE_VALUE, libsumo::INVALID_DOUBLE_VALUE, libsumo::TraCIResults(), domain, dist); \
      94              : } \
      95              : const libsumo::SubscriptionResults \
      96              : CLASS::getAllSubscriptionResults() { \
      97              :     return mySubscriptionResults; \
      98              : } \
      99              : const libsumo::TraCIResults \
     100              : CLASS::getSubscriptionResults(const std::string& objectID) { \
     101              :     return mySubscriptionResults[objectID]; \
     102              : } \
     103              : const libsumo::ContextSubscriptionResults \
     104              : CLASS::getAllContextSubscriptionResults() { \
     105              :     return myContextSubscriptionResults; \
     106              : } \
     107              : const libsumo::SubscriptionResults \
     108              : CLASS::getContextSubscriptionResults(const std::string& objectID) { \
     109              :     return myContextSubscriptionResults[objectID]; \
     110              : } \
     111              : void \
     112              : CLASS::subscribeParameterWithKey(const std::string& objectID, const std::string& key, double beginTime, double endTime) { \
     113              :     libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_VARIABLE, objectID, std::vector<int>({libsumo::VAR_PARAMETER_WITH_KEY}), beginTime, endTime, libsumo::TraCIResults {{libsumo::VAR_PARAMETER_WITH_KEY, std::make_shared<libsumo::TraCIString>(key)}}); \
     114              : }
     115              : 
     116              : 
     117              : #define LIBSUMO_ID_PARAMETER_API \
     118              : static std::vector<std::string> getIDList(); \
     119              : static int getIDCount(); \
     120              : static std::string getParameter(const std::string& objectID, const std::string& key); \
     121              : static const std::pair<std::string, std::string> getParameterWithKey(const std::string& objectID, const std::string& key); \
     122              : static void setParameter(const std::string& objectID, const std::string& key, const std::string& value);
     123              : 
     124              : #define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS) \
     125              : const std::pair<std::string, std::string> \
     126              : CLASS::getParameterWithKey(const std::string& objectID, const std::string& key) { \
     127              :     return std::make_pair(key, getParameter(objectID, key)); \
     128              : }
     129              : 
     130              : 
     131              : #define SWIGJAVA_CAST(CLASS) \
     132              : static std::shared_ptr<CLASS> cast(std::shared_ptr<TraCIResult> res) { \
     133              :     return std::dynamic_pointer_cast<CLASS>(res); \
     134              : }
     135              : 
     136              : 
     137              : // ===========================================================================
     138              : // class and type definitions
     139              : // ===========================================================================
     140              : namespace libsumo {
     141              : /**
     142              :  * @class TraCIException
     143              :  * @brief An error which allows to continue
     144              :  */
     145              : class TraCIException : public std::runtime_error {
     146              : public:
     147              :     /** constructor */
     148              :     TraCIException(std::string what)
     149         6741 :         : std::runtime_error(what) {}
     150              : };
     151              : 
     152              : /**
     153              :  * @class FatalTraCIError
     154              :  * @brief An error which is not recoverable
     155              :  */
     156              : class FatalTraCIError : public std::runtime_error {
     157              : public:
     158              :     /** constructor */
     159              :     FatalTraCIError(std::string what)
     160          103 :         : std::runtime_error(what) {}
     161              : };
     162              : 
     163              : /// @name Structures definitions
     164              : /// @{
     165              : 
     166              : struct TraCIResult {
     167       278186 :     TraCIResult() {}
     168            0 :     virtual ~TraCIResult() {}
     169              : #ifndef SWIG
     170       361871 :     TraCIResult(const TraCIResult&) = default;
     171              :     TraCIResult& operator=(const TraCIResult&) = default;
     172              : #endif
     173            0 :     virtual std::string getString() const {
     174            0 :         return "";
     175              :     }
     176           96 :     virtual int getType() const {
     177           96 :         return -1;
     178              :     }
     179              : };
     180              : 
     181              : /** @struct TraCIPosition
     182              :  * @brief A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE
     183              :  */
     184      9763734 : struct TraCIPosition : TraCIResult {
     185          138 :     std::string getString() const override {
     186          138 :         std::ostringstream os;
     187          276 :         os << "TraCIPosition(" << x << "," << y;
     188          138 :         if (z != INVALID_DOUBLE_VALUE) {
     189            5 :             os << "," << z;
     190              :         }
     191          138 :         os << ")";
     192          138 :         return os.str();
     193          138 :     }
     194           28 :     int getType() const override {
     195           28 :         return z != INVALID_DOUBLE_VALUE ? POSITION_3D : POSITION_2D;
     196              :     }
     197              :     double x = INVALID_DOUBLE_VALUE, y = INVALID_DOUBLE_VALUE, z = INVALID_DOUBLE_VALUE;
     198              : #ifdef SWIGJAVA
     199            0 :     SWIGJAVA_CAST(TraCIPosition)
     200              : #endif
     201              : };
     202              : 
     203              : /** @struct TraCIRoadPosition
     204              :  * @brief An edgeId, position and laneIndex
     205              :  */
     206         2151 : struct TraCIRoadPosition : TraCIResult {
     207        15765 :     TraCIRoadPosition(const std::string e = "", const double p = INVALID_DOUBLE_VALUE, const int li = INVALID_INT_VALUE) : edgeID(e), pos(p), laneIndex(li) {}
     208            2 :     std::string getString() const override {
     209            2 :         std::ostringstream os;
     210            4 :         os << "TraCIRoadPosition(" << edgeID << "_" << laneIndex << "," << pos << ")";
     211            2 :         return os.str();
     212            2 :     }
     213           20 :     int getType() const override {
     214           20 :         return POSITION_ROADMAP;
     215              :     }
     216              :     std::string edgeID;
     217              :     double pos;
     218              :     int laneIndex;
     219              : #ifdef SWIGJAVA
     220            0 :     SWIGJAVA_CAST(TraCIRoadPosition)
     221              : #endif
     222              : };
     223              : 
     224              : /** @struct TraCIColor
     225              :  * @brief A color
     226              :  */
     227         1639 : struct TraCIColor : TraCIResult {
     228         1584 :     TraCIColor() : r(0), g(0), b(0), a(255) {}
     229           78 :     TraCIColor(int r, int g, int b, int a = 255) : r(r), g(g), b(b), a(a) {}
     230            3 :     std::string getString() const override {
     231            3 :         std::ostringstream os;
     232           12 :         os << "TraCIColor(" << r << "," << g << "," << b << "," << a << ")";
     233            3 :         return os.str();
     234            3 :     }
     235              :     int r, g, b, a;
     236              : #ifdef SWIGJAVA
     237            0 :     SWIGJAVA_CAST(TraCIColor)
     238              : #endif
     239              : };
     240              : 
     241              : 
     242              : /** @struct TraCIPositionVector
     243              :  * @brief A list of positions
     244              :  */
     245       109180 : struct TraCIPositionVector : TraCIResult {
     246            3 :     std::string getString() const override {
     247            3 :         std::ostringstream os;
     248            3 :         os << "[";
     249           20 :         for (const TraCIPosition& v : value) {
     250           51 :             os << "(" << v.x << "," << v.y << "," << v.z << ")";
     251              :         }
     252            3 :         os << "]";
     253            3 :         return os.str();
     254            3 :     }
     255              :     std::vector<TraCIPosition> value;
     256              : #ifdef SWIGJAVA
     257            0 :     SWIGJAVA_CAST(TraCIPositionVector)
     258              : #endif
     259              : };
     260              : 
     261              : 
     262              : struct TraCIInt : TraCIResult {
     263        18337 :     TraCIInt(int v = 0, int t = libsumo::TYPE_INTEGER) : value(v), traciType(t) {}
     264            0 :     std::string getString() const override {
     265            0 :         std::ostringstream os;
     266            0 :         os << value;
     267            0 :         return os.str();
     268            0 :     }
     269          216 :     int getType() const override {
     270          216 :         return traciType;
     271              :     }
     272              :     int value;
     273              :     int traciType;
     274              : #ifdef SWIGJAVA
     275            0 :     SWIGJAVA_CAST(TraCIInt)
     276              : #endif
     277              : };
     278              : 
     279              : 
     280              : struct TraCIDouble : TraCIResult {
     281        48350 :     TraCIDouble(double v = 0.) : value(v) {}
     282          132 :     std::string getString() const override {
     283          132 :         std::ostringstream os;
     284          132 :         os << value;
     285          132 :         return os.str();
     286          132 :     }
     287          639 :     int getType() const override {
     288          639 :         return libsumo::TYPE_DOUBLE;
     289              :     }
     290              :     double value;
     291              : #ifdef SWIGJAVA
     292            0 :     SWIGJAVA_CAST(TraCIDouble)
     293              : #endif
     294              : };
     295              : 
     296              : 
     297              : struct TraCIString : TraCIResult {
     298        36147 :     TraCIString(std::string v = "") : value(v) {}
     299          141 :     std::string getString() const override {
     300          141 :         return value;
     301              :     }
     302         1260 :     int getType() const override {
     303         1260 :         return libsumo::TYPE_STRING;
     304              :     }
     305              :     std::string value;
     306              : #ifdef SWIGJAVA
     307            0 :     SWIGJAVA_CAST(TraCIString)
     308              : #endif
     309              : };
     310              : 
     311              : 
     312         2055 : struct TraCIStringList : TraCIResult {
     313            0 :     std::string getString() const override {
     314            0 :         std::ostringstream os;
     315            0 :         os << "[";
     316            0 :         for (std::string v : value) {
     317            0 :             os << v << ",";
     318              :         }
     319            0 :         os << "]";
     320            0 :         return os.str();
     321            0 :     }
     322              :     std::vector<std::string> value;
     323              : #ifdef SWIGJAVA
     324           30 :     SWIGJAVA_CAST(TraCIStringList)
     325              : #endif
     326              : };
     327              : 
     328              : 
     329            8 : struct TraCIDoubleList : TraCIResult {
     330            0 :     std::string getString() const override {
     331            0 :         std::ostringstream os;
     332            0 :         os << "[";
     333            0 :         for (double v : value) {
     334            0 :             os << v << ",";
     335              :         }
     336            0 :         os << "]";
     337            0 :         return os.str();
     338            0 :     }
     339              :     std::vector<double> value;
     340              : #ifdef SWIGJAVA
     341            0 :     SWIGJAVA_CAST(TraCIDoubleList)
     342              : #endif
     343              : };
     344              : 
     345              : 
     346            4 : struct TraCIIntList : TraCIResult {
     347            0 :     std::string getString() const override {
     348            0 :         std::ostringstream os;
     349            0 :         os << "[";
     350            0 :         for (int v : value) {
     351            0 :             os << v << ",";
     352              :         }
     353            0 :         os << "]";
     354            0 :         return os.str();
     355            0 :     }
     356              :     std::vector<int> value;
     357              : #ifdef SWIGJAVA
     358            0 :     SWIGJAVA_CAST(TraCIIntList)
     359              : #endif
     360              : };
     361              : 
     362              : 
     363           40 : struct TraCIStringDoublePairList : TraCIResult {
     364            0 :     std::string getString() const override {
     365            0 :         std::ostringstream os;
     366            0 :         os << "[";
     367            0 :         for (const auto& v : value) {
     368            0 :             os << "(" << v.first << "," << v.second << "),";
     369              :         }
     370            0 :         os << "]";
     371            0 :         return os.str();
     372            0 :     }
     373              :     std::vector<std::pair<std::string, double> > value;
     374              : #ifdef SWIGJAVA
     375            0 :     SWIGJAVA_CAST(TraCIStringDoublePairList)
     376              : #endif
     377              : };
     378              : 
     379              : 
     380              : /// @brief {variable->value}
     381              : typedef std::map<int, std::shared_ptr<libsumo::TraCIResult> > TraCIResults;
     382              : /// @brief {object->{variable->value}}
     383              : typedef std::map<std::string, libsumo::TraCIResults> SubscriptionResults;
     384              : typedef std::map<std::string, libsumo::SubscriptionResults> ContextSubscriptionResults;
     385              : 
     386              : 
     387              : struct TraCIPhase {
     388          240 :     TraCIPhase() {}
     389         1464 :     TraCIPhase(const double _duration, const std::string& _state, const double _minDur = libsumo::INVALID_DOUBLE_VALUE,
     390              :                const double _maxDur = libsumo::INVALID_DOUBLE_VALUE,
     391              :                const std::vector<int>& _next = std::vector<int>(),
     392              :                const std::string& _name = "",
     393         1464 :                const std::string& _earlyTarget = "") :
     394         4392 :         duration(_duration), state(_state), minDur(_minDur), maxDur(_maxDur), next(_next), name(_name), earlyTarget(_earlyTarget) {}
     395              : 
     396              :     double duration;
     397              :     std::string state;
     398              :     double minDur, maxDur;
     399              :     std::vector<int> next;
     400              :     std::string name;
     401              :     std::string earlyTarget;
     402              : };
     403              : }
     404              : 
     405              : 
     406              : #ifdef SWIG
     407              : %template(TraCIPhaseVector) std::vector<std::shared_ptr<libsumo::TraCIPhase> >; // *NOPAD*
     408              : #endif
     409              : 
     410              : 
     411              : namespace libsumo {
     412              : struct TraCILogic {
     413           82 :     TraCILogic() {}
     414          195 :     TraCILogic(const std::string& _programID, const int _type, const int _currentPhaseIndex,
     415              :                const std::vector<std::shared_ptr<libsumo::TraCIPhase> >& _phases = std::vector<std::shared_ptr<libsumo::TraCIPhase> >())
     416          195 :         : programID(_programID), type(_type), currentPhaseIndex(_currentPhaseIndex), phases(_phases) {}
     417              : 
     418            0 :     std::string getString() const {
     419            0 :         std::ostringstream os;
     420            0 :         os << "TraCILink(" << programID << "," << type << "," << currentPhaseIndex << ")";
     421            0 :         return os.str();
     422            0 :     }
     423              : 
     424              :     std::string programID;
     425              :     int type;
     426              :     int currentPhaseIndex;
     427              :     std::vector<std::shared_ptr<libsumo::TraCIPhase> > phases;
     428              :     std::map<std::string, std::string> subParameter;
     429              : };
     430              : 
     431              : 
     432            6 : struct TraCILogicVectorWrapped : TraCIResult {
     433            0 :     std::string getString() const override {
     434            0 :         std::ostringstream os;
     435            0 :         os << "TraCILogicVectorWrapped[";
     436            0 :         for (const TraCILogic& v : value) {
     437            0 :             os << v.getString() << ",";
     438              :         }
     439            0 :         os << "]";
     440            0 :         return os.str();
     441            0 :     }
     442              : 
     443              :     std::vector<TraCILogic> value;
     444              : };
     445              : 
     446              : 
     447              : struct TraCILink {
     448            0 :     TraCILink() {}
     449         1118 :     TraCILink(const std::string& _from, const std::string& _via, const std::string& _to)
     450         3354 :         : fromLane(_from), viaLane(_via), toLane(_to) {}
     451              : 
     452            0 :     std::string getString() const {
     453            0 :         std::ostringstream os;
     454            0 :         os << "TraCILink(" << fromLane << "," << viaLane << "," << toLane << ")";
     455            0 :         return os.str();
     456            0 :     }
     457              : 
     458              :     std::string fromLane;
     459              :     std::string viaLane;
     460              :     std::string toLane;
     461              : };
     462              : 
     463              : 
     464            4 : struct TraCILinkVectorVectorWrapped : TraCIResult {
     465            0 :     std::string getString() const override {
     466            0 :         std::ostringstream os;
     467            0 :         os << "TraCILinkVectorVectorWrapped[";
     468            0 :         for (const std::vector<TraCILink>& v : value) {
     469            0 :             os << "[";
     470            0 :             for (const TraCILink& tl : v) {
     471            0 :                 os << tl.getString() << ",";
     472              :             }
     473              :         }
     474            0 :         os << "]";
     475            0 :         return os.str();
     476            0 :     }
     477              : 
     478              :     std::vector<std::vector<TraCILink> > value;
     479              : };
     480              : 
     481              : 
     482              : struct TraCIConnection {
     483           33 :     TraCIConnection() {} // this is needed by SWIG when building a vector of this type, please don't use it
     484          152 :     TraCIConnection(const std::string& _approachedLane, const bool _hasPrio, const bool _isOpen, const bool _hasFoe,
     485              :                     const std::string _approachedInternal, const std::string _state, const std::string _direction, const double _length)
     486          152 :         : approachedLane(_approachedLane), hasPrio(_hasPrio), isOpen(_isOpen), hasFoe(_hasFoe),
     487          608 :           approachedInternal(_approachedInternal), state(_state), direction(_direction), length(_length) {}
     488              : 
     489            0 :     std::string getString() const {
     490            0 :         std::ostringstream os;
     491            0 :         os << "TraCIConnection(" << approachedLane << "," << hasPrio << "," << isOpen
     492            0 :            << "," << hasFoe << "," << approachedInternal << "," << state << "," << direction << "," << length << ")";
     493            0 :         return os.str();
     494            0 :     }
     495              : 
     496              :     std::string approachedLane;
     497              :     bool hasPrio;
     498              :     bool isOpen;
     499              :     bool hasFoe;
     500              :     std::string approachedInternal;
     501              :     std::string state;
     502              :     std::string direction;
     503              :     double length;
     504              : };
     505              : 
     506              : 
     507           26 : struct TraCIConnectionVectorWrapped : TraCIResult {
     508            0 :     std::string getString() const override {
     509            0 :         std::ostringstream os;
     510            0 :         os << "TraCIConnectionVectorWrapped[";
     511            0 :         for (const TraCIConnection& v : value) {
     512            0 :             os << v.getString() << ",";
     513              :         }
     514            0 :         os << "]";
     515            0 :         return os.str();
     516            0 :     }
     517              : 
     518              :     std::vector<TraCIConnection> value;
     519              : };
     520              : 
     521              : 
     522              : /// @brief mirrors MSInductLoop::VehicleData
     523        17142 : struct TraCIVehicleData {
     524            0 :     std::string getString() const {
     525            0 :         std::ostringstream os;
     526            0 :         os << "TraCIVehicleData(" << id << "," << length << "," << entryTime
     527            0 :            << "," << leaveTime << "," << typeID << ")";
     528            0 :         return os.str();
     529            0 :     }
     530              : 
     531              :     /// @brief The id of the vehicle
     532              :     std::string id;
     533              :     /// @brief Length of the vehicle
     534              :     double length;
     535              :     /// @brief Entry-time of the vehicle in [s]
     536              :     double entryTime;
     537              :     /// @brief Leave-time of the vehicle in [s]
     538              :     double leaveTime;
     539              :     /// @brief Type of the vehicle in
     540              :     std::string typeID;
     541              : };
     542              : 
     543              : 
     544            4 : struct TraCIVehicleDataVectorWrapped : TraCIResult {
     545            0 :     std::string getString() const override {
     546            0 :         std::ostringstream os;
     547            0 :         os << "TraCIVehicleDataVectorWrapped[";
     548            0 :         for (const TraCIVehicleData& v : value) {
     549            0 :             os << v.getString() << ",";
     550              :         }
     551            0 :         os << "]";
     552            0 :         return os.str();
     553            0 :     }
     554              : 
     555              :     std::vector<TraCIVehicleData> value;
     556              : };
     557              : 
     558              : 
     559         2400 : struct TraCINextTLSData {
     560            0 :     std::string getString() const {
     561            0 :         std::ostringstream os;
     562            0 :         os << "TraCINextTLSData(" << id << "," << tlIndex << "," << dist
     563            0 :            << "," << state << ")";
     564            0 :         return os.str();
     565            0 :     }
     566              : 
     567              :     /// @brief The id of the next tls
     568              :     std::string id;
     569              :     /// @brief The tls index of the controlled link
     570              :     int tlIndex;
     571              :     /// @brief The distance to the tls
     572              :     double dist;
     573              :     /// @brief The current state of the tls
     574              :     char state;
     575              : };
     576              : 
     577              : 
     578            4 : struct TraCINextTLSDataVectorWrapped : TraCIResult {
     579            0 :     std::string getString() const override {
     580            0 :         std::ostringstream os;
     581            0 :         os << "TraCINextTLSDataVectorWrapped[";
     582            0 :         for (const TraCINextTLSData& v : value) {
     583            0 :             os << v.getString() << ",";
     584              :         }
     585            0 :         os << "]";
     586            0 :         return os.str();
     587            0 :     }
     588              : 
     589              :     std::vector<TraCINextTLSData> value;
     590              : };
     591              : 
     592              : 
     593              : struct TraCINextStopData {
     594              : 
     595        10212 :     TraCINextStopData(const std::string& lane = "",
     596              :                       double startPos = INVALID_DOUBLE_VALUE,
     597              :                       double endPos = INVALID_DOUBLE_VALUE,
     598              :                       const std::string& stoppingPlaceID = "",
     599              :                       int stopFlags = 0,
     600              :                       double duration = INVALID_DOUBLE_VALUE,
     601              :                       double until = INVALID_DOUBLE_VALUE,
     602              :                       double intendedArrival = INVALID_DOUBLE_VALUE,
     603              :                       double arrival = INVALID_DOUBLE_VALUE,
     604              :                       double depart = INVALID_DOUBLE_VALUE,
     605              :                       const std::string& split = "",
     606              :                       const std::string& join = "",
     607              :                       const std::string& actType = "",
     608              :                       const std::string& tripId = "",
     609              :                       const std::string& line = "",
     610        10212 :                       double speed = 0):
     611        10212 :         lane(lane),
     612        10212 :         startPos(startPos),
     613        10212 :         endPos(endPos),
     614        10212 :         stoppingPlaceID(stoppingPlaceID),
     615        10212 :         stopFlags(stopFlags),
     616        10212 :         duration(duration),
     617        10212 :         until(until),
     618        10212 :         intendedArrival(intendedArrival),
     619        10212 :         arrival(arrival),
     620        10212 :         depart(depart),
     621        10212 :         split(split),
     622        10212 :         join(join),
     623        10212 :         actType(actType),
     624        10212 :         tripId(tripId),
     625        10212 :         line(line),
     626        10212 :         speed(speed)
     627        10212 :     {}
     628              : 
     629            0 :     std::string getString() const {
     630            0 :         std::ostringstream os;
     631            0 :         os << "TraCINextStopData(" << lane << "," << endPos << "," << stoppingPlaceID
     632            0 :            << "," << stopFlags << "," << duration << "," << until
     633            0 :            << "," << arrival << ")";
     634            0 :         return os.str();
     635            0 :     }
     636              : 
     637              :     /// @brief The lane to stop at
     638              :     std::string lane;
     639              :     /// @brief The stopping position start
     640              :     double startPos;
     641              :     /// @brief The stopping position end
     642              :     double endPos;
     643              :     /// @brief Id assigned to the stop
     644              :     std::string stoppingPlaceID;
     645              :     /// @brief Stop flags
     646              :     int stopFlags;
     647              :     /// @brief The intended (minimum) stopping duration
     648              :     double duration;
     649              :     /// @brief The time at which the vehicle may continue its journey
     650              :     double until;
     651              :     /// @brief The intended arrival time
     652              :     double intendedArrival;
     653              :     /// @brief The actual arrival time (only for past stops)
     654              :     double arrival;
     655              :     /// @brief The time at which this stop was ended
     656              :     double depart;
     657              :     /// @brief the id of the vehicle (train portion) that splits of upon reaching this stop
     658              :     std::string split;
     659              :     /// @brief the id of the vehicle (train portion) to which this vehicle shall be joined
     660              :     std::string join;
     661              :     /// @brief additional information for this stop
     662              :     std::string actType;
     663              :     /// @brief id of the trip within a cyclical public transport route
     664              :     std::string tripId;
     665              :     /// @brief the new line id of the trip within a cyclical public transport route
     666              :     std::string line;
     667              :     /// @brief the speed at which this stop counts as reached (waypoint mode)
     668              :     double speed;
     669              : };
     670              : 
     671              : 
     672              : /** @struct TraCINextStopDataVectorWrapped
     673              :  * @brief A list of vehicle stops
     674              :  * @see TraCINextStopData
     675              :  */
     676            6 : struct TraCINextStopDataVectorWrapped : TraCIResult {
     677            0 :     std::string getString() const override {
     678            0 :         std::ostringstream os;
     679            0 :         os << "TraCINextStopDataVectorWrapped[";
     680            0 :         for (const TraCINextStopData& v : value) {
     681            0 :             os << v.getString() << ",";
     682              :         }
     683            0 :         os << "]";
     684            0 :         return os.str();
     685            0 :     }
     686              : 
     687              :     std::vector<TraCINextStopData> value;
     688              : };
     689              : 
     690              : 
     691          363 : struct TraCIBestLanesData {
     692            0 :     std::string getString() const {
     693            0 :         std::ostringstream os;
     694            0 :         os << "TraCIBestLanesData(" << laneID << "," << length << "," << occupation
     695            0 :            << "," << bestLaneOffset << "," << allowsContinuation << ",[";
     696            0 :         for (const std::string& s : continuationLanes) {
     697            0 :             os << s << ",";
     698              :         }
     699            0 :         os << "])";
     700            0 :         return os.str();
     701            0 :     }
     702              : 
     703              :     /// @brief The id of the lane
     704              :     std::string laneID;
     705              :     /// @brief The length than can be driven from that lane without lane change
     706              :     double length;
     707              :     /// @brief The traffic density along length
     708              :     double occupation;
     709              :     /// @brief The offset of this lane from the best lane
     710              :     int bestLaneOffset;
     711              :     /// @brief Whether this lane allows continuing the route
     712              :     bool allowsContinuation;
     713              :     /// @brief The sequence of lanes that best allows continuing the route without lane change
     714              :     std::vector<std::string> continuationLanes;
     715              : };
     716              : 
     717              : 
     718            4 : struct TraCIBestLanesDataVectorWrapped : TraCIResult {
     719            0 :     std::string getString() const override {
     720            0 :         std::ostringstream os;
     721            0 :         os << "TraCIBestLanesDataVectorWrapped[";
     722            0 :         for (const TraCIBestLanesData& v : value) {
     723            0 :             os << v.getString() << ",";
     724              :         }
     725            0 :         os << "]";
     726            0 :         return os.str();
     727            0 :     }
     728              : 
     729              :     std::vector<TraCIBestLanesData> value;
     730              : };
     731              : 
     732              : 
     733              : struct TraCIStage : TraCIResult {
     734              : public:
     735         9112 :     TraCIStage(int type = INVALID_INT_VALUE, const std::string& vType = "", const std::string& line = "", const std::string& destStop = "",
     736              :                const std::vector<std::string>& edges = std::vector<std::string>(),
     737              :                double travelTime = INVALID_DOUBLE_VALUE, double cost = INVALID_DOUBLE_VALUE, double length = INVALID_DOUBLE_VALUE,
     738              :                const std::string& intended = "", double depart = INVALID_DOUBLE_VALUE, double departPos = INVALID_DOUBLE_VALUE,
     739         9112 :                double arrivalPos = INVALID_DOUBLE_VALUE, const std::string& description = "") :
     740        27336 :         type(type), vType(vType), line(line), destStop(destStop), edges(edges), travelTime(travelTime), cost(cost),
     741        36448 :         length(length), intended(intended), depart(depart), departPos(departPos), arrivalPos(arrivalPos), description(description) {}
     742              :     /// @brief The type of stage (walking, driving, ...)
     743              :     int type;
     744              :     /// @brief The vehicle type when using a private car or bike
     745              :     std::string vType;
     746              :     /// @brief The line or the id of the vehicle type
     747              :     std::string line;
     748              :     /// @brief The id of the destination stop
     749              :     std::string destStop;
     750              :     /// @brief The sequence of edges to travel
     751              :     std::vector<std::string> edges;
     752              :     /// @brief duration of the stage in seconds
     753              :     double travelTime;
     754              :     /// @brief effort needed
     755              :     double cost;
     756              :     /// @brief length in m
     757              :     double length;
     758              :     /// @brief id of the intended vehicle for public transport ride
     759              :     std::string intended;
     760              :     /// @brief intended depart time for public transport ride or INVALID_DOUBLE_VALUE
     761              :     double depart;
     762              :     /// @brief position on the lane when starting the stage
     763              :     double departPos;
     764              :     /// @brief position on the lane when ending the stage
     765              :     double arrivalPos;
     766              :     /// @brief arbitrary description string
     767              :     std::string description;
     768              : };
     769              : 
     770              : 
     771              : 
     772              : struct TraCIReservation {
     773         1535 :     TraCIReservation() {}
     774         8286 :     TraCIReservation(const std::string& id,
     775              :                      const std::vector<std::string>& persons,
     776              :                      const std::string& group,
     777              :                      const std::string& fromEdge,
     778              :                      const std::string& toEdge,
     779              :                      double departPos,
     780              :                      double arrivalPos,
     781              :                      double depart,
     782              :                      double reservationTime,
     783         8286 :                      int state) :
     784        24858 :         id(id), persons(persons), group(group), fromEdge(fromEdge), toEdge(toEdge), departPos(departPos), arrivalPos(arrivalPos),
     785         8286 :         depart(depart), reservationTime(reservationTime), state(state) {}
     786              :     /// @brief The id of the taxi reservation (usable for traci.vehicle.dispatchTaxi)
     787              :     std::string id;
     788              :     /// @brief The persons ids that are part of this reservation
     789              :     std::vector<std::string> persons;
     790              :     /// @brief The group id of this reservation
     791              :     std::string group;
     792              :     /// @brief The origin edge id
     793              :     std::string fromEdge;
     794              :     /// @brief The destination edge id
     795              :     std::string toEdge;
     796              :     /// @brief pickup position on the origin edge
     797              :     double departPos;
     798              :     /// @brief drop-off position on the destination edge
     799              :     double arrivalPos;
     800              :     /// @brief pickup-time
     801              :     double depart;
     802              :     /// @brief time when the reservation was made
     803              :     double reservationTime;
     804              :     /// @brief the state of this reservation
     805              :     int state;
     806              : 
     807            0 :     std::string getString() const {
     808            0 :         std::ostringstream os;
     809            0 :         os << "TraCIReservation(id=" << id << ")";
     810            0 :         return os.str();
     811            0 :     }
     812              : };
     813              : 
     814              : 
     815            4 : struct TraCIReservationVectorWrapped : TraCIResult {
     816            0 :     std::string getString() const override {
     817            0 :         std::ostringstream os;
     818            0 :         os << "TraCIReservationVectorWrapped[";
     819            0 :         for (const TraCIReservation& v : value) {
     820            0 :             os << v.getString() << ",";
     821              :         }
     822            0 :         os << "]";
     823            0 :         return os.str();
     824            0 :     }
     825              : 
     826              :     std::vector<TraCIReservation> value;
     827              : };
     828              : 
     829              : 
     830              : struct TraCICollision {
     831              :     /// @brief The ids of the participating vehicles and persons
     832              :     std::string collider;
     833              :     std::string victim;
     834              :     std::string colliderType;
     835              :     std::string victimType;
     836              :     double colliderSpeed;
     837              :     double victimSpeed;
     838              :     /// @brief The type of collision
     839              :     std::string type;
     840              :     /// @brief The lane where the collision happended
     841              :     std::string lane;
     842              :     /// @brief The position of the collision along the lane
     843              :     double pos;
     844              : 
     845            0 :     std::string getString() const {
     846            0 :         std::ostringstream os;
     847            0 :         os << "TraCICollision(collider=" << collider << ", victim=" << victim << ")";
     848            0 :         return os.str();
     849            0 :     }
     850              : };
     851              : 
     852              : 
     853            2 : struct TraCICollisionVectorWrapped : TraCIResult {
     854            0 :     std::string getString() const override {
     855            0 :         std::ostringstream os;
     856            0 :         os << "TraCICollisionVectorWrapped[";
     857            0 :         for (const TraCICollision& v : value) {
     858            0 :             os << v.getString() << ",";
     859              :         }
     860            0 :         os << "]";
     861            0 :         return os.str();
     862            0 :     }
     863              : 
     864              :     std::vector<TraCICollision> value;
     865              : };
     866              : 
     867              : 
     868              : struct TraCISignalConstraint {
     869              :     /// @brief the idea of the rail signal where this constraint is active
     870              :     std::string signalId;
     871              :     /// @brief the tripId or vehicle id of the train that is constrained
     872              :     std::string tripId;
     873              :     /// @brief the tripId or vehicle id of the train that must pass first
     874              :     std::string foeId;
     875              :     /// @brief the tlsID of the rail signla that the foe must pass first
     876              :     std::string foeSignal;
     877              :     /// @brief the number of trains that must be recorded at the foeSignal
     878              :     int limit;
     879              :     /// @brief the type of constraint (predecessor:0, insertionPredecessor:1)
     880              :     int type;
     881              :     /// @brief whether tripId must still wait for foeId to pass foeSignal
     882              :     bool mustWait;
     883              :     /// @brief whether this constraint is active
     884              :     bool active;
     885              :     /// @brief additional parameters
     886              :     std::map<std::string, std::string> param;
     887              : 
     888            0 :     std::string getString() const {
     889            0 :         std::ostringstream os;
     890            0 :         os << "TraCISignalConstraint(signalId=" << signalId << ", tripid=" << tripId << ", foeSignal=" << foeSignal << ", foeId=" << foeId << ")";
     891            0 :         return os.str();
     892            0 :     }
     893              : };
     894              : 
     895              : 
     896            8 : struct TraCISignalConstraintVectorWrapped : TraCIResult {
     897            0 :     std::string getString() const override {
     898            0 :         std::ostringstream os;
     899            0 :         os << "TraCISignalConstraintVectorWrapped[";
     900            0 :         for (const TraCISignalConstraint& v : value) {
     901            0 :             os << v.getString() << ",";
     902              :         }
     903            0 :         os << "]";
     904            0 :         return os.str();
     905            0 :     }
     906              : 
     907              :     std::vector<TraCISignalConstraint> value;
     908              : };
     909              : 
     910              : 
     911              : struct TraCIJunctionFoe {
     912              :     /// @brief the id of the vehicle with intersecting trajectory
     913              :     std::string foeId;
     914              :     double egoDist;
     915              :     double foeDist;
     916              :     double egoExitDist;
     917              :     double foeExitDist;
     918              :     std::string egoLane;
     919              :     std::string foeLane;
     920              :     bool egoResponse;
     921              :     bool foeResponse;
     922              : 
     923            0 :     std::string getString() const {
     924            0 :         std::ostringstream os;
     925            0 :         os << "TraCIJunctionFoe(foeId=" << foeId << ", egoDist=" << egoDist << ", foeDist=" << foeDist << ", foeDist=" << foeDist << ")";
     926            0 :         return os.str();
     927            0 :     }
     928              : };
     929              : 
     930              : 
     931            4 : struct TraCIJunctionFoeVectorWrapped : TraCIResult {
     932            0 :     std::string getString() const override {
     933            0 :         std::ostringstream os;
     934            0 :         os << "TraCIJunctionFoeVectorWrapped[";
     935            0 :         for (const TraCIJunctionFoe& v : value) {
     936            0 :             os << v.getString() << ",";
     937              :         }
     938            0 :         os << "]";
     939            0 :         return os.str();
     940            0 :     }
     941              : 
     942              :     std::vector<TraCIJunctionFoe> value;
     943              : };
     944              : 
     945              : 
     946              : }
     947              : 
     948              : // pop MSVC warnings
     949              : #ifdef _MSC_VER
     950              : #pragma warning(pop)
     951              : #endif
        

Generated by: LCOV version 2.0-1