SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OptionsCont Class Reference

A storage for options typed value containers) More...

#include <OptionsCont.h>

Data Structures

class  abbreviation_finder
 A class to find abbreviated option names (length=1) More...
 

Public Member Functions

void clear ()
 Removes all information from the container. More...
 
const std::string & getFullName () const
 
const std::vector< std::string > & getSubTopics () const
 return the list of subtopics More...
 
std::vector< std::string > getSubTopicsEntries (const std::string &subtopic) const
 return the list of entries for the given subtopic More...
 
std::string getTypeName (const std::string name)
 return the type name for the given option More...
 
 OptionsCont ()
 Constructor. More...
 
bool processMetaOptions (bool missingOptions)
 Checks for help and configuration output, returns whether we should exit. More...
 
void resetWritable ()
 Resets all options to be writeable. More...
 
 ~OptionsCont ()
 Destructor. More...
 
Methods setting and getting information about the appplication and currently set options
void setApplicationName (const std::string &appName, const std::string &fullName)
 Sets the application name. More...
 
void setApplicationDescription (const std::string &appDesc)
 Sets the application description. More...
 
void addCallExample (const std::string &example, const std::string &desc)
 Add a call example. More...
 
void setAdditionalHelpMessage (const std::string &add)
 Sets an additional message to be printed at the begin of the help screen. More...
 
void addCopyrightNotice (const std::string &copyrightLine)
 Adds a copyright notice to the help output. More...
 
void clearCopyrightNotices ()
 Removes all copyright information. More...
 
void addOptionSubTopic (const std::string &topic)
 Adds an option subtopic. More...
 
void printHelp (std::ostream &os)
 Prints the help. More...
 
void writeConfiguration (std::ostream &os, bool filled, bool complete, bool addComments) const
 Writes the configuration. More...
 
void writeSchema (std::ostream &os, bool addComments)
 Writes the xml schema for the configuration. More...
 
void writeXMLHeader (std::ostream &os)
 Writes a standard XML header, including the configuration. More...
 
Methods for registering options
void doRegister (const std::string &name, Option *v)
 Adds an option under the given name. More...
 
void doRegister (const std::string &name, char abbr, Option *v)
 Adds an option under the given name and the given abbreviation. More...
 
void addSynonyme (const std::string &name1, const std::string &name2, bool isDeprecated=false)
 Adds a synonyme for an options name (any order) More...
 
void addDescription (const std::string &name, const std::string &subtopic, const std::string &description)
 Adds a description for an option. More...
 
Methods for retrieving information about options
bool exists (const std::string &name) const
 Returns the information whether the named option is known. More...
 
bool isSet (const std::string &name, bool failOnNonExistant=true) const
 Returns the information whether the named option is set. More...
 
void unSet (const std::string &name, bool failOnNonExistant=true) const
 Marks the option as unset. More...
 
bool isDefault (const std::string &name) const
 Returns the information whether the named option has still the default value. More...
 
bool isBool (const std::string &name) const
 Returns the information whether the option is a boolean option. More...
 
bool isUsableFileList (const std::string &name) const
 Checks whether the named option is usable as a file list (with at least a single file) More...
 
bool checkDependingSuboptions (const std::string &name, const std::string &prefix) const
 Checks whether an option is set, which has options with a prefix depending on it. More...
 
void relocateFiles (const std::string &configuration) const
 Modifies file name options according to the configuration path. More...
 
std::vector< std::string > getSynonymes (const std::string &name) const
 Returns the synonymes of an option name. More...
 
bool isWriteable (const std::string &name)
 Returns the information whether the named option may be set. More...
 
Methods for retrieving values from options
std::string getString (const std::string &name) const
 Returns the string-value of the named option (only for Option_String) More...
 
SUMOReal getFloat (const std::string &name) const
 Returns the SUMOReal-value of the named option (only for Option_Float) More...
 
int getInt (const std::string &name) const
 Returns the int-value of the named option (only for Option_Integer) More...
 
bool getBool (const std::string &name) const
 Returns the boolean-value of the named option (only for Option_Bool) More...
 
const IntVectorgetIntVector (const std::string &name) const
 Returns the list of integer-value of the named option (only for Option_IntVector) More...
 
std::vector< std::string > getStringVector (const std::string &name) const
 Returns the list of string-vector-value of the named option (only for Option_String) More...
 
bool isInStringVector (const std::string &optionName, const std::string &itemName)
 Returns the named option is a list of string values containing the specified item. More...
 
Methods for setting values into options
bool set (const std::string &name, const std::string &value)
 Sets the given value for the named option. More...
 

Static Public Member Functions

static OptionsContgetOptions ()
 Retrieves the options. More...
 

Private Types

typedef std::vector< Option * > ItemAddressContType
 
typedef std::map< std::string,
Option * > 
KnownContType
 

Private Member Functions

std::string convertChar (char abbr) const
 Converts an abbreviation into a name. More...
 
OptiongetSecure (const std::string &name) const
 Returns the named option. More...
 
OptionsContoperator= (const OptionsCont &s)
 
 OptionsCont (const OptionsCont &s)
 
void reportDoubleSetting (const std::string &arg) const
 Reports an error that the option has already been set. More...
 
void splitLines (std::ostream &os, std::string what, size_t offset, size_t nextOffset)
 Writes the given string 'formatted'. More...
 

Private Attributes

std::string myAdditionalMessage
 
ItemAddressContType myAddresses
 
std::string myAppDescription
 
std::string myAppName
 some information on the application More...
 
std::vector< std::pair
< std::string, std::string > > 
myCallExamples
 list of call examples More...
 
std::vector< std::string > myCopyrightNotices
 
std::map< std::string, boolmyDeprecatedSynonymes
 A map from deprecated options to a bool indicating whether we warned about deprecation. More...
 
std::string myFullName
 
bool myHaveInformedAboutDeprecatedDivider
 Information whether a warning a deprecated divider. More...
 
std::map< std::string,
std::vector< std::string > > 
mySubTopicEntries
 A map from subtopic to option. More...
 
std::vector< std::string > mySubTopics
 lists of option subtopics and copyright notices More...
 
KnownContType myValues
 

Static Private Attributes

static OptionsCont myOptions
 The static options container used. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const OptionsCont &oc)
 Output operator. More...
 

Detailed Description

A storage for options typed value containers)

This container stores options (typed value containers) by their names. In the case of command line tools, this container is the main interface between a user's definitions about what to do (command line options, configuration files) and the application.

At the begin, the application should initialise the container. Because the OptionsCont is also responsible for printing the help screen, one should name and describe the application, first. This means that the first usage of this container should look similar to this:

// give some application descriptions
oc.setApplicationDescription(<ONE_LINE_DESCRIPTION>);
oc.setApplicationName(<APPLICATION_NAME>, "SUMO <APPLICATION_NAME> Version " + (string)VERSION_STRING);
See Also
setApplicationDescription
setApplicationName

Then, you may also add some example calls using addCallExample.

See Also
addCallExample

In the next step, option subtopics are registered. This is needed for the help screen and for writing the templates/saving configurations. A subtopic is added using addOptionSubTopic(<SUBTOPIC_NAME>).

See Also
addOptionSubTopic

After this, you may add options to the container. This is done using doRegister. This method requires a long name for the option and the value container. The value container must be an instance of one of the classes derived from "Option". Do not use Option itself! This is a base class which is meant to supply a default behaviour, but this default behaviour throws exceptions only!

See Also
Option
doRegister
addSynonyme

Once stored inside this container, options will not be visible to the world and are deleted by the container. Only values and stati of the options may be returned. While accessing the options, the programmer must assure that he asks for the right value (only Option_Bool is able to return a boolean value, other option types will throw exceptions). Further, options added to the container must not be deleted outside this container (the container becomes the owner).

For being printed in the help screen, a description together with the subtopic the option belongs to must be given to OptionsCont. This is done using addDescription(<OPTION_NAME>, <SUBTOPIC>, <DESCRIPTION>).

See Also
addDescription
http://sumo.sourceforge.net/wiki/index.php/OptionsSubSystem

Definition at line 108 of file OptionsCont.h.

Member Typedef Documentation

typedef std::vector<Option*> OptionsCont::ItemAddressContType
private

definition of the type that stores the addresses of used options

Definition at line 677 of file OptionsCont.h.

typedef std::map<std::string, Option*> OptionsCont::KnownContType
private

definition of the type that realises the access to options

Definition at line 680 of file OptionsCont.h.

Constructor & Destructor Documentation

OptionsCont::OptionsCont ( )

Constructor.

Definition at line 72 of file OptionsCont.cpp.

References myCopyrightNotices.

OptionsCont::~OptionsCont ( )

Destructor.

Definition at line 78 of file OptionsCont.cpp.

References clear().

OptionsCont::OptionsCont ( const OptionsCont s)
private

invalid copy constructor

Member Function Documentation

void OptionsCont::addCallExample ( const std::string &  example,
const std::string &  desc 
)

Add a call example.

Parameters
[in]exampleA call example (without the app name)
[in]descA verbose description

Definition at line 467 of file OptionsCont.cpp.

References myCallExamples.

Referenced by RODFFrame::fillOptions(), AGFrame::fillOptions(), ROJTRFrame::fillOptions(), RODUAFrame::fillOptions(), fillOptions(), and MSFrame::fillOptions().

void OptionsCont::addCopyrightNotice ( const std::string &  copyrightLine)

Adds a copyright notice to the help output.

Parameters
[in]copyrightLineThe line to put out as a copyright notice

Definition at line 479 of file OptionsCont.cpp.

References myCopyrightNotices.

Referenced by AGFrame::fillOptions().

void OptionsCont::addDescription ( const std::string &  name,
const std::string &  subtopic,
const std::string &  description 
)

Adds a description for an option.

Tries to retrieve the named option and to set the given description. Adds the name to the list of option names to be located in the named subtopic.

Throws an InvalidArgument if the option is not known or already has a description set.

Parameters
[in]nameThe option's name
[in]subtopicThe subtopic to locate the description within
[in]descriptionThe description
Exceptions
InvalidArgumentIf none of the synonymes or both synonymes with different options were registered before

Definition at line 441 of file OptionsCont.cpp.

References getSecure(), mySubTopicEntries, mySubTopics, and Option::setDescription().

Referenced by SystemFrame::addConfigurationOptions(), RODUAFrame::addDUAOptions(), RODUAFrame::addImportOptions(), GeoConvHelper::addProjectionOptions(), SystemFrame::addReportOptions(), NGFrame::fillOptions(), RODFFrame::fillOptions(), AGFrame::fillOptions(), NIFrame::fillOptions(), ROJTRFrame::fillOptions(), NWFrame::fillOptions(), ROFrame::fillOptions(), NBFrame::fillOptions(), MSFrame::fillOptions(), fillOptions(), MSDevice_HBEFA::insertOptions(), MSDevice_Routing::insertOptions(), and RandHelper::insertRandOptions().

void OptionsCont::addOptionSubTopic ( const std::string &  topic)

Adds an option subtopic.

Sub-topics are used to join several options into one thematic field. They are used on writing the help screen and the configuration. They have no further meaning besides making the outputs better readable.

Parameters
[in]topicThe options sub topic

Definition at line 491 of file OptionsCont.cpp.

References mySubTopicEntries, and mySubTopics.

Referenced by SystemFrame::addConfigurationOptions(), GeoConvHelper::addProjectionOptions(), SystemFrame::addReportOptions(), RODFFrame::fillOptions(), AGFrame::fillOptions(), ROJTRFrame::fillOptions(), RODUAFrame::fillOptions(), MSFrame::fillOptions(), fillOptions(), MSDevice_HBEFA::insertOptions(), MSDevice_Routing::insertOptions(), and RandHelper::insertRandOptions().

void OptionsCont::addSynonyme ( const std::string &  name1,
const std::string &  name2,
bool  isDeprecated = false 
)

Adds a synonyme for an options name (any order)

Tries to find one of the synonymes. If both are known and the option differs for both, an InvalidArgument exception is thrown. If none is known, also.

If one of the synonymes is known and the other not, the option from the known one is made accessible by the other.

In the case both synonymes are known and have the same option assigned, nothing is done.

Parameters
[in]name1The first synonyme
[in]name2The second synonyme
[in]isDeprecatedwhether the synonyme is considered deprecated
Exceptions
InvalidArgumentIf none of the synonymes or both synonymes with different options were registered before

Definition at line 105 of file OptionsCont.cpp.

References doRegister(), myDeprecatedSynonymes, and myValues.

Referenced by SystemFrame::addConfigurationOptions(), RODUAFrame::addDUAOptions(), RODUAFrame::addImportOptions(), GeoConvHelper::addProjectionOptions(), SystemFrame::addReportOptions(), NGFrame::fillOptions(), RODFFrame::fillOptions(), AGFrame::fillOptions(), NIFrame::fillOptions(), ROJTRFrame::fillOptions(), NWFrame::fillOptions(), ROFrame::fillOptions(), NBFrame::fillOptions(), MSFrame::fillOptions(), fillOptions(), MSDevice_HBEFA::insertOptions(), MSDevice_Routing::insertOptions(), and RandHelper::insertRandOptions().

bool OptionsCont::checkDependingSuboptions ( const std::string &  name,
const std::string &  prefix 
) const

Checks whether an option is set, which has options with a prefix depending on it.

The method returns true, if the named option is set or no option dependoing on it is set. Throws an InvalidArgument exception if the option is not known.

Parameters
[in]nameThe name of the option to check
[in]prefixThe prefix of depending options
Returns
Whether the dependencies are fulfilled
Exceptions
InvalidArgumentIf the option does not exist

Definition at line 357 of file OptionsCont.cpp.

References getSecure(), getSynonymes(), Option::isSet(), myValues, and WRITE_ERROR.

Referenced by NIFrame::checkOptions().

void OptionsCont::clear ( )

Removes all information from the container.

Definition at line 428 of file OptionsCont.cpp.

References myAddresses, mySubTopicEntries, mySubTopics, and myValues.

Referenced by SystemFrame::close(), GUILoadThread::initOptions(), and ~OptionsCont().

void OptionsCont::clearCopyrightNotices ( )

Removes all copyright information.

Definition at line 485 of file OptionsCont.cpp.

References myCopyrightNotices.

std::string OptionsCont::convertChar ( char  abbr) const
private

Converts an abbreviation into a name.

Build and returns the string which consists of the given character only.

Parameters
[in]abbrThe abbreviation to convert into a string
Returns
The abbreviation converted into a string

Definition at line 396 of file OptionsCont.cpp.

Referenced by doRegister().

void OptionsCont::doRegister ( const std::string &  name,
char  abbr,
Option v 
)

Adds an option under the given name and the given abbreviation.

Adds the option under both names using void doRegister(const std::string &name, Option *v);

Parameters
[in]nameThe (long) name of the option
[in]abbrThe (short) name of the option
[in]vThe option (typed value storage)
Exceptions
InvalidArgumentIf one of the names is already used

Definition at line 98 of file OptionsCont.cpp.

References convertChar(), and doRegister().

bool OptionsCont::exists ( const std::string &  name) const
bool OptionsCont::getBool ( const std::string &  name) const

Returns the boolean-value of the named option (only for Option_Bool)

This method returns the boolean-value of an existing boolean-option. If the named option does not exist or is not a boolean-option, an InvalidArgument is thrown.

Parameters
[in]nameThe name of the option to return the boolean-value of
Returns
The boolean-value of the named, existing boolean-option
Exceptions
InvalidArgumentIf the option does not exist or is not a boolean-option

Definition at line 226 of file OptionsCont.cpp.

References Option::getBool(), and getSecure().

Referenced by NIXMLEdgesHandler::addEdge(), NIXMLNodesHandler::addNode(), NBEdgeCont::applyOptions(), buildNetwork(), MSDevice_HBEFA::buildVehicleDevices(), MSDevice_Routing::buildVehicleDevices(), NGFrame::checkOptions(), NIFrame::checkOptions(), NWFrame::checkOptions(), MSFrame::checkOptions(), NBNetBuilder::compute(), NBNode::computeLogic(), NBRampsComputer::computeRamps(), RONet::computeRoute(), computeRoutes(), SUMOVehicleParameter::defaultOptionOverrides(), ROCostCalculator::getCalculator(), NBNodeCont::guessTLs(), MSDevice_Vehroutes::init(), GeoConvHelper::init(), initNet(), MsgHandler::initOutputOptions(), RandHelper::initRandGlobal(), NBEdgeCont::insert(), NILoader::load(), PCLoaderVisum::load(), PCLoaderArcView::load(), NIImporter_ArcView::load(), PCLoaderOSM::loadIfSet(), loadJTRDefinitions(), NIImporter_ArcView::loadNetwork(), NIImporter_DlrNavteq::loadNetwork(), NIImporter_MATSim::loadNetwork(), NIImporter_OpenDrive::loadNetwork(), NIImporter_VISUM::loadNetwork(), PCLoaderDlrNavteq::loadPOIFile(), PCLoaderDlrNavteq::loadPolyFile(), main(), MSNet::MSNet(), PCLoaderXML::myStartElement(), ROLoader::openRoutes(), ROLoader::openTypedRoutes(), NIImporter_VISUM::parse_EdgePolys(), NIImporter_VISUM::parse_Turns(), RORouteHandler::parseFromTo(), NIXMLConnectionsHandler::parseLaneBound(), PCTypeMap::PCTypeMap(), NIImporter_Vissim::postLoadBuild(), processMetaOptions(), ROLoader::processRoutes(), readDetectors(), RORouteDef::repairCurrentRoute(), ROCostCalculator::ROCostCalculator(), RODFNet::RODFNet(), GUILoadThread::run(), RONet::saveAndRemoveRoutesUntil(), MSFrame::setMSGlobals(), startComputation(), MSFCDExport::write(), NWWriter_XML::writeEdgesAndConnections(), NWWriter_SUMO::writeNetwork(), and NWWriter_XML::writeNodes().

SUMOReal OptionsCont::getFloat ( const std::string &  name) const
const std::string& OptionsCont::getFullName ( ) const
inline

Definition at line 622 of file OptionsCont.h.

References myFullName.

Referenced by NWWriter_DlrNavteq::writeHeader().

int OptionsCont::getInt ( const std::string &  name) const

Returns the int-value of the named option (only for Option_Integer)

This method returns the int-value of an existing int-option. If the named option does not exist or is not a int-option, an InvalidArgument is thrown.

Parameters
[in]nameThe name of the option to return the int-value of
Returns
The int-value of the named, existing int-option
Exceptions
InvalidArgumentIf the option does not exist or is not a int-option

Definition at line 219 of file OptionsCont.cpp.

References Option::getInt(), and getSecure().

Referenced by NBNetBuilder::applyOptions(), buildNetwork(), ROFrame::checkOptions(), MSFrame::checkOptions(), NBTrafficLightDefinition::compute(), GeoConvHelper::init(), RandHelper::initRandGlobal(), PCLoaderVisum::load(), PCLoaderArcView::load(), PCLoaderDlrNavteq::loadPOIFile(), PCLoaderDlrNavteq::loadPolyFile(), main(), MSNet::MSNet(), MSVehicleControl::MSVehicleControl(), PCTypeDefHandler::myStartElement(), PCLoaderXML::myStartElement(), PCTypeMap::PCTypeMap(), ROCostCalculator::ROCostCalculator(), RONet::saveAndRemoveRoutesUntil(), MSFrame::setMSGlobals(), MSNet::simulationState(), and startComputation().

const IntVector & OptionsCont::getIntVector ( const std::string &  name) const

Returns the list of integer-value of the named option (only for Option_IntVector)

This method returns the int-vector-value of an existing int-vector-option. If the named option does not exist or is not a int-vector-option, an InvalidArgument is thrown.

Parameters
[in]nameThe name of the option to return the int-vector-value of
Returns
The int-vector-value of the named, existing int-vector-option
Exceptions
InvalidArgumentIf the option does not exist or is not a int-vector-option

Definition at line 233 of file OptionsCont.cpp.

References Option::getIntVector(), and getSecure().

Referenced by NLBuilder::buildNet().

OptionsCont & OptionsCont::getOptions ( )
static

Retrieves the options.

Definition at line 67 of file OptionsCont.cpp.

References myOptions.

Referenced by MSDetectorControl::add(), MSDetectorControl::addDetectorAndInterval(), RODUAFrame::addDUAOptions(), NLHandler::addEdgeLaneMeanData(), ROLoader::EdgeFloatTimeLineRetriever_EdgeWeight::addEdgeWeight(), ROLoader::EdgeFloatTimeLineRetriever_EdgeTravelTime::addEdgeWeight(), RODUAFrame::addImportOptions(), NIXMLEdgesHandler::addLane(), PCLoaderOSM::addPOI(), PCLoaderOSM::addPolygon(), NIXMLEdgesHandler::addSplit(), NBNodeCont::analyzeCluster(), NLBuilder::build(), NLEdgeControlBuilder::build(), NIVisumTL::build(), NIVissimEdge::buildNBEdge(), NGNode::buildNBNode(), buildNetwork(), NLTriggerBuilder::buildVaporizer(), MSDevice_Tripinfo::buildVehicleDevices(), MSDevice_Vehroutes::buildVehicleDevices(), MSDevice_HBEFA::buildVehicleDevices(), MSDevice_Routing::buildVehicleDevices(), OptionsParser::check(), NGFrame::checkOptions(), NIFrame::checkOptions(), ROJTRFrame::checkOptions(), NWFrame::checkOptions(), RODUAFrame::checkOptions(), NBFrame::checkOptions(), MSFrame::checkOptions(), checkOptions(), SystemFrame::close(), MSRouteHandler::closeFlow(), RORouteHandler::closeFlow(), MSNet::closeSimulation(), MSRouteHandler::closeVehicle(), RORouteHandler::closeVehicle(), computeRoutes(), RODFNet::computeRoutesFor(), NIImporter_OpenDrive::computeShapes(), OutputDevice::createDeviceByOption(), MSPersonControl::erase(), NGFrame::fillOptions(), RODFFrame::fillOptions(), AGFrame::fillOptions(), NIFrame::fillOptions(), ROJTRFrame::fillOptions(), RODUAFrame::fillOptions(), NWFrame::fillOptions(), NBFrame::fillOptions(), MSFrame::fillOptions(), fillOptions(), ROCostCalculator::getCalculator(), OutputDevice::getDeviceByOption(), OptionsIO::getOptions(), GUINet::getParameterWindow(), NIVissimDistrictConnection::getRealSpeed(), MSDevice_Routing::getRouter(), MSNet::getRouterTT(), NBNodeCont::guessTLs(), GUIDialog_Breakpoints::GUIDialog_Breakpoints(), MSDevice_Vehroutes::init(), MSEdge::initialize(), GUILoadThread::initOptions(), MsgHandler::initOutputOptions(), RandHelper::initRandGlobal(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), NBEdgeCont::insert(), NIImporter_OpenStreetMap::insertNodeChecking(), MSDevice_HBEFA::insertOptions(), MSDevice_Routing::insertOptions(), RandHelper::insertRandOptions(), NLBuilder::load(), NIImporter_OpenStreetMap::load(), OptionsIO::loadConfiguration(), PCLoaderOSM::loadIfSet(), loadNet(), PCLoaderDlrNavteq::loadPOIFile(), main(), GUIRunThread::makeStep(), MSNet::MSNet(), MSPhaseDefinition::MSPhaseDefinition(), MSVehicleControl::MSVehicleControl(), NBOwnTLDef::myCompute(), NBLoadedTLDef::myCompute(), SUMORouteHandler::myEndElement(), PCLoaderXML::myStartElement(), traci::TraCIServer::openSocket(), NIImporter_VISUM::parse_Connectors(), NIImporter_VISUM::parse_EdgePolys(), NIImporter_VISUM::parse_Edges(), NIImporter_VISUM::parse_Turns(), RORouteHandler::parseFromTo(), NIXMLConnectionsHandler::parseLaneBound(), NIImporter_Vissim::postLoadBuild(), traci::TraCIServer::processCommandsUntilSimStep(), NIXMLNodesHandler::processTrafficLightDefinitions(), NBNodeCont::removeIsolatedRoads(), RORouteDef::repairCurrentRoute(), NIImporter_DlrNavteq::TrafficlightsHandler::report(), ROCostCalculator::ROCostCalculator(), RODFNet::RODFNet(), GUILoadThread::run(), ROVehicle::saveAllAsXML(), MSVehicleControl::scheduleVehicleRemoval(), NLHandler::setLocation(), MSNet::simulate(), MSNet::simulationState(), NGNet::toNB(), NILoader::transformCoordinates(), traci::TraCIServer::vehicleStateChanged(), MSFCDExport::write(), ODMatrix::writeDefaultAttrs(), PlainXMLFormatter::writeHeader(), NWWriter_SUMO::writeJunction(), NBRequest::writeLaneResponse(), MSNet::writeOutput(), and PlainXMLFormatter::writeXMLHeader().

Option * OptionsCont::getSecure ( const std::string &  name) const
private

Returns the named option.

If the named option does not exist, an InvalidArgument is thrown.

Parameters
[in]nameThe name of the option to return
Returns
The named option

Definition at line 177 of file OptionsCont.cpp.

References myDeprecatedSynonymes, mySubTopicEntries, myValues, and WRITE_WARNING.

Referenced by addDescription(), checkDependingSuboptions(), getBool(), getFloat(), getInt(), getIntVector(), getString(), getStringVector(), getSynonymes(), getTypeName(), isBool(), isUsableFileList(), isWriteable(), printHelp(), set(), writeConfiguration(), and writeSchema().

std::string OptionsCont::getString ( const std::string &  name) const

Returns the string-value of the named option (only for Option_String)

This method returns the string-value of an existing string-option. If the named option does not exist or is not a string-option, an InvalidArgument is thrown.

Parameters
[in]nameThe name of the option to return the string-value of
Returns
The string-value of the named, existing string-option
Exceptions
InvalidArgumentIf the option does not exist or is not a string-option

Definition at line 205 of file OptionsCont.cpp.

References getSecure(), and Option::getString().

Referenced by NBNetBuilder::applyOptions(), NLBuilder::build(), NGNode::buildNBNode(), NLBuilder::buildNet(), NLBuilder::buildRouteLoaderControl(), MSDevice_Routing::buildVehicleDevices(), NGFrame::checkOptions(), NIFrame::checkOptions(), ROJTRFrame::checkOptions(), RODUAFrame::checkOptions(), NBFrame::checkOptions(), MSFrame::checkOptions(), checkOptions(), NBNetBuilder::compute(), computeRoutes(), OutputDevice::getDeviceByOption(), MSDevice_Routing::getRouter(), MSNet::getRouterTT(), GeoConvHelper::init(), initNet(), MsgHandler::initOutputOptions(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), PCLoaderVisum::load(), NIImporter_Vissim::load(), PCLoaderArcView::load(), NIImporter_ArcView::load(), OptionsIO::loadConfiguration(), ODMatrix::loadMatrix(), loadNet(), ROLoader::loadNet(), NIImporter_ArcView::loadNetwork(), NIImporter_Vissim::loadNetwork(), NIImporter_DlrNavteq::loadNetwork(), NIImporter_VISUM::loadNetwork(), PCLoaderDlrNavteq::loadPOIFile(), PCLoaderDlrNavteq::loadPolyFile(), main(), MSNet::MSNet(), PCTypeDefHandler::myStartElement(), PCLoaderXML::myStartElement(), ROLoader::openRoutes(), PCTypeMap::PCTypeMap(), processMetaOptions(), NIXMLNodesHandler::processTrafficLightDefinitions(), readDetectorFlows(), GUILoadThread::run(), MSFrame::setMSGlobals(), startComputation(), SUMOVehicleParameter::write(), ODMatrix::writeDefaultAttrs(), NWWriter_XML::writeEdgesAndConnections(), NWWriter_XML::writeJoinedJunctions(), NWWriter_DlrNavteq::writeLinksUnsplitted(), NWWriter_OpenDrive::writeNetwork(), NWFrame::writeNetwork(), NWWriter_MATSim::writeNetwork(), NWWriter_SUMO::writeNetwork(), NWWriter_XML::writeNodes(), NWWriter_DlrNavteq::writeNodesUnsplitted(), MSNet::writeOutput(), NWWriter_XML::writeStreetSigns(), and NWWriter_XML::writeTrafficLights().

std::vector< std::string > OptionsCont::getStringVector ( const std::string &  name) const

Returns the list of string-vector-value of the named option (only for Option_String)

This method returns the string-vector-value of an existing string-option. If the named option does not exist or is not a string-option, an InvalidArgument is thrown.

The string-value is determined, first. If the legacy-divider ';' is found within the string, a warning is generated. The retrieved string is splitted at ',' and ';'.

Parameters
[in]nameThe name of the option to return the string-vector-value of
Returns
The string-vector-value of the named, existing string-option
Exceptions
InvalidArgumentIf the option does not exist or is not a string-option
Todo:
Is it possible to retrieve a const-reference of the string?
See Also
getString()

Definition at line 844 of file OptionsCont.cpp.

References getSecure(), Option::getString(), StringTokenizer::getVector(), myHaveInformedAboutDeprecatedDivider, StringUtils::prune(), and WRITE_WARNING.

Referenced by NIImporter_SUMO::_loadNetwork(), NBTrafficLightLogicCont::applyOptions(), NBEdgeCont::applyOptions(), NLBuilder::build(), NLBuilder::buildRouteLoaderControl(), MSDevice_Routing::buildVehicleDevices(), NBNetBuilder::compute(), NBRampsComputer::computeRamps(), getTurningDefaults(), NBNodeCont::guessTLs(), isInStringVector(), isUsableFileList(), NILoader::load(), NLBuilder::load(), NIImporter_OpenStreetMap::load(), PCLoaderVisum::loadIfSet(), PCLoaderOSM::loadIfSet(), PCLoaderXML::loadIfSet(), PCLoaderArcView::loadIfSet(), loadJTRDefinitions(), ODMatrix::loadMatrix(), NIImporter_RobocupRescue::loadNetwork(), NIImporter_ITSUMO::loadNetwork(), NIImporter_MATSim::loadNetwork(), NIImporter_OpenDrive::loadNetwork(), PCLoaderDlrNavteq::loadPOIFiles(), PCLoaderDlrNavteq::loadPolyFiles(), ROLoader::loadWeights(), NILoader::loadXML(), main(), ROLoader::openTypedRoutes(), readDetectorFlows(), readDetectors(), RODFNet::RODFNet(), and GUILoadThread::run().

const std::vector<std::string>& OptionsCont::getSubTopics ( ) const
inline

return the list of subtopics

Definition at line 601 of file OptionsCont.h.

References mySubTopics.

std::vector<std::string> OptionsCont::getSubTopicsEntries ( const std::string &  subtopic) const
inline

return the list of entries for the given subtopic

Definition at line 607 of file OptionsCont.h.

References mySubTopicEntries.

std::vector< std::string > OptionsCont::getSynonymes ( const std::string &  name) const

Returns the synonymes of an option name.

The named option is extracted, first. An InvalidArgument is thrown if it does not exist. Otherwise, other names for the named option are searched and returned (the original name is not in the list).

Parameters
[in]nameThe name of the option to return synonymes of
Returns
List of existing synonymes
Exceptions
InvalidArgumentIf the named option does not exist

Definition at line 259 of file OptionsCont.cpp.

References getSecure(), and myValues.

Referenced by checkDependingSuboptions(), operator<<(), printHelp(), reportDoubleSetting(), and writeConfiguration().

std::string OptionsCont::getTypeName ( const std::string  name)
inline

return the type name for the given option

Definition at line 617 of file OptionsCont.h.

References getSecure(), and Option::getTypeName().

bool OptionsCont::isBool ( const std::string &  name) const

Returns the information whether the option is a boolean option.

The option is retrieved from the container, first, what may cause an InvalidArgument exception if it is not known. Otherwise, this option's isBool-method is called.

Parameters
[in]nameThe name of the option to check
Returns
Whether the existing named option is a bool option
Exceptions
InvalidArgumentIf the option does not exist

Definition at line 406 of file OptionsCont.cpp.

References getSecure(), and Option::isBool().

Referenced by OptionsParser::check().

bool OptionsCont::isDefault ( const std::string &  name) const

Returns the information whether the named option has still the default value.

The named option is tried to be retrieved from the container. If it does not exist, an InvalidArgument is thrown. If it could be retrieved, the information whether the option still has the default value is returned.

An option "is default" if no value has been set from the command line / the configuration file.

Returns
true if the option still has the default value
Exceptions
InvalidArgumentIf the named option is not known

Definition at line 167 of file OptionsCont.cpp.

References myValues.

Referenced by NIImporter_SUMO::_loadNetwork(), NLBuilder::build(), buildNetwork(), NIFrame::checkOptions(), NBFrame::checkOptions(), MSFrame::checkOptions(), NBNetBuilder::compute(), and main().

bool OptionsCont::isInStringVector ( const std::string &  optionName,
const std::string &  itemName 
)

Returns the named option is a list of string values containing the specified item.

If the named option is not set, false is returned. Otherwise, the string-vector of this option is retrieved using getStringVector what may throw an InvalidArgument exception if the named option is not a string option or not existing at all.

The given itemName is searched in the obtained string-vector and the method returns whether it is stored in the list or not.

Parameters
[in]optionNameThe name of the option to evaluate entries of
[in]itemNameThe item to be searched for in the entries of the named option
Returns
Whether the named item is set in the named string-option
Exceptions
InvalidArgumentIf the option does not exist or is not a string-option
See Also
getStringVector()
Todo:
Try to optimize - at each call, the vector is rebuilt

Definition at line 861 of file OptionsCont.cpp.

References getStringVector(), and isSet().

Referenced by NIXMLEdgesHandler::addSplit(), MSDevice_HBEFA::buildVehicleDevices(), NBNode::computeLogic(), PCLoaderOSM::loadIfSet(), and PCLoaderXML::myStartElement().

bool OptionsCont::isSet ( const std::string &  name,
bool  failOnNonExistant = true 
) const

Returns the information whether the named option is set.

The named option is tried to be retrieved from the container. If it does not exist, an InvalidArgument is thrown. If it could be retrieved, the information whether the option has a value stored is returned.

An option "is set" if a default value was supplied or a value has been set from the command line / the configuration file.

Parameters
[in]nameThe name of the option to check
[in]failOnNonExistantWhether asking for an unregistered option should trigger an exception
Returns
true if the option has a valid value, false otherwise
Exceptions
InvalidArgumentIf the named option is not known

Definition at line 139 of file OptionsCont.cpp.

References myValues.

Referenced by NBTrafficLightLogicCont::applyOptions(), NBEdgeCont::applyOptions(), NBNetBuilder::applyOptions(), NLBuilder::build(), NGNode::buildNBNode(), NLBuilder::buildNet(), NLBuilder::buildRouteLoaderControl(), MSDevice_Vehroutes::buildVehicleDevices(), MSDevice_HBEFA::buildVehicleDevices(), MSDevice_Routing::buildVehicleDevices(), NGFrame::checkOptions(), NIFrame::checkOptions(), ROJTRFrame::checkOptions(), NWFrame::checkOptions(), RODUAFrame::checkOptions(), NBFrame::checkOptions(), ROFrame::checkOptions(), MSFrame::checkOptions(), checkOptions(), NBNetBuilder::compute(), NBTrafficLightDefinition::compute(), NBRampsComputer::computeRamps(), computeRoutes(), NIImporter_OpenDrive::computeShapes(), SUMOVehicleParameter::defaultOptionOverrides(), NBNodeCont::guessTLs(), initNet(), MsgHandler::initOutputOptions(), isInStringVector(), PCLoaderArcView::load(), NIImporter_ArcView::load(), NIImporter_OpenStreetMap::load(), OptionsIO::loadConfiguration(), PCLoaderVisum::loadIfSet(), PCLoaderOSM::loadIfSet(), PCLoaderXML::loadIfSet(), PCLoaderArcView::loadIfSet(), PCLoaderDlrNavteq::loadIfSet(), loadJTRDefinitions(), ROLoader::loadNet(), NIImporter_RobocupRescue::loadNetwork(), NIImporter_ArcView::loadNetwork(), NIImporter_Vissim::loadNetwork(), NIImporter_DlrNavteq::loadNetwork(), NIImporter_ITSUMO::loadNetwork(), NIImporter_MATSim::loadNetwork(), NIImporter_OpenDrive::loadNetwork(), NIImporter_VISUM::loadNetwork(), main(), MSVehicleControl::MSVehicleControl(), ROLoader::openTypedRoutes(), NIImporter_VISUM::parse_Turns(), processMetaOptions(), readDetectorFlows(), readDetectors(), MSFrame::setMSGlobals(), startComputation(), SUMOVehicleParameter::write(), ODMatrix::writeDefaultAttrs(), NWWriter_OpenDrive::writeNetwork(), NWFrame::writeNetwork(), NWWriter_DlrNavteq::writeNetwork(), NWWriter_MATSim::writeNetwork(), NWWriter_XML::writeNetwork(), and NWWriter_SUMO::writeNetwork().

bool OptionsCont::isUsableFileList ( const std::string &  name) const

Checks whether the named option is usable as a file list (with at least a single file)

The method returns true, if the named option is set with entries containing names of accessable files.

Throw an InvalidArgument exception if the option is not known. If the option is not set, false is returned. Also, if the list is empty (conatins delimiters only) or if one of the named files (obtained using getStringVector) does not exist, false is returned. Additionally, an error is sent to MsgHandler in both cases.

In the case two delimiters were placed in the option value directly after each other, a warning is generated.

Parameters
[in]nameThe name of the option to check
Returns
Whether the option contains names of files which can be accessed (for reading)
Exceptions
InvalidArgumentIf the option does not exist or is not a string-option

Definition at line 328 of file OptionsCont.cpp.

References FileHelpers::exists(), getSecure(), getStringVector(), Option::isSet(), WRITE_ERROR, and WRITE_WARNING.

Referenced by NIImporter_SUMO::_loadNetwork(), NLBuilder::build(), MSFrame::checkOptions(), NIImporter_OpenDrive::loadNetwork(), ROLoader::loadWeights(), and ROLoader::openTypedRoutes().

bool OptionsCont::isWriteable ( const std::string &  name)

Returns the information whether the named option may be set.

An option is writable after initialisation, but as soon as it gets set, it is no longer writeable. This method returns whether the named option is writeable. If the named option is not known, an InvalidArgument is thrown.

Parameters
[in]nameThe name of the option to check
Returns
Whether the value can be set
Exceptions
InvalidArgumentIf the option does not exist

Definition at line 421 of file OptionsCont.cpp.

References getSecure(), and Option::isWriteable().

Referenced by NIFrame::checkOptions(), and OptionsLoader::setSecure().

OptionsCont& OptionsCont::operator= ( const OptionsCont s)
private

invalid assignment operator

void OptionsCont::printHelp ( std::ostream &  os)

Prints the help.

Parameters
[in]osThe stream to write the help into

Definition at line 631 of file OptionsCont.cpp.

References Option::getDescription(), getSecure(), getSynonymes(), Option::getTypeName(), Option::isBool(), myAdditionalMessage, myAppDescription, myAppName, myCallExamples, mySubTopicEntries, mySubTopics, and splitLines().

Referenced by processMetaOptions().

bool OptionsCont::processMetaOptions ( bool  missingOptions)

Checks for help and configuration output, returns whether we should exit.

Returns false if no error was detected and the application may be executed (at least from this point of view). If missingOptions is true, the user is informed that they should be supplied (returns true). Otherwise it is checked whether help shall be printed what is done if so, returning true. Also, it is checked whether the set options shall be printed and the configuration template or the current configuration shall be written.

This method throws a ProcessError if the configuration should be saved, but the file is not accessable. An error message is supplied.

Parameters
[in]missingOptionsWhether no options have been given
Returns
Whether the application shall stop
Exceptions
ProcessErrorIf the configuration file could not be saved

Definition at line 529 of file OptionsCont.cpp.

References exists(), getBool(), getString(), isSet(), myCopyrightNotices, myFullName, printHelp(), WRITE_MESSAGE, writeConfiguration(), and writeSchema().

Referenced by main().

void OptionsCont::relocateFiles ( const std::string &  configuration) const

Modifies file name options according to the configuration path.

If the configuration path given is a relative one all filenames inside are adapted such that they refer to the correct location.

Parameters
[in]configurationThe path to the configuration file

Definition at line 306 of file OptionsCont.cpp.

References FileHelpers::getConfigurationRelative(), FileHelpers::isAbsolute(), myAddresses, and StringTokenizer::next().

Referenced by OptionsIO::loadConfiguration().

void OptionsCont::reportDoubleSetting ( const std::string &  arg) const
private

Reports an error that the option has already been set.

Using the given option name, an error string is generated and reported to MsgHandler-error instance.

Parameters
[in]nameThe name of the option that was already set

Definition at line 380 of file OptionsCont.cpp.

References getSynonymes(), and WRITE_ERROR.

Referenced by set().

void OptionsCont::resetWritable ( )

Resets all options to be writeable.

An option is writable after initialisation, but as soon as it gets set, it is no longer writeable. This method resets the writable-flag of all known options.

Definition at line 413 of file OptionsCont.cpp.

References myAddresses.

Referenced by OptionsIO::getOptions(), and main().

bool OptionsCont::set ( const std::string &  name,
const std::string &  value 
)

Sets the given value for the named option.

The option is retrieved from the container, first, what yields in a InvalidArgument exception for not known options.

If the option is not writable (was set before), an error is generated using reportDoubleSetting, and false is returned. Otherwise, the option is told to set the given value using Option::set. Possible problems herein are caught and reported to the error-handler, yielding in returning false.

If the new value could be set, true is returned.

Parameters
[in]nameThe name of the option to set
[in]valueThe value to set
Returns
Whether the value could be set
Exceptions
InvalidArgumentIf the option does not exist
See Also
reportDoubleSetting
Option::set(const std::string &)

Definition at line 240 of file OptionsCont.cpp.

References getSecure(), Option::isWriteable(), reportDoubleSetting(), Option::set(), and WRITE_ERROR.

Referenced by NIImporter_SUMO::_loadNetwork(), NBNetBuilder::applyOptions(), NLBuilder::build(), OptionsParser::check(), NIFrame::checkOptions(), NWFrame::checkOptions(), NBFrame::checkOptions(), MSFrame::checkOptions(), GUILoadThread::initOptions(), main(), OptionsParser::processNonBooleanSingleSwitch(), and OptionsLoader::setSecure().

void OptionsCont::setAdditionalHelpMessage ( const std::string &  add)

Sets an additional message to be printed at the begin of the help screen.

Parameters
[in]exampleSome additional information about how to use the application

Definition at line 473 of file OptionsCont.cpp.

References myAdditionalMessage.

Referenced by fillOptions().

void OptionsCont::setApplicationDescription ( const std::string &  appDesc)

Sets the application description.

Parameters
[in]appDescA description of the application

Definition at line 461 of file OptionsCont.cpp.

References myAppDescription.

Referenced by AGFrame::fillOptions(), and main().

void OptionsCont::setApplicationName ( const std::string &  appName,
const std::string &  fullName 
)

Sets the application name.

Parameters
[in]nameThe name of the excutable
[in]vThe name of the executable with version information

Definition at line 453 of file OptionsCont.cpp.

References myAppName, and myFullName.

Referenced by AGFrame::fillOptions(), and main().

void OptionsCont::splitLines ( std::ostream &  os,
std::string  what,
size_t  offset,
size_t  nextOffset 
)
private

Writes the given string 'formatted'.

The given string is split so that no word-wrapping occurs at line ends. The text is wrapped at ';' or ' '.

Parameters
[in]osThe stream to write the text into
[in]whatThe text to write
[in]offset?
[in]nextOffset?
Todo:
Describe parameter

Definition at line 498 of file OptionsCont.cpp.

Referenced by printHelp().

void OptionsCont::unSet ( const std::string &  name,
bool  failOnNonExistant = true 
) const

Marks the option as unset.

Parameters
[in]nameThe name of the option to check
[in]failOnNonExistantWhether asking for an unregistered option should trigger an exception

Definition at line 153 of file OptionsCont.cpp.

References myValues.

Referenced by NIImporter_OpenDrive::loadNetwork().

void OptionsCont::writeConfiguration ( std::ostream &  os,
bool  filled,
bool  complete,
bool  addComments 
) const

Writes the configuration.

The configuration is written as XML into the given stream, allowing to reload it on a next run.

Parameters
[in]osThe stream to write the configuration into
[in]filledWhether only set (and not default) options shall be written
[in]completeWhether all options shall be written
[in]addCommentsWhether comments (option descriptions) shall be written

Definition at line 722 of file OptionsCont.cpp.

References SUMOSAXAttributes::ENCODING, StringUtils::escapeXML(), Option::getDescription(), getSecure(), getSynonymes(), Option::getTypeName(), Option::getValueString(), Option::isDefault(), Option::isSet(), myAppName, mySubTopicEntries, and mySubTopics.

Referenced by processMetaOptions(), NWWriter_DlrNavteq::writeHeader(), and writeXMLHeader().

void OptionsCont::writeSchema ( std::ostream &  os,
bool  addComments 
)

Writes the xml schema for the configuration.

The schema for the configuration is written as XML into the given stream, allowing to validate the configuration against.

Parameters
[in]osThe stream to write the schema into
[in]addCommentsWhether comments (option descriptions) shall be written

Definition at line 785 of file OptionsCont.cpp.

References SUMOSAXAttributes::ENCODING, getSecure(), Option::getTypeName(), mySubTopicEntries, and mySubTopics.

Referenced by processMetaOptions().

void OptionsCont::writeXMLHeader ( std::ostream &  os)

Writes a standard XML header, including the configuration.

The header consists of the xml-declaration with encoding as defined by SUMOSAXAttributes::ENCODING, followed by a note which contains the current date and time and the application configuration (set values).

Parameters
[in]osThe stream to write the header into

Definition at line 830 of file OptionsCont.cpp.

References SUMOSAXAttributes::ENCODING, myFullName, and writeConfiguration().

Referenced by PlainXMLFormatter::writeHeader(), and PlainXMLFormatter::writeXMLHeader().

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const OptionsCont oc 
)
friend

Output operator.

Generates the output used when current option values shall be printed.

Parameters
[in]osThe stream to write into
[in]ocThe options to print
Returns
The stream to write into

Definition at line 272 of file OptionsCont.cpp.

Field Documentation

std::string OptionsCont::myAdditionalMessage
private

Definition at line 689 of file OptionsCont.h.

Referenced by printHelp(), and setAdditionalHelpMessage().

ItemAddressContType OptionsCont::myAddresses
private

storage for option-addresses

Definition at line 683 of file OptionsCont.h.

Referenced by clear(), doRegister(), relocateFiles(), and resetWritable().

std::string OptionsCont::myAppDescription
private

Definition at line 689 of file OptionsCont.h.

Referenced by printHelp(), and setApplicationDescription().

std::string OptionsCont::myAppName
private

some information on the application

Definition at line 689 of file OptionsCont.h.

Referenced by printHelp(), setApplicationName(), and writeConfiguration().

std::vector< std::pair<std::string, std::string> > OptionsCont::myCallExamples
private

list of call examples

Definition at line 692 of file OptionsCont.h.

Referenced by addCallExample(), and printHelp().

std::vector<std::string> OptionsCont::myCopyrightNotices
private
std::map<std::string, bool> OptionsCont::myDeprecatedSynonymes
mutableprivate

A map from deprecated options to a bool indicating whether we warned about deprecation.

Definition at line 701 of file OptionsCont.h.

Referenced by addSynonyme(), and getSecure().

std::string OptionsCont::myFullName
private

Definition at line 689 of file OptionsCont.h.

Referenced by getFullName(), processMetaOptions(), setApplicationName(), and writeXMLHeader().

bool OptionsCont::myHaveInformedAboutDeprecatedDivider
mutableprivate

Information whether a warning a deprecated divider.

Definition at line 704 of file OptionsCont.h.

Referenced by getStringVector().

OptionsCont OptionsCont::myOptions
staticprivate

The static options container used.

Definition at line 674 of file OptionsCont.h.

Referenced by getOptions().

std::map<std::string, std::vector<std::string> > OptionsCont::mySubTopicEntries
private

A map from subtopic to option.

Definition at line 698 of file OptionsCont.h.

Referenced by addDescription(), addOptionSubTopic(), clear(), getSecure(), getSubTopicsEntries(), printHelp(), writeConfiguration(), and writeSchema().

std::vector<std::string> OptionsCont::mySubTopics
private

lists of option subtopics and copyright notices

Definition at line 695 of file OptionsCont.h.

Referenced by addDescription(), addOptionSubTopic(), clear(), getSubTopics(), printHelp(), writeConfiguration(), and writeSchema().

KnownContType OptionsCont::myValues
private

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