SUMO - Simulation of Urban MObility

MSBaseVehicle.h

Go to the documentation of this file.
00001 /****************************************************************************/
00008 // A base class for vehicle implementations
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 MSBaseVehicle_h
00022 #define MSBaseVehicle_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 <iostream>
00035 #include <cassert>
00036 #include <vector>
00037 #include <utils/common/SUMOVehicle.h>
00038 #include <utils/common/StdDefs.h>
00039 #include "MSRoute.h"
00040 #include "MSMoveReminder.h"
00041 
00042 
00043 // ===========================================================================
00044 // class declarations
00045 // ===========================================================================
00046 class SUMOVehicleParameter;
00047 class MSVehicleType;
00048 
00049 
00050 // ===========================================================================
00051 // class definitions
00052 // ===========================================================================
00057 class MSBaseVehicle : public SUMOVehicle {
00058 public:
00061     MSBaseVehicle(SUMOVehicleParameter* pars, const MSRoute* route, const MSVehicleType* type) ;
00062 
00063 
00065     virtual ~MSBaseVehicle() ;
00066 
00067 
00069     const std::string& getID() const ;
00070 
00075     const SUMOVehicleParameter& getParameter() const ;
00076 
00077 
00081     const MSRoute& getRoute() const ;
00082 
00083 
00087     const MSVehicleType& getVehicleType() const ;
00088 
00089 
00093     SUMOReal getMaxSpeed() const;
00094 
00095 
00099     SUMOReal adaptMaxSpeed(SUMOReal referenceSpeed);
00100 
00101 
00109     const MSEdge* succEdge(unsigned int nSuccs) const ;
00110 
00115     const MSEdge* getEdge() const;
00116 
00117 
00121     virtual bool isOnRoad() const {
00122         return true;
00123     }
00124 
00125 
00135     void reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle> &router, bool withTaz = false) ;
00136 
00137 
00148     bool replaceRouteEdges(const MSEdgeVector& edges, bool onInit = false) ;
00149 
00150 
00157     virtual SUMOReal getPreDawdleAcceleration() const ;
00158 
00164     void onDepart() ;
00165 
00169     SUMOTime getDeparture() const ;
00170 
00174     unsigned int getNumberReroutes() const ;
00175 
00179     const std::vector<MSDevice*> &getDevices() const {
00180         return myDevices;
00181     }
00182 
00189     virtual void addPerson(MSPerson* person) ;
00190 
00194     virtual bool isStopped() const;
00195 
00200     bool hasValidRoute(std::string& msg) const ;
00201 
00207     void addReminder(MSMoveReminder* rem) ;
00208 
00214     void removeReminder(MSMoveReminder* rem) ;
00215 
00226     virtual void activateReminders(const MSMoveReminder::Notification reason) ;
00227 
00228 protected:
00231     void calculateArrivalPos() ;
00232 
00233 protected:
00235     const SUMOVehicleParameter* myParameter;
00236 
00238     const MSRoute* myRoute;
00239 
00241     const MSVehicleType* myType;
00242 
00244     MSRouteIterator myCurrEdge;
00245 
00250     SUMOReal myIndividualMaxSpeed;
00251 
00253     bool myHasIndividualMaxSpeed;
00254 
00256     SUMOReal myReferenceSpeed;
00257 
00260 
00262     typedef std::vector< std::pair<MSMoveReminder*, SUMOReal> > MoveReminderCont;
00263 
00265     MoveReminderCont myMoveReminders;
00267 
00269     std::vector<MSDevice*> myDevices;
00270 
00272     SUMOTime myDeparture;
00273 
00275     SUMOReal myArrivalPos;
00276 
00278     unsigned int myNumberReroutes;
00279 
00280 };
00281 
00282 #endif
00283 
00284 /****************************************************************************/
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines