SUMO - Simulation of Urban MObility
NBTypeCont.h
Go to the documentation of this file.
00001 /****************************************************************************/
00011 // A storage for available types of edges
00012 /****************************************************************************/
00013 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00014 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00015 /****************************************************************************/
00016 //
00017 //   This file is part of SUMO.
00018 //   SUMO is free software: you can redistribute it and/or modify
00019 //   it under the terms of the GNU General Public License as published by
00020 //   the Free Software Foundation, either version 3 of the License, or
00021 //   (at your option) any later version.
00022 //
00023 /****************************************************************************/
00024 #ifndef NBTypeCont_h
00025 #define NBTypeCont_h
00026 
00027 
00028 // ===========================================================================
00029 // included modules
00030 // ===========================================================================
00031 #ifdef _MSC_VER
00032 #include <windows_config.h>
00033 #else
00034 #include <config.h>
00035 #endif
00036 
00037 #include <string>
00038 #include <map>
00039 #include "NBNode.h"
00040 #include <utils/common/SUMOVehicleClass.h>
00041 
00042 
00043 // ===========================================================================
00044 // class definitions
00045 // ===========================================================================
00056 class NBTypeCont {
00057 public:
00059     NBTypeCont() {}
00060 
00061 
00063     ~NBTypeCont() {}
00064 
00065 
00071     void setDefaults(int defaultNoLanes,
00072                      SUMOReal defaultSpeed, int defaultPriority) ;
00073 
00074 
00086     bool insert(const std::string& id, int noLanes, SUMOReal maxSpeed, int prio,
00087                 SUMOReal width, SUMOVehicleClass vClasses = SVC_UNKNOWN, bool oneWayIsDefault = false) ;
00088 
00099     bool insert(const std::string& id, int noLanes,
00100                 SUMOReal maxSpeed, int prio,
00101                 SVCPermissions permissions,
00102                 SUMOReal width, bool oneWayIsDefault) ;
00103 
00107     unsigned int size() const {
00108         return (unsigned int) myTypes.size();
00109     }
00110 
00111 
00115     bool knows(const std::string& type) const ;
00116 
00117 
00121     bool markAsToDiscard(const std::string& id) ;
00122 
00123 
00124 
00127 
00134     int getNumLanes(const std::string& type) const ;
00135 
00136 
00143     SUMOReal getSpeed(const std::string& type) const ;
00144 
00145 
00152     int getPriority(const std::string& type) const ;
00153 
00154 
00162     bool getIsOneWay(const std::string& type) const ;
00163 
00164 
00170     bool getShallBeDiscarded(const std::string& type) const ;
00171 
00172 
00179     SVCPermissions getPermissions(const std::string& type) const ;
00180 
00181 
00188     SUMOReal getWidth(const std::string& type) const ;
00190 
00191 
00192 private:
00193     struct TypeDefinition {
00195         TypeDefinition() : 
00196             noLanes(1), speed((SUMOReal) 13.9), priority(-1),
00197             permissions(SVCFreeForAll),
00198             oneWay(true), discard(false), width(NBEdge::UNSPECIFIED_WIDTH) { }
00199 
00201         TypeDefinition(int _noLanes, SUMOReal _speed, int _priority, 
00202                 SUMOReal _width, SVCPermissions _permissions, bool _oneWay) : 
00203             noLanes(_noLanes), speed(_speed), priority(_priority),
00204             permissions(_permissions),
00205             oneWay(_oneWay), discard(false), width(_width) { }
00206 
00208         int noLanes;
00210         SUMOReal speed;
00212         int priority;
00214         SVCPermissions permissions;
00216         bool oneWay;
00218         bool discard;
00220         SUMOReal width;
00221 
00222     };
00223 
00224 
00231     const TypeDefinition& getType(const std::string& name) const;
00232 
00233 
00234 private:
00236     TypeDefinition myDefaultType;
00237 
00239     typedef std::map<std::string, TypeDefinition> TypesCont;
00240 
00242     TypesCont myTypes;
00243 
00244 
00245 private:
00247     NBTypeCont(const NBTypeCont& s);
00248 
00250     NBTypeCont& operator=(const NBTypeCont& s);
00251 
00252 
00253 };
00254 
00255 
00256 #endif
00257 
00258 /****************************************************************************/
00259 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines