#include <NBDistrictCont.h>
A simple storage for district instances. Allows addition an retrieval of districts, filling them with sources/sinks, and some other methods which operate at all stored districts.
Definition at line 58 of file NBDistrictCont.h.
Public Member Functions | |
| bool | addSink (const std::string &dist, NBEdge *const destination, SUMOReal weight) throw () |
| Adds a sink to the named district. | |
| bool | addSource (const std::string &dist, NBEdge *const source, SUMOReal weight) throw () |
| Adds a source to the named district. | |
| bool | insert (NBDistrict *const district) throw () |
| Adds a district to the dictionary. | |
| NBDistrictCont () throw () | |
| Constructor. | |
| void | removeFromSinksAndSources (NBEdge *const e) throw () |
| Removes the given edge from the lists of sources and sinks in all stored districts. | |
| void | reshiftDistrictPositions (SUMOReal xoff, SUMOReal yoff) throw () |
| Applies an offset to all districts. | |
| NBDistrict * | retrieve (const std::string &id) const throw () |
| Returns the districts with the given id. | |
| size_t | size () const throw () |
| Returns the number of districts inside the container. | |
| void | writeXML (OutputDevice &into) const throw () |
| Writes the sumo-xml-representation of all districts into the given stream. | |
| ~NBDistrictCont () throw () | |
| Destructor. | |
Private Types | |
| typedef std::map< std::string, NBDistrict * > | DistrictCont |
| The type of the dictionary where a node may be found by her id. | |
Private Member Functions | |
| NBDistrictCont (const NBDistrictCont &s) | |
| NBDistrictCont & | operator= (const NBDistrictCont &s) |
Private Attributes | |
| DistrictCont | myDistricts |
| The instance of the dictionary. | |
typedef std::map<std::string, NBDistrict*> NBDistrictCont::DistrictCont [private] |
The type of the dictionary where a node may be found by her id.
Definition at line 156 of file NBDistrictCont.h.
| NBDistrictCont::NBDistrictCont | ( | ) | throw () |
| NBDistrictCont::~NBDistrictCont | ( | ) | throw () |
Destructor.
Definition at line 49 of file NBDistrictCont.cpp.
References myDistricts.
00049 { 00050 for (DistrictCont::iterator i=myDistricts.begin(); i!=myDistricts.end(); i++) { 00051 delete((*i).second); 00052 } 00053 myDistricts.clear(); 00054 }
| NBDistrictCont::NBDistrictCont | ( | const NBDistrictCont & | s | ) | [private] |
invalid copy constructor
| bool NBDistrictCont::addSink | ( | const std::string & | dist, | |
| NBEdge *const | destination, | |||
| SUMOReal | weight | |||
| ) | throw () |
Adds a sink to the named district.
At first, the district is tried to be retrieved. If this fails, false is returned. Otherwise the retrieved districts NBDistrict::addSink-method is called.
| [in] | dist | The id of the district to add the sink to |
| [in] | source | An edge that shall be used as sink |
| [in] | weight | An optional weight of the source |
Definition at line 101 of file NBDistrictCont.cpp.
References retrieve().
Referenced by NIImporter_VISUM::parse_Connectors().
00102 { 00103 NBDistrict *o = retrieve(dist); 00104 if (o==0) { 00105 return false; 00106 } 00107 return o->addSink(destination, weight); 00108 }
| bool NBDistrictCont::addSource | ( | const std::string & | dist, | |
| NBEdge *const | source, | |||
| SUMOReal | weight | |||
| ) | throw () |
Adds a source to the named district.
At first, the district is tried to be retrieved. If this fails, false is returned. Otherwise the retrieved districts NBDistrict::addSource-method is called.
| [in] | dist | The id of the district to add the source to |
| [in] | source | An edge that shall be used as source |
| [in] | weight | An optional weight of the source |
Definition at line 90 of file NBDistrictCont.cpp.
References retrieve().
Referenced by NIImporter_VISUM::parse_Connectors().
00091 { 00092 NBDistrict *o = retrieve(dist); 00093 if (o==0) { 00094 return false; 00095 } 00096 return o->addSource(source, weight); 00097 }
| bool NBDistrictCont::insert | ( | NBDistrict *const | district | ) | throw () |
Adds a district to the dictionary.
| [in] | district | The district to add |
Definition at line 58 of file NBDistrictCont.cpp.
References myDistricts.
Referenced by NIVissimDistrictConnection::dict_BuildDistrictNodes(), and NIImporter_VISUM::parse_Districts().
00058 { 00059 DistrictCont::const_iterator i = myDistricts.find(district->getID()); 00060 if (i!=myDistricts.end()) return false; 00061 myDistricts.insert(DistrictCont::value_type(district->getID(), district)); 00062 return true; 00063 }
| NBDistrictCont& NBDistrictCont::operator= | ( | const NBDistrictCont & | s | ) | [private] |
invalid assignment operator
| void NBDistrictCont::removeFromSinksAndSources | ( | NBEdge *const | e | ) | throw () |
Removes the given edge from the lists of sources and sinks in all stored districts.
This method simply goes through all stored districts and calls their method NBDistrict::removeFromSinksAndSources.
| [in] | e | The edge to remove from sinks/sources |
Definition at line 112 of file NBDistrictCont.cpp.
References myDistricts.
00112 { 00113 for (DistrictCont::iterator i=myDistricts.begin(); i!=myDistricts.end(); i++) { 00114 (*i).second->removeFromSinksAndSources(e); 00115 } 00116 }
| void NBDistrictCont::reshiftDistrictPositions | ( | SUMOReal | xoff, | |
| SUMOReal | yoff | |||
| ) | throw () |
Applies an offset to all districts.
This method simply goes through all stored districts and calls their method NBDistrict::reshiftPosition.
| [in] | xoff | The x-offset to apply |
| [in] | yoff | The y-offset to apply |
Definition at line 120 of file NBDistrictCont.cpp.
References myDistricts.
Referenced by NBNetBuilder::compute().
00120 { 00121 for (DistrictCont::iterator i=myDistricts.begin(); i!=myDistricts.end(); i++) { 00122 (*i).second->reshiftPosition(xoff, yoff); 00123 } 00124 }
| NBDistrict * NBDistrictCont::retrieve | ( | const std::string & | id | ) | const throw () |
Returns the districts with the given id.
| [in] | id | The id of the district to retrieve |
Definition at line 67 of file NBDistrictCont.cpp.
References myDistricts.
Referenced by addSink(), addSource(), NIImporter_VISUM::buildDistrictNode(), and NIVissimDistrictConnection::dict_BuildDistricts().
00067 { 00068 DistrictCont::const_iterator i = myDistricts.find(id); 00069 if (i==myDistricts.end()) return 0; 00070 return (*i).second; 00071 }
| size_t NBDistrictCont::size | ( | ) | const throw () |
Returns the number of districts inside the container.
Definition at line 84 of file NBDistrictCont.cpp.
References myDistricts.
Referenced by NILoader::load().
00084 { 00085 return myDistricts.size(); 00086 }
| void NBDistrictCont::writeXML | ( | OutputDevice & | into | ) | const throw () |
Writes the sumo-xml-representation of all districts into the given stream.
This method simply goes through all stored districts and calls their method NBDistrict::writeXML.
| [in] | into | The stream to write the xml-representations into |
Definition at line 75 of file NBDistrictCont.cpp.
References myDistricts.
Referenced by NBNetBuilder::save().
00075 { 00076 for (DistrictCont::const_iterator i=myDistricts.begin(); i!=myDistricts.end(); i++) { 00077 (*i).second->writeXML(into); 00078 } 00079 into << "\n"; 00080 }
DistrictCont NBDistrictCont::myDistricts [private] |
The instance of the dictionary.
Definition at line 159 of file NBDistrictCont.h.
Referenced by insert(), removeFromSinksAndSources(), reshiftDistrictPositions(), retrieve(), size(), writeXML(), and ~NBDistrictCont().
1.5.6