Eclipse SUMO - Simulation of Urban MObility
MSStateHandler.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2012-2020 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 /****************************************************************************/
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 
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
43 public:
45  MSStateHandler(const std::string& file, const SUMOTime offset, bool onlyReadTime = false);
46 
48  virtual ~MSStateHandler();
49 
54  static void saveState(const std::string& file, SUMOTime step);
55 
57  SUMOTime getTime() const {
58  return myTime;
59  }
60 
61 protected:
63 
64 
72  void myStartElement(int element,
73  const SUMOSAXAttributes& attrs);
74 
81  void myEndElement(int element);
83 
85  void closeVehicle();
86 
87 private:
90 
93 
96 
99 
102 
105 
108 
111 
113  std::vector<SUMOSAXAttributes*> myDeviceAttrs;
114 
117 
120 
122  std::set<std::string> myVehiclesToRemove;
123 
126 
127 private:
129  static void saveRNGs(OutputDevice& out);
130 
131 private:
133  MSStateHandler(const MSStateHandler& s) = delete;
134 
137 };
long long int SUMOTime
Definition: SUMOTime.h:31
A single mesoscopic segment (cell)
Definition: MESegment.h:47
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
Parser and container for routes during their loading.
Parser and output filter for routes and vehicles state saving and loading.
SUMOSAXAttributes * myAttrs
cached attrs (used when loading vehicles or transportables)
bool myOnlyReadTime
whether the handler should abort parsing (via Exception) after parsing the time
MSStateHandler(const MSStateHandler &s)=delete
Invalidated copy constructor.
static void saveState(const std::string &file, SUMOTime step)
Saves the current state.
MSStateHandler(const std::string &file, const SUMOTime offset, bool onlyReadTime=false)
standard constructor
int myQueIndex
que index
SUMOTime myTime
time
std::set< std::string > myVehiclesToRemove
vehicles that shall be removed when loading state
int myRemoved
vehicles that were removed when loading state
MSLink * myCurrentLink
current link being loaded
MESegment * mySegment
segment
MSLane * myCurrentLane
current lane being loaded
static void saveRNGs(OutputDevice &out)
save the state of random number generators
const SUMOTime myOffset
offset
Parameterised * myLastParameterised
the last object that potentially carries parameters
void closeVehicle()
Ends the processing of a vehicle.
SUMOTime getTime() const
get time
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
std::vector< SUMOSAXAttributes * > myDeviceAttrs
cached device attrs (used when loading vehicles)
MSStateHandler & operator=(const MSStateHandler &s)=delete
Invalidated assignment operator.
SUMOSAXAttributes * myVCAttrs
cached attrs for delayed loading of MSVehicleControl state
void myEndElement(int element)
Called when a closing tag occurs.
virtual ~MSStateHandler()
standard destructor
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
An upper class for objects with additional parameters.
Definition: Parameterised.h:39
Encapsulated SAX-Attributes.