NBDistrictCont Class Reference

#include <NBDistrictCont.h>


Detailed Description

A container for districts.

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.

See also:
NBDistrict

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.
NBDistrictretrieve (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)
NBDistrictContoperator= (const NBDistrictCont &s)

Private Attributes

DistrictCont myDistricts
 The instance of the dictionary.

Member Typedef Documentation

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.


Constructor & Destructor Documentation

NBDistrictCont::NBDistrictCont (  )  throw ()

Constructor.

Definition at line 46 of file NBDistrictCont.cpp.

00046 {}

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


Member Function Documentation

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.

See also:
NBDistrict::addSink
Parameters:
[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
Returns:
Whether the source could be added (the district exists and the suorce was not added to it before)

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.

See also:
NBDistrict::addSource
Parameters:
[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
Returns:
Whether the source could be added (the district exists and the suorce was not added to it before)

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.

Parameters:
[in] district The district to add
Returns:
false if the districts already was in the dictionary

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.

See also:
NBDistrict::removeFromSinksAndSources
Parameters:
[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.

See also:
NBDistrict::reshiftPosition
Parameters:
[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.

Parameters:
[in] id The id of the district to retrieve
Returns:
The district with the given id if there was one having it, 0 otherwise

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.

See also:
NBDistrict::writeXML
Parameters:
[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 }


Field Documentation

The instance of the dictionary.

Definition at line 159 of file NBDistrictCont.h.

Referenced by insert(), removeFromSinksAndSources(), reshiftDistrictPositions(), retrieve(), size(), writeXML(), and ~NBDistrictCont().


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

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