SUMO - Simulation of Urban MObility
SUMOVehicleClass.cpp File Reference
#include <config.h>
#include <string>
#include <map>
#include "SUMOVehicleClass.h"
#include <utils/common/TplConvert.h>
#include <utils/common/ToString.h>
#include <utils/common/MsgHandler.h>
#include <utils/common/StringTokenizer.h>
#include <utils/iodevices/OutputDevice.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 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...
 
std::string getVehicleClassNames (SVCPermissions permissions, bool expand)
 Returns the ids of the given classes, divided using a ' '. More...
 
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 isWaterway (SVCPermissions permissions)
 Returns whether an edge with the given permission is a waterway edge. 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)
 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
 
const int SUMOVehicleClass_MAX = SVC_CUSTOM2
 
StringBijection< SUMOVehicleClass >::Entry sumoVehicleClassStringInitializer []
 
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings (sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
 
StringBijection< SUMOVehicleShape >::Entry sumoVehicleShapeStringInitializer []
 
StringBijection< SUMOVehicleShape > SumoVehicleShapeStrings (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...
 

Detailed Description

Author
Daniel Krajzewicz
Jakob Erdmann
Michael Behrisch
Walter Bamberger
Date
2006-01-24
Version
Id
SUMOVehicleClass.cpp 25918 2017-09-07 19:38:16Z behrisch

Definition in file SUMOVehicleClass.cpp.

Function Documentation

bool canParseVehicleShape ( const std::string &  shape)

Checks whether the given string contains only known vehicle shape.

Definition at line 312 of file SUMOVehicleClass.cpp.

References StringBijection< T >::hasString().

Referenced by GNECalibratorVehicleType::setShape().

const double DEFAULT_CONTAINER_TRANSHIP_SPEED ( 5./3.  6)

Referenced by isForbidden().

const double DEFAULT_PEDESTRIAN_SPEED ( 5./3.  6)

Referenced by isForbidden().

const std::string DEFAULT_PEDTYPE_ID ( "DEFAULT_PEDTYPE"  )

Referenced by isForbidden().

const double DEFAULT_VEH_PROB ( 1.  )

Referenced by isForbidden().

const std::string DEFAULT_VTYPE_ID ( "DEFAULT_VEHTYPE"  )

Referenced by isForbidden().

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 185 of file SUMOVehicleClass.cpp.

References StringBijection< T >::get(), StringBijection< T >::getStrings(), and SVC_IGNORING.

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 176 of file SUMOVehicleClass.cpp.

References StringBijection< T >::get(), and StringBijection< T >::hasString().

Referenced by NIXMLTypesHandler::myStartElement(), RONetHandler::myStartElement(), NLHandler::myStartElement(), SUMOVehicleParserHelper::parseVehicleClass(), parseVehicleClasses(), GNECalibratorVehicleType::setVClass(), and TraCI_VehicleType::setVehicleClass().

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
Todo:
cache values?

Definition at line 161 of file SUMOVehicleClass.cpp.

References StringBijection< T >::get(), StringBijection< T >::getStrings(), and SVC_IGNORING.

Referenced by TraCI_Lane::getAllowed(), TraCI_Lane::getDisallowed(), and getVehicleClassNames().

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 303 of file SUMOVehicleClass.cpp.

References StringBijection< T >::get(), and StringBijection< T >::hasString().

Referenced by GNECalibratorVehicleType::setShape(), TraCI_VehicleType::setShapeClass(), and TraCI_Vehicle::setShapeClass().

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 318 of file SUMOVehicleClass.cpp.

References StringBijection< T >::getString().

Referenced by TraCI_VehicleType::getShapeClass(), TraCI_Vehicle::getShapeClass(), GNECalibratorVehicleTypeDialog::updateCalibratorVehicleTypeValues(), and SUMOVTypeParameter::write().

SVCPermissions invertPermissions ( SVCPermissions  permissions)

negate the given permissions and ensure that only relevant bits are set

Definition at line 250 of file SUMOVehicleClass.cpp.

References SVCAll.

Referenced by GNEEdge::getAttribute(), GNELane::getAttribute(), TraCI_Lane::getDisallowed(), parseVehicleClasses(), TraCIServerAPI_Edge::processSet(), GNELane::setAttribute(), and TraCI_Lane::setDisallowed().

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 333 of file SUMOVehicleClass.cpp.

References DEFAULT_CONTAINER_TRANSHIP_SPEED(), DEFAULT_PEDESTRIAN_SPEED(), DEFAULT_PEDTYPE_ID(), DEFAULT_VEH_PROB(), DEFAULT_VTYPE_ID(), and SVCAll.

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

bool isRailway ( SVCPermissions  permissions)

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

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

Definition at line 323 of file SUMOVehicleClass.cpp.

References SVC_PASSENGER, SVC_RAIL, SVC_RAIL_ELECTRIC, SVC_RAIL_URBAN, and SVC_TRAM.

Referenced by GNENet::addReversedEdge(), NBTrafficLightDefinition::collectAllLinks(), GNELane::drawAsRailway(), GUILane::drawAsRailway(), GNELane::getColorValue(), GUILane::getColorValue(), NWWriter_OpenDrive::getLaneType(), NBNode::getLinkState(), NBEdge::recheckLanes(), and NBEdge::shiftPositionAtNode().

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 328 of file SUMOVehicleClass.cpp.

References SVC_SHIP.

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

SVCPermissions parseVehicleClasses ( const std::string &  allowedS,
const std::string &  disallowedS 
)

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 236 of file SUMOVehicleClass.cpp.

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

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 255 of file SUMOVehicleClass.cpp.

References StringBijection< T >::getString(), getVehicleClassID(), and WRITE_WARNING.

void writePermissions ( OutputDevice &  into,
SVCPermissions  permissions 
)
void writePreferences ( OutputDevice &  into,
SVCPermissions  preferred 
)

writes allowed disallowed attributes if needed;

Definition at line 293 of file SUMOVehicleClass.cpp.

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

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

Variable Documentation

std::set<std::string> deprecatedVehicleClassesSeen
const int SUMOVehicleClass_MAX = SVC_CUSTOM2

Definition at line 141 of file SUMOVehicleClass.cpp.

Referenced by writePermissions().

StringBijection<SUMOVehicleClass>::Entry sumoVehicleClassStringInitializer[]

Definition at line 48 of file SUMOVehicleClass.cpp.

StringBijection<SUMOVehicleShape>::Entry sumoVehicleShapeStringInitializer[]

Definition at line 93 of file SUMOVehicleClass.cpp.

const SVCPermissions SVC_UNSPECIFIED = -1

permissions not specified

Definition at line 143 of file SUMOVehicleClass.cpp.

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