NLDiscreteEventBuilder Class Reference

#include <NLDiscreteEventBuilder.h>


Detailed Description

This class is responsible for building event-handling actions which the simulation shall execute.

Definition at line 52 of file NLDiscreteEventBuilder.h.


Public Types

enum  ActionType { EV_SAVETLSTATE, EV_SAVETLSWITCHES, EV_SAVETLSWITCHSTATES }
 Known action types. More...

Public Member Functions

void addAction (const SUMOSAXAttributes &attrs, const std::string &basePath)
 Builds an action and saves it for further use.
 NLDiscreteEventBuilder (MSNet &net)
 Constructor.
 ~NLDiscreteEventBuilder ()
 Destructor.

Protected Types

typedef std::map< std::string,
ActionType
KnownActions
 Definitions of a storage for build actions.

Protected Attributes

KnownActions myActions
 Build actions that shall be executed during the simulation.
MSNetmyNet

Private Member Functions

void buildSaveTLStateCommand (const SUMOSAXAttributes &attrs, const std::string &basePath)
 Builds an action which saves the state of a certain tls into a file.
void buildSaveTLSwitchesCommand (const SUMOSAXAttributes &attrs, const std::string &basePath)
 Builds an action which saves the switch times of links into a file.
void buildSaveTLSwitchStatesCommand (const SUMOSAXAttributes &attrs, const std::string &basePath)
 Builds an action which saves the switch times and states of tls into a file.

Member Typedef Documentation

typedef std::map<std::string, ActionType> NLDiscreteEventBuilder::KnownActions [protected]

Definitions of a storage for build actions.

Definition at line 85 of file NLDiscreteEventBuilder.h.


Member Enumeration Documentation

Known action types.

Enumerator:
EV_SAVETLSTATE  "SaveTLSStates"
EV_SAVETLSWITCHES  "SaveTLSSwitchTimes"
EV_SAVETLSWITCHSTATES  "SaveTLSSwitchStates"

Definition at line 55 of file NLDiscreteEventBuilder.h.

00055                     {
00057         EV_SAVETLSTATE,
00059         EV_SAVETLSWITCHES,
00061         EV_SAVETLSWITCHSTATES
00062     };


Constructor & Destructor Documentation

NLDiscreteEventBuilder::NLDiscreteEventBuilder ( MSNet net  ) 

Constructor.

Definition at line 51 of file NLDiscreteEventBuilder.cpp.

References EV_SAVETLSTATE, EV_SAVETLSWITCHES, EV_SAVETLSWITCHSTATES, and myActions.

00052         : myNet(net) {
00053     myActions["SaveTLSStates"] = EV_SAVETLSTATE;
00054     myActions["SaveTLSSwitchTimes"] = EV_SAVETLSWITCHES;
00055     myActions["SaveTLSSwitchStates"] = EV_SAVETLSWITCHSTATES;
00056 }

NLDiscreteEventBuilder::~NLDiscreteEventBuilder (  ) 

Destructor.

Definition at line 59 of file NLDiscreteEventBuilder.cpp.

00059 {}


Member Function Documentation

void NLDiscreteEventBuilder::addAction ( const SUMOSAXAttributes attrs,
const std::string &  basePath 
)

Builds an action and saves it for further use.

Definition at line 63 of file NLDiscreteEventBuilder.cpp.

References buildSaveTLStateCommand(), buildSaveTLSwitchesCommand(), buildSaveTLSwitchStatesCommand(), EV_SAVETLSTATE, EV_SAVETLSWITCHES, EV_SAVETLSWITCHSTATES, SUMOSAXAttributes::getOptStringReporting(), myActions, and SUMO_ATTR_TYPE.

Referenced by NLHandler::myStartElement().

00064                                                              {
00065     bool ok = true;
00066     const std::string type = attrs.getOptStringReporting(SUMO_ATTR_TYPE, "action", 0, ok, "");
00067     // check whether the type was given
00068     if (type==""||!ok) {
00069         throw InvalidArgument("An action's type is not given.");
00070     }
00071     // get the numerical representation
00072     KnownActions::iterator i = myActions.find(type);
00073     if (i==myActions.end()) {
00074         throw InvalidArgument("The action type '" + type + "' is not known.");
00075     }
00076     // build the action
00077     switch ((*i).second) {
00078     case EV_SAVETLSTATE:
00079         buildSaveTLStateCommand(attrs, basePath);
00080         break;
00081     case EV_SAVETLSWITCHES:
00082         buildSaveTLSwitchesCommand(attrs, basePath);
00083         break;
00084     case EV_SAVETLSWITCHSTATES:
00085         buildSaveTLSwitchStatesCommand(attrs, basePath);
00086         break;
00087     }
00088 }

void NLDiscreteEventBuilder::buildSaveTLStateCommand ( const SUMOSAXAttributes attrs,
const std::string &  basePath 
) [private]

Builds an action which saves the state of a certain tls into a file.

Definition at line 92 of file NLDiscreteEventBuilder.cpp.

References MSTLLogicControl::get(), MSTLLogicControl::getAllTLIds(), OutputDevice::getDevice(), SUMOSAXAttributes::getOptStringReporting(), MSNet::getTLSControl(), MSTLLogicControl::knows(), myNet, SUMO_ATTR_DEST, and SUMO_ATTR_SOURCE.

Referenced by addAction().

00093                                    {
00094     bool ok = true;
00095     const std::string dest = attrs.getOptStringReporting(SUMO_ATTR_DEST, "action", 0, ok, "");
00096     const std::string source = attrs.getOptStringReporting(SUMO_ATTR_SOURCE, "action", 0, ok, "");
00097     // check the parameter
00098     if (dest==""||!ok) {
00099         throw InvalidArgument("Incomplete description of an 'SaveTLSState'-action occured.");
00100     }
00101     if (source == "") {
00102         const std::vector<std::string> ids = myNet.getTLSControl().getAllTLIds();
00103         for (std::vector<std::string>::const_iterator tls = ids.begin(); tls != ids.end(); ++tls) {
00104             const MSTLLogicControl::TLSLogicVariants &logics = myNet.getTLSControl().get(*tls);
00105             new Command_SaveTLSState(logics, OutputDevice::getDevice(dest, basePath));
00106         }
00107     } else {
00108         // get the logic
00109         if (!myNet.getTLSControl().knows(source)) {
00110             throw InvalidArgument("The traffic light logic to save (" + source +  ") is not known.");
00111         }
00112         const MSTLLogicControl::TLSLogicVariants &logics = myNet.getTLSControl().get(source);
00113         // build the action
00114         new Command_SaveTLSState(logics, OutputDevice::getDevice(dest, basePath));
00115     }
00116 }

void NLDiscreteEventBuilder::buildSaveTLSwitchesCommand ( const SUMOSAXAttributes attrs,
const std::string &  basePath 
) [private]

Builds an action which saves the switch times of links into a file.

Definition at line 120 of file NLDiscreteEventBuilder.cpp.

References MSTLLogicControl::get(), MSTLLogicControl::getAllTLIds(), OutputDevice::getDevice(), SUMOSAXAttributes::getOptStringReporting(), MSNet::getTLSControl(), MSTLLogicControl::knows(), myNet, SUMO_ATTR_DEST, and SUMO_ATTR_SOURCE.

Referenced by addAction().

00121                                    {
00122     bool ok = true;
00123     const std::string dest = attrs.getOptStringReporting(SUMO_ATTR_DEST, "action", 0, ok, "");
00124     const std::string source = attrs.getOptStringReporting(SUMO_ATTR_SOURCE, "action", 0, ok, "");
00125     // check the parameter
00126     if (dest==""||!ok) {
00127         throw InvalidArgument("Incomplete description of an 'SaveTLSSwitchTimes'-action occured.");
00128     }
00129     if (source == "") {
00130         const std::vector<std::string> ids = myNet.getTLSControl().getAllTLIds();
00131         for (std::vector<std::string>::const_iterator tls = ids.begin(); tls != ids.end(); ++tls) {
00132             const MSTLLogicControl::TLSLogicVariants &logics = myNet.getTLSControl().get(*tls);
00133             new Command_SaveTLSSwitches(logics, OutputDevice::getDevice(dest, basePath));
00134         }
00135     } else {
00136         // get the logic
00137         if (!myNet.getTLSControl().knows(source)) {
00138             throw InvalidArgument("The traffic light logic to save (" + source +  ") is not known.");
00139         }
00140         const MSTLLogicControl::TLSLogicVariants &logics = myNet.getTLSControl().get(source);
00141         // build the action
00142         new Command_SaveTLSSwitches(logics, OutputDevice::getDevice(dest, basePath));
00143     }
00144 }

void NLDiscreteEventBuilder::buildSaveTLSwitchStatesCommand ( const SUMOSAXAttributes attrs,
const std::string &  basePath 
) [private]

Builds an action which saves the switch times and states of tls into a file.

Definition at line 148 of file NLDiscreteEventBuilder.cpp.

References MSTLLogicControl::get(), MSTLLogicControl::getAllTLIds(), OutputDevice::getDevice(), SUMOSAXAttributes::getOptStringReporting(), MSNet::getTLSControl(), MSTLLogicControl::knows(), myNet, SUMO_ATTR_DEST, and SUMO_ATTR_SOURCE.

Referenced by addAction().

00149                                    {
00150     bool ok = true;
00151     const std::string dest = attrs.getOptStringReporting(SUMO_ATTR_DEST, "action", 0, ok, "");
00152     const std::string source = attrs.getOptStringReporting(SUMO_ATTR_SOURCE, "action", 0, ok, "");
00153     // check the parameter
00154     if (dest==""||!ok) {
00155         throw InvalidArgument("Incomplete description of an 'SaveTLSSwitchStates'-action occured.");
00156     }
00157     if (source == "") {
00158         const std::vector<std::string> ids = myNet.getTLSControl().getAllTLIds();
00159         for (std::vector<std::string>::const_iterator tls = ids.begin(); tls != ids.end(); ++tls) {
00160             const MSTLLogicControl::TLSLogicVariants &logics = myNet.getTLSControl().get(*tls);
00161             new Command_SaveTLSSwitchStates(logics, OutputDevice::getDevice(dest, basePath));
00162         }
00163     } else {
00164         // get the logic
00165         if (!myNet.getTLSControl().knows(source)) {
00166             throw InvalidArgument("The traffic light logic to save (" + source +  ") is not known.");
00167         }
00168         const MSTLLogicControl::TLSLogicVariants &logics = myNet.getTLSControl().get(source);
00169         // build the action
00170         new Command_SaveTLSSwitchStates(logics, OutputDevice::getDevice(dest, basePath));
00171     }
00172 }


Field Documentation

Build actions that shall be executed during the simulation.

Definition at line 88 of file NLDiscreteEventBuilder.h.

Referenced by addAction(), and NLDiscreteEventBuilder().


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:06:56 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6