SUMO - Simulation of Urban MObility

RONet.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // The router's network representation
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 #ifndef RONet_h
00020 #define RONet_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <string>
00033 #include <set>
00034 #include <fstream>
00035 #include <deque>
00036 #include <vector>
00037 #include "ROEdge.h"
00038 #include "RONode.h"
00039 #include "ROVehicleCont.h"
00040 #include "ROVehicle.h"
00041 #include "RORouteDef.h"
00042 #include <utils/common/SUMOVTypeParameter.h>
00043 #include <utils/common/SUMOAbstractRouter.h>
00044 
00045 
00046 // ===========================================================================
00047 // class declarations
00048 // ===========================================================================
00049 class RONode;
00050 class RORouteDef;
00051 class OptionsCont;
00052 class OutputDevice;
00053 
00054 
00055 // ===========================================================================
00056 // class definitions
00057 // ===========================================================================
00066 class RONet {
00067 public:
00069     RONet() throw();
00070 
00071 
00073     virtual ~RONet() throw();
00074 
00075 
00077 
00078 
00079     /* @brief Adds a read edge to the network
00080      *
00081      * If the edge is already known (another one with the same id exists),
00082      *  an error is generated and given to msg-error-handler. The edge
00083      *  is deleted in this case and false is returned.
00084      *
00085      * @param[in] edge The edge to add
00086      * @return Whether the edge was added (if not, it was deleted, too)
00087      */
00088     virtual bool addEdge(ROEdge* edge) throw();
00089 
00090 
00100     ROEdge* getEdge(const std::string& name) const throw() {
00101         return myEdges.get(name);
00102     }
00103 
00104 
00105     /* @brief Adds a read node to the network
00106      *
00107      * If the node is already known (another one with the same id exists),
00108      *  an error is generated and given to msg-error-handler. The node
00109      *  is deleted in this case
00110      *
00111      * @param[in] node The node to add
00112      */
00113     void addNode(RONode* node) throw();
00114 
00115 
00122     RONode* getNode(const std::string& id) const throw() {
00123         return myNodes.get(id);
00124     }
00126 
00127 
00128 
00130 
00131 
00132     /* @brief Adds a read vehicle type definition to the network
00133      *
00134      * If the vehicle type definition is already known (another one with
00135      *  the same id exists), false is returned, and the vehicle type
00136      *  is deleted.
00137      *
00138      * @param[in] def The vehicle type to add
00139      * @return Whether the vehicle type could be added
00140      */
00141     virtual bool addVehicleType(SUMOVTypeParameter* type) throw();
00142 
00143 
00156     SUMOVTypeParameter* getVehicleTypeSecure(const std::string& id) throw();
00157 
00158 
00159     /* @brief Adds a route definition to the network
00160      *
00161      * If the route definition is already known (another one with
00162      *  the same id exists), false is returned, but the route definition
00163      *  is not deleted.
00164      *
00165      * @param[in] def The route definition to add
00166      * @return Whether the route definition could be added
00167      * @todo Rename myRoutes to myRouteDefinitions
00168      */
00169     bool addRouteDef(RORouteDef* def) throw();
00170 
00171 
00179     RORouteDef* getRouteDef(const std::string& name) const throw() {
00180         return myRoutes.get(name);
00181     }
00182 
00183 
00184     /* @brief Adds a vehicle to the network
00185      *
00186      * If the vehicle is already known (another one with the same id
00187      *  exists), false is returned, but the vehicle is not deleted.
00188      *
00189      * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
00190      *
00191      * @param[in] id The id of the vehicle to add
00192      * @param[in] veh The vehicle to add
00193      * @return Whether the vehicle could be added
00194      */
00195     virtual bool addVehicle(const std::string& id, ROVehicle* veh) throw();
00196     // @}
00197 
00198 
00199 
00201 
00202 
00214     SUMOTime saveAndRemoveRoutesUntil(OptionsCont& options,
00215                                       SUMOAbstractRouter<ROEdge,ROVehicle> &router, SUMOTime time);
00216 
00217 
00219     virtual bool furtherStored();
00221 
00222 
00223 
00224 
00225 
00236     void openOutput(const std::string& filename, bool useAlternatives) throw(IOError);
00237 
00238 
00240     void closeOutput() throw();
00241 
00242 
00243 
00244 
00251     ROEdge* getRandomSource() throw();
00252 
00253 
00260     const ROEdge* getRandomSource() const throw();
00261 
00262 
00269     ROEdge* getRandomDestination() throw();
00270 
00271 
00278     const ROEdge* getRandomDestination() const throw();
00279 
00280 
00282     unsigned int getEdgeNo() const;
00283 
00284     const std::map<std::string, ROEdge*> &getEdgeMap() const;
00285 
00286     bool hasRestrictions() const;
00287 
00288     void setRestrictionFound();
00289 
00290 
00291 protected:
00292     bool computeRoute(OptionsCont& options,
00293                       SUMOAbstractRouter<ROEdge,ROVehicle> &router, const ROVehicle* const veh);
00294 
00296     void checkSourceAndDestinations() const;
00297 
00298 protected:
00300     std::set<std::string> myVehIDs;
00301 
00303     NamedObjectCont<RONode*> myNodes;
00304 
00306     NamedObjectCont<ROEdge*> myEdges;
00307 
00309     NamedObjectCont<SUMOVTypeParameter*> myVehicleTypes;
00310 
00312     NamedObjectCont<RORouteDef*> myRoutes;
00313 
00315     ROVehicleCont myVehicles;
00316 
00318     mutable std::vector<ROEdge*> mySourceEdges;
00319 
00321     mutable std::vector<ROEdge*> myDestinationEdges;
00322 
00324     OutputDevice* myRoutesOutput;
00325 
00327     OutputDevice* myRouteAlternativesOutput;
00328 
00330     unsigned int myReadRouteNo;
00331 
00333     unsigned int myDiscardedRouteNo;
00334 
00336     unsigned int myWrittenRouteNo;
00337 
00339     bool myHaveRestrictions;
00340 
00341 
00342 private:
00344     RONet(const RONet& src);
00345 
00347     RONet& operator=(const RONet& src);
00348 
00349 };
00350 
00351 
00352 #endif
00353 
00354 /****************************************************************************/
00355 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines