SUMO - Simulation of Urban MObility
RORouteDef_Alternatives.h
Go to the documentation of this file.
00001 /****************************************************************************/
00008 // A route with alternative routes
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 RORouteDef_Alternatives_h
00022 #define RORouteDef_Alternatives_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 <vector>
00036 #include "RORoute.h"
00037 
00038 
00039 // ===========================================================================
00040 // class declarations
00041 // ===========================================================================
00042 class ROEdge;
00043 
00044 
00045 // ===========================================================================
00046 // class definitions
00047 // ===========================================================================
00052 class RORouteDef_Alternatives : public RORouteDef {
00053 public:
00055     RORouteDef_Alternatives(const std::string& id, unsigned int lastUsed, const int maxRoutes,
00056                             const bool keepRoutes, const bool skipRouteCalculation) ;
00057 
00059     virtual ~RORouteDef_Alternatives() ;
00060 
00063     virtual void addLoadedAlternative(RORoute* alternative);
00064 
00066     void preComputeCurrentRoute(SUMOAbstractRouter<ROEdge, ROVehicle> &router, SUMOTime begin,
00067                                const ROVehicle& veh) const;
00068 
00070     void addAlternative(SUMOAbstractRouter<ROEdge, ROVehicle> &router,
00071                         const ROVehicle* const, RORoute* current, SUMOTime begin);
00072 
00074     RORouteDef* copy(const std::string& id) const;
00075 
00076     void invalidateLast();
00077 
00078     void removeLast();
00079 
00080     virtual OutputDevice& writeXMLDefinition(SUMOAbstractRouter<ROEdge, ROVehicle> &router,
00081             OutputDevice& dev, const ROVehicle* const veh,
00082             bool asAlternatives, bool withExitTimes) const;
00083 
00084     /* @brief Returns destination of this route definition */
00085     const ROEdge* getDestination() const;
00086 
00087 private:
00089     int findRoute(RORoute* opt) const;
00090 
00092     struct ComparatorProbability {
00093         bool operator()(const RORoute* const a, const RORoute* const b) {
00094             return a->getProbability() > b->getProbability();
00095         }
00096     };
00097 
00098 private:
00100     mutable bool myNewRoute;
00101 
00103     mutable int myLastUsed;
00104 
00106     typedef std::vector<RORoute*> AlternativesVector;
00107 
00109     AlternativesVector myAlternatives;
00110 
00112     const int myMaxRouteNumber;
00113 
00115     const bool myKeepRoutes;
00116 
00118     const bool mySkipRouteCalculation;
00119 
00120 
00121 private:
00123     RORouteDef_Alternatives(const RORouteDef_Alternatives& src);
00124 
00126     RORouteDef_Alternatives& operator=(const RORouteDef_Alternatives& src);
00127 
00128 };
00129 
00130 
00131 #endif
00132 
00133 /****************************************************************************/
00134 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines