SUMO - Simulation of Urban MObility
NLTriggerBuilder Class Reference

Builds trigger objects for microsim. More...

#include <NLTriggerBuilder.h>

Inheritance diagram for NLTriggerBuilder:
GUITriggerBuilder

Public Member Functions

void buildVaporizer (const SUMOSAXAttributes &attrs)
 Builds a vaporization.
 NLTriggerBuilder ()
 Constructor.
void setHandler (NLHandler *handler)
 Sets the parent handler to use for nested parsing.
virtual ~NLTriggerBuilder ()
 Destructor.
parsing methods

These methods parse the attributes for each of the described trigger and call the according methods to build the trigger

void parseAndBuildLaneSpeedTrigger (MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base) throw (InvalidArgument)
 Parses his values and builds a lane speed trigger.
void parseAndBuildRerouter (MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base) throw (InvalidArgument)
 Parses his values and builds a rerouter.
void parseAndBuildBusStop (MSNet &net, const SUMOSAXAttributes &attrs) throw (InvalidArgument)
 Parses his values and builds a bus stop.

Protected Member Functions

building methods

Called with parsed values, these methods build the trigger.

These methods should be overriden for the gui loader in order to build visualizable versions of the triggers.

In most cases, these methods only call the constructor.

virtual MSLaneSpeedTriggerbuildLaneSpeedTrigger (MSNet &net, const std::string &id, const std::vector< MSLane * > &destLanes, const std::string &file)
 Builds a lane speed trigger.
virtual void buildBusStop (MSNet &net, const std::string &id, const std::vector< std::string > &lines, MSLane *lane, SUMOReal frompos, SUMOReal topos) throw (InvalidArgument)
 Builds a bus stop.
virtual MSTriggeredRerouterbuildRerouter (MSNet &net, const std::string &id, std::vector< MSEdge * > &edges, SUMOReal prob, const std::string &file, bool off)
 builds an rerouter
helper method for obtaining and checking values
std::string getFileName (const SUMOSAXAttributes &attrs, const std::string &base, const bool allowEmpty=false) throw (InvalidArgument)
 Helper method to obtain the filename.
MSLanegetLane (const SUMOSAXAttributes &attrs, const std::string &tt, const std::string &tid) throw (InvalidArgument)
 Returns the lane defined by attribute "lane".
SUMOReal getPosition (const SUMOSAXAttributes &attrs, MSLane *lane, const std::string &tt, const std::string &tid) throw (InvalidArgument)
 returns the position on the lane checking it

Protected Attributes

NLHandlermyHandler
 The parent handler to set for subhandlers.
bool myHaveWarnedAboutDeprecatedFriendlyPos

Detailed Description

Builds trigger objects for microsim.

The building methods may be overridden, to build guisim-instances of the triggers, for example.

Definition at line 68 of file NLTriggerBuilder.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 65 of file NLTriggerBuilder.cpp.

Destructor.

Definition at line 69 of file NLTriggerBuilder.cpp.


Member Function Documentation

void NLTriggerBuilder::buildBusStop ( MSNet net,
const std::string &  id,
const std::vector< std::string > &  lines,
MSLane lane,
SUMOReal  frompos,
SUMOReal  topos 
) throw (InvalidArgument) [protected, virtual]

Builds a bus stop.

Simply calls the MSBusStop constructor.

Parameters:
[in]netThe net the bus stop belongs to
[in]idThe id of the bus stop
[in]linesNames of the bus lines that halt on this bus stop
[in]laneThe lane the bus stop is placed on
[in]fromposBegin position of the bus stop on the lane
[in]toposEnd position of the bus stop on the lane
Exceptions:
InvalidArgumentIf the bus stop can not be added to the net (is duplicate)

Reimplemented in GUITriggerBuilder.

Definition at line 288 of file NLTriggerBuilder.cpp.

MSLaneSpeedTrigger * NLTriggerBuilder::buildLaneSpeedTrigger ( MSNet net,
const std::string &  id,
const std::vector< MSLane * > &  destLanes,
const std::string &  file 
) [protected, virtual]

Builds a lane speed trigger.

Simply calls the MSLaneSpeedTrigger constructor.

Parameters:
[in]netThe net the lane speed trigger belongs to
[in]idThe id of the lane speed trigger
[in]destLanesList of lanes affected by this speed trigger
[in]fileName of the file to read the speeds to set from
See also:
MSLaneSpeedTrigger
Exceptions:
ProcessErrorIf the XML definition file is errornous

Reimplemented in GUITriggerBuilder.

Definition at line 260 of file NLTriggerBuilder.cpp.

MSTriggeredRerouter * NLTriggerBuilder::buildRerouter ( MSNet net,
const std::string &  id,
std::vector< MSEdge * > &  edges,
SUMOReal  prob,
const std::string &  file,
bool  off 
) [protected, virtual]

builds an rerouter

Simply calls the MSTriggeredRerouter constructor.

Parameters:
[in]netThe net the rerouter belongs to
[in]idThe id of the rerouter
[in]edgesThe edges the rerouter is placed at
[in]probThe probability the rerouter reoutes vehicles with
[in]fileThe file to read the reroute definitions from

Reimplemented in GUITriggerBuilder.

Definition at line 280 of file NLTriggerBuilder.cpp.

Builds a vaporization.

Parses the attributes, reporting errors if the time values are false or the edge is not known. Instatiates events for enabling and disabling the vaporization otherwise.

Parameters:
[in]attrsSAX-attributes which define the vaporizer
Note:
recheck throwing the exception

Definition at line 78 of file NLTriggerBuilder.cpp.

References MSEventControl::ADAPT_AFTER_EXECUTION, MSEventControl::addEvent(), MSEdge::decVaporization(), MSEdge::dictionary(), MSNet::getBeginOfTimestepEvents(), MSNet::getInstance(), OptionsCont::getOptions(), SUMOSAXAttributes::getStringReporting(), SUMOSAXAttributes::getSUMOTimeReporting(), MSEdge::incVaporization(), string2time(), SUMO_ATTR_BEGIN, SUMO_ATTR_END, SUMO_ATTR_ID, and WRITE_ERROR.

Referenced by NLHandler::myStartElement().

std::string NLTriggerBuilder::getFileName ( const SUMOSAXAttributes attrs,
const std::string &  base,
const bool  allowEmpty = false 
) throw (InvalidArgument) [protected]

Helper method to obtain the filename.

Retrieves "file" from attributes, checks whether it is absolute and extends it by the given base path if not. Returns this information.

Parameters:
[in]attrsThe attributes to obtain the file name from
[in]baseThe base path (the path the loaded additional file lies in)
Returns:
The (expanded) path to the named file
Todo:
Recheck usage of the helper class

Definition at line 302 of file NLTriggerBuilder.cpp.

References FileHelpers::getConfigurationRelative(), FileHelpers::isAbsolute(), and SUMO_ATTR_FILE.

MSLane * NLTriggerBuilder::getLane ( const SUMOSAXAttributes attrs,
const std::string &  tt,
const std::string &  tid 
) throw (InvalidArgument) [protected]

Returns the lane defined by attribute "lane".

Retrieves the lane id from the given attrs. Tries to retrieve the lane, throws an InvalidArgument if it does not exist.

Parameters:
[in]attrsThe attributes to obtain the lane id from
[in]ttThe trigger type (for user output)
[in]tidThe trigger id (for user output)
Returns:
The named lane if it is known
Exceptions:
InvalidArgumentIf the named lane does not exist or a lane is not named

Definition at line 323 of file NLTriggerBuilder.cpp.

References MSLane::dictionary(), and SUMO_ATTR_LANE.

SUMOReal NLTriggerBuilder::getPosition ( const SUMOSAXAttributes attrs,
MSLane lane,
const std::string &  tt,
const std::string &  tid 
) throw (InvalidArgument) [protected]

returns the position on the lane checking it

This method extracts the position, checks whether it shall be mirrored and checks whether it is within the lane. If not, an error is reported and a InvalidArgument is thrown.

Parameters:
[in]attrsThe attributes to obtain the position from
[in]laneThe lane the position shall be valid for
[in]ttThe trigger type (for user output)
[in]tidThe trigger id (for user output)
Returns:
The position on the lane
Exceptions:
InvalidArgumentIf the position is beyond the lane

Definition at line 337 of file NLTriggerBuilder.cpp.

References Named::getID(), MSLane::getLength(), SUMO_ATTR_FRIENDLY_POS, SUMO_ATTR_FRIENDLY_POS__DEPRECATED, SUMO_ATTR_POSITION, SUMOReal, toString(), and WRITE_WARNING.

Parses his values and builds a bus stop.

Parameters:
[in]netThe network the bus stop belongs to
[in]attrsSAX-attributes which define the trigger
Exceptions:
InvalidArgumentIf a parameter (lane/position) is not valid

Definition at line 154 of file NLTriggerBuilder.cpp.

References MSLane::getLength(), SUMOSAXAttributes::parseStringVector(), SUMO_ATTR_ENDPOS, SUMO_ATTR_FRIENDLY_POS, SUMO_ATTR_FRIENDLY_POS__DEPRECATED, SUMO_ATTR_FROM, SUMO_ATTR_ID, SUMO_ATTR_LINES, SUMO_ATTR_STARTPOS, SUMO_ATTR_TO, SUMOReal, toString(), and WRITE_WARNING.

Referenced by NLHandler::myStartElement().

void NLTriggerBuilder::parseAndBuildLaneSpeedTrigger ( MSNet net,
const SUMOSAXAttributes attrs,
const std::string &  base 
) throw (InvalidArgument)

Parses his values and builds a lane speed trigger.

If one of the declaration values is errornous, an InvalidArgument is thrown.

If the XML-file parsed during initialisation is errornous, and the MSLaneSpeedTrigger-constructor throws a ProcessError due to this, this exception is catched and an InvalidArgument with the message given in the ProcessError is thrown.

Parameters:
[in]netThe network the lane speed trigger belongs to
[in]attrsSAX-attributes which define the trigger
[in]baseThe base path
Exceptions:
InvalidArgumentIf a parameter (lane/position) is not valid or the read definition is errornous
See also:
buildLaneSpeedTrigger

Definition at line 114 of file NLTriggerBuilder.cpp.

References MSLane::dictionary(), SUMOSAXAttributes::parseStringVector(), GenericSAXHandler::registerParent(), SUMO_ATTR_ID, SUMO_ATTR_LANES, and SUMO_TAG_VSS.

Referenced by NLHandler::myStartElement().

void NLTriggerBuilder::parseAndBuildRerouter ( MSNet net,
const SUMOSAXAttributes attrs,
const std::string &  base 
) throw (InvalidArgument)

Parses his values and builds a rerouter.

Parameters:
[in]netThe network the rerouter belongs to
[in]attrsSAX-attributes which define the trigger
[in]baseThe base path
Exceptions:
InvalidArgumentIf a parameter (edge) is not valid

Definition at line 217 of file NLTriggerBuilder.cpp.

References MSEdge::dictionary(), SUMOSAXAttributes::parseStringVector(), GenericSAXHandler::registerParent(), SUMO_ATTR_EDGES, SUMO_ATTR_ID, SUMO_ATTR_OFF, SUMO_ATTR_PROB, SUMO_TAG_REROUTER, and SUMOReal.

Referenced by NLHandler::myStartElement().

Sets the parent handler to use for nested parsing.

Parameters:
[in]handlerThe netload handler to set

Definition at line 72 of file NLTriggerBuilder.cpp.

References myHandler.

Referenced by load(), and GUILoadThread::run().


Field Documentation

The parent handler to set for subhandlers.

Definition at line 289 of file NLTriggerBuilder.h.

Referenced by setHandler().


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines