Eclipse SUMO - Simulation of Urban MObility
SUMOVehicleClass.cpp File Reference
#include <config.h>
#include <string>
#include <map>
#include "SUMOVehicleClass.h"
#include <utils/common/StringUtils.h>
#include <utils/common/ToString.h>
#include <utils/common/MsgHandler.h>
#include <utils/common/StringTokenizer.h>
#include <utils/iodevices/OutputDevice.h>
#include <utils/xml/SUMOSAXAttributes.h>
Include dependency graph for SUMOVehicleClass.cpp:

Go to the source code of this file.

Functions

bool canParseVehicleClasses (const std::string &classes)
 Checks whether the given string contains only known vehicle classes. More...
 
bool canParseVehicleShape (const std::string &shape)
 Checks whether the given string contains only known vehicle shape. More...
 
const std::string DEFAULT_BIKETYPE_ID ("DEFAULT_BIKETYPE")
 
const double DEFAULT_CONTAINER_TRANSHIP_SPEED (5./3.6)
 
const double DEFAULT_PEDESTRIAN_SPEED (5./3.6)
 
const std::string DEFAULT_PEDTYPE_ID ("DEFAULT_PEDTYPE")
 
const double DEFAULT_VEH_PROB (1.)
 
const std::string DEFAULT_VTYPE_ID ("DEFAULT_VEHTYPE")
 
int getVehicleClassCompoundID (const std::string &name)
 Returns the OR'ed id of the compound class given by its name. More...
 
SUMOVehicleClass getVehicleClassID (const std::string &name)
 Returns the class id of the abstract class given by its name. More...
 
const std::string & getVehicleClassNames (SVCPermissions permissions, bool expand)
 Returns the ids of the given classes, divided using a ' '. More...
 
const std::vector< std::string > & getVehicleClassNamesList (SVCPermissions permissions)
 Returns the ids of the given classes, divided using a ' '. More...
 
SUMOVehicleShape getVehicleShapeID (const std::string &name)
 Returns the class id of the shape class given by its name. More...
 
std::string getVehicleShapeName (SUMOVehicleShape id)
 Returns the class name of the shape class given by its id. More...
 
SVCPermissions invertPermissions (SVCPermissions permissions)
 negate the given permissions and ensure that only relevant bits are set More...
 
bool isForbidden (SVCPermissions permissions)
 Returns whether an edge with the given permission is a forbidden edge. More...
 
bool isRailway (SVCPermissions permissions)
 Returns whether an edge with the given permission is a railway edge. More...
 
bool isSidewalk (SVCPermissions permissions)
 Returns whether an edge with the given permission is a sidewalk. More...
 
bool isWaterway (SVCPermissions permissions)
 Returns whether an edge with the given permission is a waterway edge. More...
 
bool noVehicles (SVCPermissions permissions)
 Returns whether an edge with the given permission forbids vehicles. More...
 
std::map< SVCPermissions, double > parseStopOffsets (const SUMOSAXAttributes &attrs, bool &ok)
 Extract stopOffsets from attributes of stopOffset element. More...
 
SVCPermissions parseVehicleClasses (const std::string &allowedS)
 Parses the given definition of allowed vehicle classes into the given containers Deprecated classes go into a separate container. More...
 
SVCPermissions parseVehicleClasses (const std::string &allowedS, const std::string &disallowedS, double networkVersion)
 Encodes the given vector of allowed and disallowed classes into a bitset. More...
 
SVCPermissions parseVehicleClasses (const std::vector< std::string > &allowedS)
 Encodes the given vector of allowed classs into a bitset Unlike the methods which parse a string it gives immediately a warning output on deprecated vehicle classes. More...
 
void writePermissions (OutputDevice &into, SVCPermissions permissions)
 writes allowed disallowed attributes if needed; More...
 
void writePreferences (OutputDevice &into, SVCPermissions preferred)
 writes allowed disallowed attributes if needed; More...
 

Variables

std::set< std::string > deprecatedVehicleClassesSeen
 
static std::map< SVCPermissions, std::string > getVehicleClassNamesCached
 
static std::map< std::string, SVCPermissionsparseVehicleClassesCached
 
const int SUMOVehicleClass_MAX = SVC_CUSTOM2
 
StringBijection< SUMOVehicleClass >::Entry sumoVehicleClassStringInitializer []
 
StringBijection< SUMOVehicleClassSumoVehicleClassStrings (sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
 
StringBijection< SUMOVehicleShape >::Entry sumoVehicleShapeStringInitializer []
 
StringBijection< SUMOVehicleShapeSumoVehicleShapeStrings (sumoVehicleShapeStringInitializer, SVS_UNKNOWN, false)
 
const SVCPermissions SVC_UNSPECIFIED = -1
 permissions not specified More...
 
const SVCPermissions SVCAll = 2 * SUMOVehicleClass_MAX - 1
 all VClasses are allowed More...
 
static std::string vehicleClassNameAll = "all"
 
static std::map< int, std::vector< std::string > > vehicleClassNamesListCached
 

Detailed Description

Author
Daniel Krajzewicz
Jakob Erdmann
Michael Behrisch
Walter Bamberger
Laura Bieker-Walz
Date
2006-01-24
Version
$Id$

Definition in file SUMOVehicleClass.cpp.

Function Documentation

◆ canParseVehicleClasses()

bool canParseVehicleClasses ( const std::string &  classes)

◆ canParseVehicleShape()

bool canParseVehicleShape ( const std::string &  shape)

Checks whether the given string contains only known vehicle shape.

Definition at line 353 of file SUMOVehicleClass.cpp.

References SumoVehicleShapeStrings.

Referenced by GNEVehicleType::isValid().

◆ DEFAULT_BIKETYPE_ID()

const std::string DEFAULT_BIKETYPE_ID ( "DEFAULT_BIKETYPE"  )

◆ DEFAULT_CONTAINER_TRANSHIP_SPEED()

const double DEFAULT_CONTAINER_TRANSHIP_SPEED ( 5./3.  6)

◆ DEFAULT_PEDESTRIAN_SPEED()

const double DEFAULT_PEDESTRIAN_SPEED ( 5./3.  6)

◆ DEFAULT_PEDTYPE_ID()

const std::string DEFAULT_PEDTYPE_ID ( "DEFAULT_PEDTYPE"  )

◆ DEFAULT_VEH_PROB()

const double DEFAULT_VEH_PROB ( 1.  )

◆ DEFAULT_VTYPE_ID()

const std::string DEFAULT_VTYPE_ID ( "DEFAULT_VEHTYPE"  )

◆ getVehicleClassCompoundID()

int getVehicleClassCompoundID ( const std::string &  name)

Returns the OR'ed id of the compound class given by its name.

Parameters
[in]nameThe name of the abstract vehicle class
Returns
The OR'ed combination of base enum values

Definition at line 210 of file SUMOVehicleClass.cpp.

References SumoVehicleClassStrings, and SVC_IGNORING.

◆ getVehicleClassID()

SUMOVehicleClass getVehicleClassID ( const std::string &  name)

Returns the class id of the abstract class given by its name.

Parameters
[in]nameThe name of the abstract vehicle class
Returns
The internal representation of this class. Name must not be a compound name

Definition at line 201 of file SUMOVehicleClass.cpp.

References SumoVehicleClassStrings.

Referenced by NIXMLTypesHandler::myStartElement(), RONetHandler::myStartElement(), NLHandler::myStartElement(), SUMOVehicleParserHelper::parseVehicleClass(), parseVehicleClasses(), and GNEVehicleType::setAttribute().

◆ getVehicleClassNames()

◆ getVehicleClassNamesList()

const std::vector<std::string>& getVehicleClassNamesList ( SVCPermissions  permissions)

Returns the ids of the given classes, divided using a ' '.

Parameters
[in]thepermissions to encode
Returns
The string representation of these classes as a vector

Definition at line 182 of file SUMOVehicleClass.cpp.

References SumoVehicleClassStrings, SVC_IGNORING, and vehicleClassNamesListCached.

Referenced by libsumo::Lane::getAllowed(), libsumo::Lane::getDisallowed(), and getVehicleClassNames().

◆ getVehicleShapeID()

SUMOVehicleShape getVehicleShapeID ( const std::string &  name)

Returns the class id of the shape class given by its name.

Parameters
[in]nameThe name of the shape class
Returns
The internal representation of this class

Definition at line 343 of file SUMOVehicleClass.cpp.

References SumoVehicleShapeStrings.

Referenced by GNEVehicle::drawGL(), GNEVehicleType::setAttribute(), and GNEVehicleTypeDialog::VTypeAtributes::VShapeRow::setVShapeLabelImage().

◆ getVehicleShapeName()

std::string getVehicleShapeName ( SUMOVehicleShape  id)

Returns the class name of the shape class given by its id.

Parameters
[in]idThe id of the shape class
Returns
The string representation of this class

Definition at line 359 of file SUMOVehicleClass.cpp.

References SumoVehicleShapeStrings.

Referenced by GNEVehicleType::getAttribute(), GUIVehicle::getTypeParameterWindow(), GNEVehicleType::overwriteVType(), and SUMOVTypeParameter::write().

◆ invertPermissions()

◆ isForbidden()

bool isForbidden ( SVCPermissions  permissions)

Returns whether an edge with the given permission is a forbidden edge.

Parameters
[in]permissionsThe permissions of the edge
Returns
Whether the edge is forbidden

Definition at line 376 of file SUMOVehicleClass.cpp.

References SVCAll.

Referenced by NBOwnTLDef::allowUnrelated(), NBNode::ApproachingDivider::ApproachingDivider(), NBEdge::divideOnEdges(), noVehicles(), NBOwnTLDef::patchStateForCrossings(), and NBEdge::recheckLanes().

◆ isRailway()

◆ isSidewalk()

bool isSidewalk ( SVCPermissions  permissions)

Returns whether an edge with the given permission is a sidewalk.

Parameters
[in]permissionsThe permissions of the edge
Returns
Whether the edge is a sidewalk

Definition at line 382 of file SUMOVehicleClass.cpp.

References SVC_PEDESTRIAN, and SVCAll.

Referenced by noVehicles().

◆ isWaterway()

bool isWaterway ( SVCPermissions  permissions)

Returns whether an edge with the given permission is a waterway edge.

Parameters
[in]permissionsThe permissions of the edge
Returns
Whether the edge is a waterway edge

Definition at line 370 of file SUMOVehicleClass.cpp.

References SVC_SHIP.

Referenced by NBNodeTypeComputer::computeNodeTypes(), GNELane::drawAsWaterway(), GUILane::drawAsWaterway(), GUILane::drawGL(), and GUIJunctionWrapper::GUIJunctionWrapper().

◆ noVehicles()

bool noVehicles ( SVCPermissions  permissions)

Returns whether an edge with the given permission forbids vehicles.

Parameters
[in]permissionsThe permissions of the edge
Returns
Whether the edge is forbidden for vehicles

Definition at line 388 of file SUMOVehicleClass.cpp.

References isForbidden(), and isSidewalk().

Referenced by libsumo::Edge::getLastStepLength(), MSDelayBasedTrafficLightLogic::init(), and MSActuatedTrafficLightLogic::init().

◆ parseStopOffsets()

std::map<SVCPermissions, double> parseStopOffsets ( const SUMOSAXAttributes attrs,
bool &  ok 
)

◆ parseVehicleClasses() [1/3]

◆ parseVehicleClasses() [2/3]

SVCPermissions parseVehicleClasses ( const std::string &  allowedS,
const std::string &  disallowedS,
double  networkVersion = NETWORK_VERSION 
)

Encodes the given vector of allowed and disallowed classes into a bitset.

Parameters
[in]allowedSDefinition which classes are allowed
[in]disallowedSDefinition which classes are not allowed

Definition at line 271 of file SUMOVehicleClass.cpp.

References invertPermissions(), parseVehicleClasses(), SVC_RAIL_FAST, SVCAll, and WRITE_WARNING.

◆ parseVehicleClasses() [3/3]

SVCPermissions parseVehicleClasses ( const std::vector< std::string > &  allowedS)

Encodes the given vector of allowed classs into a bitset Unlike the methods which parse a string it gives immediately a warning output on deprecated vehicle classes.

Parameters
[in]classesSThe names vector to parse

Definition at line 292 of file SUMOVehicleClass.cpp.

References getVehicleClassID(), SumoVehicleClassStrings, SVCAll, and WRITE_WARNING.

◆ writePermissions()

◆ writePreferences()

void writePreferences ( OutputDevice into,
SVCPermissions  preferred 
)

writes allowed disallowed attributes if needed;

Definition at line 333 of file SUMOVehicleClass.cpp.

References getVehicleClassNames(), SUMO_ATTR_PREFER, SVCAll, and OutputDevice::writeAttr().

Referenced by NWWriter_XML::writeEdgesAndConnections(), and NWWriter_SUMO::writeLane().

Variable Documentation

◆ deprecatedVehicleClassesSeen

std::set<std::string> deprecatedVehicleClassesSeen

◆ getVehicleClassNamesCached

std::map<SVCPermissions, std::string> getVehicleClassNamesCached
static

Definition at line 138 of file SUMOVehicleClass.cpp.

Referenced by getVehicleClassNames().

◆ parseVehicleClassesCached

std::map<std::string, SVCPermissions> parseVehicleClassesCached
static

Definition at line 137 of file SUMOVehicleClass.cpp.

Referenced by canParseVehicleClasses(), and parseVehicleClasses().

◆ SUMOVehicleClass_MAX

const int SUMOVehicleClass_MAX = SVC_CUSTOM2

◆ sumoVehicleClassStringInitializer

StringBijection<SUMOVehicleClass>::Entry sumoVehicleClassStringInitializer[]

Definition at line 43 of file SUMOVehicleClass.cpp.

◆ SumoVehicleClassStrings

◆ sumoVehicleShapeStringInitializer

StringBijection<SUMOVehicleShape>::Entry sumoVehicleShapeStringInitializer[]

Definition at line 88 of file SUMOVehicleClass.cpp.

◆ SumoVehicleShapeStrings

◆ SVC_UNSPECIFIED

const SVCPermissions SVC_UNSPECIFIED = -1

permissions not specified

Definition at line 149 of file SUMOVehicleClass.cpp.

Referenced by NIXMLEdgesHandler::addEdge(), and NWWriter_SUMO::writeLane().

◆ SVCAll

◆ vehicleClassNameAll

std::string vehicleClassNameAll = "all"
static

Definition at line 139 of file SUMOVehicleClass.cpp.

Referenced by getVehicleClassNames().

◆ vehicleClassNamesListCached

std::map<int, std::vector<std::string> > vehicleClassNamesListCached
static

Definition at line 136 of file SUMOVehicleClass.cpp.

Referenced by getVehicleClassNamesList().