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 2001-2010 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
00084      *
00085      * @param[in] edge The edge to add
00086      */
00087     virtual void addEdge(ROEdge *edge) throw();
00088 
00089 
00099     ROEdge *getEdge(const std::string &name) const throw() {
00100         return myEdges.get(name);
00101     }
00102 
00103 
00104     /* @brief Adds a read node to the network
00105      *
00106      * If the node is already known (another one with the same id exists),
00107      *  an error is generated and given to msg-error-handler. The node
00108      *  is deleted in this case
00109      *
00110      * @param[in] node The node to add
00111      */
00112     void addNode(RONode *node) throw();
00113 
00114 
00121     RONode *getNode(const std::string &id) const throw() {
00122         return myNodes.get(id);
00123     }
00125 
00126 
00127 
00129 
00130 
00131     /* @brief Adds a read vehicle type definition to the network
00132      *
00133      * If the vehicle type definition is already known (another one with
00134      *  the same id exists), false is returned, and the vehicle type
00135      *  is deleted.
00136      *
00137      * @param[in] def The vehicle type to add
00138      * @return Whether the vehicle type could be added
00139      */
00140     virtual bool addVehicleType(SUMOVTypeParameter *type) throw();
00141 
00142 
00155     SUMOVTypeParameter *getVehicleTypeSecure(const std::string &id) throw();
00156 
00157 
00158     /* @brief Adds a route definition to the network
00159      *
00160      * If the route definition is already known (another one with
00161      *  the same id exists), false is returned, but the route definition
00162      *  is not deleted.
00163      *
00164      * @param[in] def The route definition to add
00165      * @return Whether the route definition could be added
00166      * @todo Rename myRoutes to myRouteDefinitions
00167      */
00168     bool addRouteDef(RORouteDef *def) throw();
00169 
00170 
00178     RORouteDef *getRouteDef(const std::string &name) const throw() {
00179         return myRoutes.get(name);
00180     }
00181 
00182 
00183     /* @brief Adds a vehicle to the network
00184      *
00185      * If the vehicle is already known (another one with the same id
00186      *  exists), false is returned, but the vehicle is not deleted.
00187      *
00188      * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
00189      *
00190      * @param[in] id The id of the vehicle to add
00191      * @param[in] veh The vehicle to add
00192      * @return Whether the vehicle could be added
00193      */
00194     virtual bool addVehicle(const std::string &id, ROVehicle *veh) throw();
00195     // @}
00196 
00197 
00198 
00200 
00201 
00213     SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options,
00214                                       SUMOAbstractRouter<ROEdge,ROVehicle> &router, SUMOTime time);
00215 
00216 
00218     virtual bool furtherStored();
00220 
00221 
00222 
00223 
00224 
00235     void openOutput(const std::string &filename, bool useAlternatives) throw(IOError);
00236 
00237 
00239     void closeOutput() throw();
00240 
00241 
00242 
00243 
00250     ROEdge *getRandomSource() throw();
00251 
00252 
00259     const ROEdge *getRandomSource() const throw();
00260 
00261 
00268     ROEdge *getRandomDestination() throw();
00269 
00270 
00277     const ROEdge *getRandomDestination() const throw();
00278 
00279 
00281     unsigned int getEdgeNo() const;
00282 
00283     const std::map<std::string, ROEdge*> &getEdgeMap() const;
00284 
00285     bool hasRestrictions() const;
00286 
00287     void setRestrictionFound();
00288 
00289 
00290 protected:
00291     bool computeRoute(OptionsCont &options,
00292                       SUMOAbstractRouter<ROEdge,ROVehicle> &router, const ROVehicle * const veh);
00293 
00295     void checkSourceAndDestinations() const;
00296 
00297 protected:
00299     std::set<std::string> myVehIDs;
00300 
00302     NamedObjectCont<RONode*> myNodes;
00303 
00305     NamedObjectCont<ROEdge*> myEdges;
00306 
00308     NamedObjectCont<SUMOVTypeParameter*> myVehicleTypes;
00309 
00311     NamedObjectCont<RORouteDef*> myRoutes;
00312 
00314     ROVehicleCont myVehicles;
00315 
00317     mutable std::vector<ROEdge*> mySourceEdges;
00318 
00320     mutable std::vector<ROEdge*> myDestinationEdges;
00321 
00323     OutputDevice *myRoutesOutput;
00324 
00326     OutputDevice *myRouteAlternativesOutput;
00327 
00329     unsigned int myReadRouteNo;
00330 
00332     unsigned int myDiscardedRouteNo;
00333 
00335     unsigned int myWrittenRouteNo;
00336 
00338     bool myHaveRestrictions;
00339 
00340 
00341 private:
00343     RONet(const RONet &src);
00344 
00346     RONet &operator=(const RONet &src);
00347 
00348 };
00349 
00350 
00351 #endif
00352 
00353 /****************************************************************************/
00354 

Generated on Wed May 5 00:06:36 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6