LCOV - code coverage report
Current view: top level - src/microsim - MSStateHandler.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 1 1
Test Date: 2024-11-22 15:46:21 Functions: - 0 0

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2012-2024 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    MSStateHandler.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Michael Behrisch
      17              : /// @author  Jakob Erdmann
      18              : /// @date    Thu, 13 Dec 2012
      19              : ///
      20              : // Parser and output filter for routes and vehicles state saving and loading
      21              : /****************************************************************************/
      22              : #pragma once
      23              : #include <config.h>
      24              : 
      25              : #include <utils/common/SUMOTime.h>
      26              : #include "MSRouteHandler.h"
      27              : 
      28              : 
      29              : // ===========================================================================
      30              : // class declarations
      31              : // ===========================================================================
      32              : class MESegment;
      33              : class MSRailSignal;
      34              : 
      35              : 
      36              : // ===========================================================================
      37              : // class definitions
      38              : // ===========================================================================
      39              : /**
      40              :  * @class MSStateHandler
      41              :  * @brief Parser and output filter for routes and vehicles state saving and loading
      42              :  */
      43              : class MSStateHandler : public MSRouteHandler {
      44              : public:
      45              :     /// @brief standard constructor
      46              :     MSStateHandler(const std::string& file, const SUMOTime offset);
      47              : 
      48              :     /// @brief standard destructor
      49              :     virtual ~MSStateHandler();
      50              : 
      51              :     /** @brief Saves the current state
      52              :      *
      53              :      * @param[in] file The file to write the state into
      54              :      */
      55              :     static void saveState(const std::string& file, SUMOTime step, bool usePrefix = true);
      56              : 
      57              :     /// @brief get time
      58              :     SUMOTime getTime() const {
      59              :         return myTime;
      60              :     }
      61              : 
      62              :     /// handler to read only the simulation time from a state
      63          406 :     class MSStateTimeHandler : public SUMOSAXHandler {
      64              :     public:
      65              :         /// @brief parse time from state file
      66              :         static SUMOTime getTime(const std::string& fileName);
      67              : 
      68              :     protected:
      69              :         void myStartElement(int element, const SUMOSAXAttributes& attrs);
      70              :         SUMOTime myTime;
      71              :     };
      72              : 
      73              : protected:
      74              :     /// @name inherited from GenericSAXHandler
      75              :     //@{
      76              : 
      77              :     /** @brief Called on the opening of a tag;
      78              :      *
      79              :      * @param[in] element ID of the currently opened element
      80              :      * @param[in] attrs Attributes within the currently opened element
      81              :      * @exception ProcessError If something fails
      82              :      * @see GenericSAXHandler::myStartElement
      83              :      */
      84              :     void myStartElement(int element,
      85              :                         const SUMOSAXAttributes& attrs);
      86              : 
      87              :     /** @brief Called when a closing tag occurs
      88              :      *
      89              :      * @param[in] element ID of the currently opened element
      90              :      * @exception ProcessError If something fails
      91              :      * @see GenericSAXHandler::myEndElement
      92              :      */
      93              :     void myEndElement(int element);
      94              :     //@}
      95              : 
      96              :     /// Ends the processing of a vehicle
      97              :     void closeVehicle();
      98              : 
      99              : private:
     100              :     /// @brief offset
     101              :     const SUMOTime myOffset;
     102              : 
     103              :     /// @brief time
     104              :     SUMOTime myTime;
     105              : 
     106              :     /// @brief segment
     107              :     MESegment* mySegment;
     108              : 
     109              :     /// @brief current lane being loaded
     110              :     MSLane* myCurrentLane;
     111              : 
     112              :     /// @brief current link being loaded
     113              :     MSLink* myCurrentLink;
     114              : 
     115              :     /// @brief que index
     116              :     int myQueIndex;
     117              : 
     118              :     /// @brief cached attrs (used when loading vehicles or transportables)
     119              :     SUMOSAXAttributes* myAttrs;
     120              : 
     121              :     /// @brief cached attrs for delayed loading of MSVehicleControl state
     122              :     SUMOSAXAttributes* myVCAttrs;
     123              : 
     124              :     /// @brief cached device attrs (used when loading vehicles)
     125              :     std::vector<SUMOSAXAttributes*> myDeviceAttrs;
     126              : 
     127              :     /// @brief the last object that potentially carries parameters
     128              :     Parameterised* myLastParameterised;
     129              : 
     130              :     /// @brief vehicles that shall be removed when loading state
     131              :     std::set<std::string> myVehiclesToRemove;
     132              : 
     133              :     /// @brief vehicles that were removed when loading state
     134              :     int myRemoved;
     135              : 
     136              :     /// @brief rail signal for which constraints are being loaded
     137              :     MSRailSignal* myConstrainedSignal;
     138              : 
     139              : private:
     140              :     /// @brief save the state of random number generators
     141              :     static void saveRNGs(OutputDevice& out);
     142              : 
     143              : private:
     144              :     /// @brief Invalidated copy constructor
     145              :     MSStateHandler(const MSStateHandler& s) = delete;
     146              : 
     147              :     /// @brief Invalidated assignment operator
     148              :     MSStateHandler& operator=(const MSStateHandler& s) = delete;
     149              : };
        

Generated by: LCOV version 2.0-1