SUMO - Simulation of Urban MObility

NBTypeCont.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // A storage for available types of edges
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 NBTypeCont_h
00020 #define NBTypeCont_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 <map>
00034 #include "NBNode.h"
00035 #include "NBJunctionTypesMatrix.h"
00036 #include <utils/common/SUMOVehicleClass.h>
00037 
00038 
00039 // ===========================================================================
00040 // class definitions
00041 // ===========================================================================
00052 class NBTypeCont {
00053 public:
00055     NBTypeCont() throw() {}
00056 
00057 
00059     ~NBTypeCont() throw() {}
00060 
00061 
00067     void setDefaults(int defaultNoLanes,
00068                      SUMOReal defaultSpeed, int defaultPriority) throw();
00069 
00070 
00082     bool insert(const std::string& id, int noLanes, SUMOReal maxSpeed, int prio,
00083                 SUMOReal width, SUMOVehicleClass vClasses=SVC_UNKNOWN, bool oneWayIsDefault=false) throw();
00084 
00096     bool insert(const std::string& id, int noLanes,
00097                 SUMOReal maxSpeed, int prio,
00098                 const SUMOVehicleClasses& allow, const SUMOVehicleClasses& disallow,
00099                 SUMOReal width, bool oneWayIsDefault) throw();
00100 
00104     unsigned int size() const throw() {
00105         return (unsigned int) myTypes.size();
00106     }
00107 
00108 
00112     SumoXMLNodeType getJunctionType(SUMOReal speed1, SUMOReal speed2) const throw();
00113 
00114 
00118     bool knows(const std::string& type) const throw();
00119 
00120 
00124     bool markAsToDiscard(const std::string& id) throw();
00125 
00126 
00127 
00130 
00137     int getNumLanes(const std::string& type) const throw();
00138 
00139 
00146     SUMOReal getSpeed(const std::string& type) const throw();
00147 
00148 
00155     int getPriority(const std::string& type) const throw();
00156 
00157 
00165     bool getIsOneWay(const std::string& type) const throw();
00166 
00167 
00173     bool getShallBeDiscarded(const std::string& type) const throw();
00174 
00175 
00182     const SUMOVehicleClasses& getAllowedClasses(const std::string& type) const throw();
00183 
00184 
00191     const SUMOVehicleClasses& getDisallowedClasses(const std::string& type) const throw();
00192 
00193 
00200     SUMOReal getWidth(const std::string& type) const throw();
00202 
00203 
00204 private:
00205     struct TypeDefinition {
00207         TypeDefinition()
00208             : noLanes(1), speed((SUMOReal) 13.9), priority(-1),
00209               oneWay(true), discard(false), width(NBEdge::UNSPECIFIED_WIDTH) { }
00210 
00212         TypeDefinition(int _noLanes, SUMOReal _speed, int _priority, SUMOReal _width)
00213             : noLanes(_noLanes), speed(_speed), priority(_priority),
00214               oneWay(true), discard(false), width(_width) { }
00215 
00217         int noLanes;
00219         SUMOReal speed;
00221         int priority;
00223         SUMOVehicleClasses allowed;
00225         SUMOVehicleClasses notAllowed;
00227         bool oneWay;
00229         bool discard;
00231         SUMOReal width;
00232 
00233     };
00234 
00235 
00242     const TypeDefinition& getType(const std::string& name) const;
00243 
00244 
00245 private:
00247     TypeDefinition myDefaultType;
00248 
00250     typedef std::map<std::string, TypeDefinition> TypesCont;
00251 
00253     TypesCont myTypes;
00254 
00256     NBJunctionTypesMatrix myJunctionTypes;
00257 
00258 
00259 private:
00261     NBTypeCont(const NBTypeCont& s);
00262 
00264     NBTypeCont& operator=(const NBTypeCont& s);
00265 
00266 
00267 };
00268 
00269 
00270 #endif
00271 
00272 /****************************************************************************/
00273 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines