SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>

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.
const SUMOReal DEFAULT_VEH_ACCEL (2.6)
const SUMOVehicleClass DEFAULT_VEH_CLASS (SVC_UNKNOWN)
const SUMOReal DEFAULT_VEH_DECEL (4.5)
const SumoXMLTag DEFAULT_VEH_FOLLOW_MODEL (SUMO_TAG_CF_KRAUSS)
const SUMOReal DEFAULT_VEH_HEIGHT (1.5)
const std::string DEFAULT_VEH_LANE_CHANGE_MODEL ("dkrajzew2008")
const SUMOReal DEFAULT_VEH_LENGTH (5.)
const SUMOReal DEFAULT_VEH_MAXSPEED (70.0)
const SUMOReal DEFAULT_VEH_MINGAP (2.5)
const SUMOReal DEFAULT_VEH_PROB (1.)
const SUMOVehicleShape DEFAULT_VEH_SHAPE (SVS_UNKNOWN)
const SUMOReal DEFAULT_VEH_SIGMA (0.5)
const SUMOReal DEFAULT_VEH_SPEEDDEV (0.)
const SUMOReal DEFAULT_VEH_SPEEDFACTOR (1.)
const SUMOReal DEFAULT_VEH_TAU (1.)
const SUMOReal DEFAULT_VEH_WIDTH (2.)
const std::string DEFAULT_VTYPE_ID ("DEFAULT_VEHTYPE")
std::string getAllowedVehicleClassNames (SVCPermissions permissions)
 Returns the ids of the given classes, divided using a ' '.
std::vector< std::string > getAllowedVehicleClassNamesList (SVCPermissions permissions)
 Returns the ids of the given classes, divided using a ' '.
std::pair< std::string, boolgetPermissionEncoding (SVCPermissions permissions)
 returns the shorter encoding of the given permissions (selects automatically wether to use allow or disallow attribute)
int getVehicleClassCompoundID (const std::string &name)
 Returns the OR'ed id of the compound class given by its name.
std::string getVehicleClassCompoundName (int id)
SUMOVehicleClass getVehicleClassID (const std::string &name)
 Returns the class id of the abstract class given by its name.
SUMOEmissionClass getVehicleEmissionTypeID (const std::string &name)
 Returns the class id of the emission class given by its name.
std::string getVehicleEmissionTypeName (SUMOEmissionClass id)
 Returns the class name of the emission class given by its id.
SUMOVehicleShape getVehicleShapeID (const std::string &name)
 Returns the class id of the shape class given by its name.
std::string getVehicleShapeName (SUMOVehicleShape id)
 Returns the class name of the shape class given by its id.
SVCPermissions parseVehicleClasses (const std::string &allowedS)
 Parses the given definition of allowed vehicle classes into the given containers.
SVCPermissions parseVehicleClasses (const std::string &allowedS, const std::string &disallowedS)
 Parses the given definition of allowed/disallowed vehicle classes into the given containers.
SVCPermissions parseVehicleClasses (const std::vector< std::string > &allowedS)
 Encodes the given vector of allowed classs into a bitset.

Variables

const int SUMOVehicleClass_MAX = SVC_PEDESTRIAN
StringBijection
< SUMOVehicleClass >::Entry 
sumoVehicleClassStringInitializer []
StringBijection< SUMOVehicleClassSumoVehicleClassStrings (sumoVehicleClassStringInitializer, SVC_PEDESTRIAN)
StringBijection
< SUMOVehicleShape >::Entry 
sumoVehicleShapeStringInitializer []
StringBijection< SUMOVehicleShapeSumoVehicleShapeStrings (sumoVehicleShapeStringInitializer, SVS_UNKNOWN)
const SVCPermissions SVCFreeForAll = std::numeric_limits<SVCPermissions>::max()

Detailed Description

Author:
Daniel Krajzewicz
Jakob Erdmann
Michael Behrisch
Walter Bamberger
Date:
2006-01-24
Version:
Id:
SUMOVehicleClass.cpp 12038 2012-03-07 14:50:31Z namdre

Definition in file SUMOVehicleClass.cpp.


Function Documentation

bool canParseVehicleClasses ( const std::string &  classes)

Checks whether the given string contains only known vehicle classes.

Definition at line 223 of file SUMOVehicleClass.cpp.

References StringTokenizer::hasNext(), StringTokenizer::next(), and SumoVehicleClassStrings.

const SUMOReal DEFAULT_VEH_ACCEL ( 2.  6)
const SUMOVehicleClass DEFAULT_VEH_CLASS ( SVC_UNKNOWN  )
const SUMOReal DEFAULT_VEH_DECEL ( 4.  5)
const SumoXMLTag DEFAULT_VEH_FOLLOW_MODEL ( SUMO_TAG_CF_KRAUSS  )
const SUMOReal DEFAULT_VEH_HEIGHT ( 1.  5)
const std::string DEFAULT_VEH_LANE_CHANGE_MODEL ( "dkrajzew2008"  )
const SUMOReal DEFAULT_VEH_LENGTH ( 5.  )
const SUMOReal DEFAULT_VEH_MAXSPEED ( 70.  0)
const SUMOReal DEFAULT_VEH_MINGAP ( 2.  5)
const SUMOReal DEFAULT_VEH_PROB ( 1.  )
const SUMOVehicleShape DEFAULT_VEH_SHAPE ( SVS_UNKNOWN  )
const SUMOReal DEFAULT_VEH_SIGMA ( 0.  5)
const SUMOReal DEFAULT_VEH_SPEEDDEV ( 0.  )
const SUMOReal DEFAULT_VEH_SPEEDFACTOR ( 1.  )
const SUMOReal DEFAULT_VEH_TAU ( 1.  )
const SUMOReal DEFAULT_VEH_WIDTH ( 2.  )
const std::string DEFAULT_VTYPE_ID ( "DEFAULT_VEHTYPE"  )
std::string getAllowedVehicleClassNames ( SVCPermissions  permissions)

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

Parameters:
[in]thepermissions to encode
Returns:
The string representation of these classes

Definition at line 138 of file SUMOVehicleClass.cpp.

References getAllowedVehicleClassNamesList().

Referenced by getPermissionEncoding(), NWWriter_SUMO::writePermissions(), and NWWriter_SUMO::writePreferences().

std::vector<std::string> getAllowedVehicleClassNamesList ( 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 154 of file SUMOVehicleClass.cpp.

References SumoVehicleClassStrings, and SVC_UNKNOWN.

Referenced by getAllowedVehicleClassNames(), and TraCIServerAPI_Lane::processGet().

std::pair<std::string, bool> getPermissionEncoding ( SVCPermissions  permissions)

returns the shorter encoding of the given permissions (selects automatically wether to use allow or disallow attribute)

Returns:
the string and true for allow, false for disallow

Definition at line 169 of file SUMOVehicleClass.cpp.

References getAllowedVehicleClassNames(), SUMOVehicleClass_MAX, SumoVehicleClassStrings, and SVCFreeForAll.

Referenced by NWWriter_SUMO::writePermissions().

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

References SumoVehicleClassStrings, and SVC_UNKNOWN.

std::string getVehicleClassCompoundName ( int  id)

Definition at line 121 of file SUMOVehicleClass.cpp.

References SumoVehicleClassStrings.

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

References SumoVehicleClassStrings.

Referenced by NBEdgeCont::applyOptions(), SUMOVehicleParserHelper::parseVehicleClass(), parseVehicleClasses(), and TraCIServerAPI_VehicleType::setVariable().

SUMOEmissionClass getVehicleEmissionTypeID ( const std::string &  name)

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

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

Definition at line 276 of file SUMOVehicleClass.cpp.

References TplConvert< E >::_2int(), SVE_HDV_12_1, SVE_HDV_3_1, SVE_HDV_6_1, SVE_HDV_A0_12_1, SVE_HDV_A0_3_1, SVE_HDV_A0_6_1, SVE_P_LDV_14_1, SVE_P_LDV_7_1, SVE_P_LDV_A0_14_1, SVE_P_LDV_A0_7_1, SVE_UNKNOWN, and SVE_ZERO_EMISSIONS.

Referenced by SUMOVehicleParserHelper::parseEmissionClass(), and TraCIServerAPI_VehicleType::setVariable().

std::string getVehicleEmissionTypeName ( SUMOEmissionClass  id)

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

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

Definition at line 310 of file SUMOVehicleClass.cpp.

References SVE_ZERO_EMISSIONS, and toString().

Referenced by TraCIServerAPI_VehicleType::getVariable(), and SUMOVTypeParameter::write().

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

References SumoVehicleShapeStrings.

Referenced by TraCIServerAPI_VehicleType::setVariable().

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

References SumoVehicleShapeStrings.

Referenced by TraCIServerAPI_VehicleType::getVariable(), and SUMOVTypeParameter::write().

SVCPermissions parseVehicleClasses ( const std::string &  allowedS)

Parses the given definition of allowed vehicle classes into the given containers.

Parameters:
[in]classNamesSpace separated class names
[out]containerThe set of vehicle classes to fill throws ProcessErrorr if parsing fails

Definition at line 212 of file SUMOVehicleClass.cpp.

References getVehicleClassID(), StringTokenizer::hasNext(), and StringTokenizer::next().

Referenced by NIImporter_SUMO::_loadNetwork(), NIXMLEdgesHandler::addEdge(), NLHandler::addLane(), NIXMLEdgesHandler::addLane(), NIXMLTypesHandler::myStartElement(), RONetHandler::parseLane(), parseVehicleClasses(), TraCIServerAPI_Edge::processSet(), and TraCIServerAPI_Lane::processSet().

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

Parses the given definition of allowed/disallowed vehicle classes into the given containers.

Parameters:
[in]allowedSDefinition which classes are allowed
[in]disallowedSDefinition which classes are not allowed Encodes the given vector of allowed and disallowed classs into a bitset
[in]allowedSDefinition which classes are allowed
[in]disallowedSDefinition which classes are not allowed

Definition at line 234 of file SUMOVehicleClass.cpp.

References parseVehicleClasses(), SVCFreeForAll, and WRITE_WARNING.

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

Encodes the given vector of allowed classs into a bitset.

Parameters:
[in]classesSThe names vector to parse

Definition at line 249 of file SUMOVehicleClass.cpp.

References getVehicleClassID().


Variable Documentation

const int SUMOVehicleClass_MAX = SVC_PEDESTRIAN

Definition at line 112 of file SUMOVehicleClass.cpp.

Referenced by getPermissionEncoding().

StringBijection<SUMOVehicleClass>::Entry sumoVehicleClassStringInitializer[]
Initial value:
{
{"unknown", SVC_UNKNOWN},
{"private", SVC_PRIVATE},
{"public_transport", SVC_PUBLIC_TRANSPORT},
{"public_emergency", SVC_PUBLIC_EMERGENCY},
{"public_authority", SVC_PUBLIC_AUTHORITY},
{"public_army", SVC_PUBLIC_ARMY},
{"vip", SVC_VIP},
{"ignoring", SVC_IGNORING},
{"passenger", SVC_PASSENGER},
{"hov", SVC_HOV},
{"taxi", SVC_TAXI},
{"bus", SVC_BUS},
{"delivery", SVC_DELIVERY},
{"transport", SVC_TRANSPORT},
{"lightrail", SVC_LIGHTRAIL},
{"cityrail", SVC_CITYRAIL},
{"rail_slow", SVC_RAIL_SLOW},
{"rail_fast", SVC_RAIL_FAST},
{"motorcycle", SVC_MOTORCYCLE},
{"bicycle", SVC_BICYCLE},
{"pedestrian", SVC_PEDESTRIAN}
}

Definition at line 51 of file SUMOVehicleClass.cpp.

StringBijection<SUMOVehicleShape>::Entry sumoVehicleShapeStringInitializer[]
Initial value:
{
{"pedestrian", SVS_PEDESTRIAN},
{"bicycle", SVS_BICYCLE},
{"motorcycle", SVS_MOTORCYCLE},
{"passenger", SVS_PASSENGER},
{"passenger/sedan", SVS_PASSENGER_SEDAN},
{"passenger/hatchback", SVS_PASSENGER_HATCHBACK},
{"passenger/wagon", SVS_PASSENGER_WAGON},
{"passenger/van", SVS_PASSENGER_VAN},
{"delivery", SVS_DELIVERY},
{"transport", SVS_TRANSPORT},
{"transport/semitrailer", SVS_TRANSPORT_SEMITRAILER},
{"transport/trailer", SVS_TRANSPORT_1TRAILER},
{"bus", SVS_BUS},
{"bus/city", SVS_BUS_CITY},
{"bus/flexible", SVS_BUS_CITY_FLEXIBLE},
{"bus/overland", SVS_BUS_OVERLAND},
{"bus/trolley", SVS_BUS_TROLLEY},
{"rail", SVS_RAIL},
{"rail/light", SVS_RAIL_LIGHT},
{"rail/city", SVS_RAIL_CITY},
{"rail/slow", SVS_RAIL_SLOW},
{"rail/fast", SVS_RAIL_FAST},
{"rail/cargo", SVS_RAIL_CARGO},
{"evehicle", SVS_E_VEHICLE},
{"ant", SVS_ANT},
}

Definition at line 79 of file SUMOVehicleClass.cpp.