SUMO - Simulation of Urban MObility

RONet.h

Go to the documentation of this file.
00001 /****************************************************************************/
00008 // The router's network representation
00009 /****************************************************************************/
00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00012 /****************************************************************************/
00013 //
00014 //   This file is part of SUMO.
00015 //   SUMO is free software: you can redistribute it and/or modify
00016 //   it under the terms of the GNU General Public License as published by
00017 //   the Free Software Foundation, either version 3 of the License, or
00018 //   (at your option) any later version.
00019 //
00020 /****************************************************************************/
00021 #ifndef RONet_h
00022 #define RONet_h
00023 
00024 
00025 // ===========================================================================
00026 // included modules
00027 // ===========================================================================
00028 #ifdef _MSC_VER
00029 #include <windows_config.h>
00030 #else
00031 #include <config.h>
00032 #endif
00033 
00034 #include <string>
00035 #include <set>
00036 #include <fstream>
00037 #include <deque>
00038 #include <vector>
00039 #include "ROEdge.h"
00040 #include "RONode.h"
00041 #include "ROVehicleCont.h"
00042 #include "ROVehicle.h"
00043 #include "RORouteDef.h"
00044 #include <utils/common/SUMOVTypeParameter.h>
00045 #include <utils/common/SUMOAbstractRouter.h>
00046 
00047 
00048 // ===========================================================================
00049 // class declarations
00050 // ===========================================================================
00051 class RONode;
00052 class RORouteDef;
00053 class OptionsCont;
00054 class OutputDevice;
00055 
00056 
00057 // ===========================================================================
00058 // class definitions
00059 // ===========================================================================
00068 class RONet {
00069 public:
00071     RONet() ;
00072 
00073 
00075     virtual ~RONet() ;
00076 
00077 
00079 
00080 
00081     /* @brief Adds a read edge to the network
00082      *
00083      * If the edge is already known (another one with the same id exists),
00084      *  an error is generated and given to msg-error-handler. The edge
00085      *  is deleted in this case and false is returned.
00086      *
00087      * @param[in] edge The edge to add
00088      * @return Whether the edge was added (if not, it was deleted, too)
00089      */
00090     virtual bool addEdge(ROEdge* edge) ;
00091 
00092 
00102     ROEdge* getEdge(const std::string& name) const {
00103         return myEdges.get(name);
00104     }
00105 
00106 
00107     /* @brief Adds a read node to the network
00108      *
00109      * If the node is already known (another one with the same id exists),
00110      *  an error is generated and given to msg-error-handler. The node
00111      *  is deleted in this case
00112      *
00113      * @param[in] node The node to add
00114      */
00115     void addNode(RONode* node) ;
00116 
00117 
00124     RONode* getNode(const std::string& id) const {
00125         return myNodes.get(id);
00126     }
00128 
00129 
00130 
00132 
00133 
00134     /* @brief Adds a read vehicle type definition to the network
00135      *
00136      * If the vehicle type definition is already known (another one with
00137      *  the same id exists), false is returned, and the vehicle type
00138      *  is deleted.
00139      *
00140      * @param[in] def The vehicle type to add
00141      * @return Whether the vehicle type could be added
00142      */
00143     virtual bool addVehicleType(SUMOVTypeParameter* type) ;
00144 
00145 
00158     SUMOVTypeParameter* getVehicleTypeSecure(const std::string& id) ;
00159 
00160 
00161     /* @brief Adds a route definition to the network
00162      *
00163      * If the route definition is already known (another one with
00164      *  the same id exists), false is returned, but the route definition
00165      *  is not deleted.
00166      *
00167      * @param[in] def The route definition to add
00168      * @return Whether the route definition could be added
00169      * @todo Rename myRoutes to myRouteDefinitions
00170      */
00171     bool addRouteDef(RORouteDef* def) ;
00172 
00173 
00181     RORouteDef* getRouteDef(const std::string& name) const {
00182         return myRoutes.get(name);
00183     }
00184 
00185 
00186     /* @brief Adds a vehicle to the network
00187      *
00188      * If the vehicle is already known (another one with the same id
00189      *  exists), false is returned, but the vehicle is not deleted.
00190      *
00191      * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
00192      *
00193      * @param[in] id The id of the vehicle to add
00194      * @param[in] veh The vehicle to add
00195      * @return Whether the vehicle could be added
00196      */
00197     virtual bool addVehicle(const std::string& id, ROVehicle* veh) ;
00198     // @}
00199 
00200 
00201 
00203 
00204 
00216     SUMOTime saveAndRemoveRoutesUntil(OptionsCont& options,
00217                                       SUMOAbstractRouter<ROEdge, ROVehicle> &router, SUMOTime time);
00218 
00219 
00221     virtual bool furtherStored();
00223 
00224 
00225 
00226 
00227 
00238     void openOutput(const std::string& filename, bool useAlternatives);
00239 
00240 
00242     void closeOutput() ;
00243 
00244 
00245 
00246 
00253     ROEdge* getRandomSource() ;
00254 
00255 
00262     const ROEdge* getRandomSource() const ;
00263 
00264 
00271     ROEdge* getRandomDestination() ;
00272 
00273 
00280     const ROEdge* getRandomDestination() const ;
00281 
00282 
00284     unsigned int getEdgeNo() const;
00285 
00286     const std::map<std::string, ROEdge*> &getEdgeMap() const;
00287 
00288     bool hasRestrictions() const;
00289 
00290     void setRestrictionFound();
00291 
00292 
00293 protected:
00294     bool computeRoute(OptionsCont& options,
00295                       SUMOAbstractRouter<ROEdge, ROVehicle> &router, const ROVehicle* const veh);
00296 
00298     void checkSourceAndDestinations() const;
00299 
00300 protected:
00302     std::set<std::string> myVehIDs;
00303 
00305     NamedObjectCont<RONode*> myNodes;
00306 
00308     NamedObjectCont<ROEdge*> myEdges;
00309 
00311     NamedObjectCont<SUMOVTypeParameter*> myVehicleTypes;
00312 
00314     NamedObjectCont<RORouteDef*> myRoutes;
00315 
00317     ROVehicleCont myVehicles;
00318 
00320     mutable std::vector<ROEdge*> mySourceEdges;
00321 
00323     mutable std::vector<ROEdge*> myDestinationEdges;
00324 
00326     OutputDevice* myRoutesOutput;
00327 
00329     OutputDevice* myRouteAlternativesOutput;
00330 
00332     unsigned int myReadRouteNo;
00333 
00335     unsigned int myDiscardedRouteNo;
00336 
00338     unsigned int myWrittenRouteNo;
00339 
00341     bool myHaveRestrictions;
00342 
00343 
00344 private:
00346     RONet(const RONet& src);
00347 
00349     RONet& operator=(const RONet& src);
00350 
00351 };
00352 
00353 
00354 #endif
00355 
00356 /****************************************************************************/
00357 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines