ShapeContainer Class Reference

#include <ShapeContainer.h>

Inheritance diagram for ShapeContainer:

GUIShapeContainer

Detailed Description

Storage for geometrical objects, sorted by the layers they are in.

Definition at line 45 of file ShapeContainer.h.


Public Member Functions

virtual bool add (int layer, PointOfInterest *p) throw ()
 Adds a PoI to the container.
virtual bool add (int layer, Polygon2D *p) throw ()
 Adds a polygon to the container.
int getMaxLayer () const throw ()
 Returns the highest layer.
int getMinLayer () const throw ()
 Returns the lowest layer.
const NamedObjectCont
< PointOfInterest * > & 
getPOICont (int layer) const throw ()
 Returns the polygons located at the given layer.
const NamedObjectCont
< Polygon2D * > & 
getPolygonCont (int layer) const throw ()
 Returns the polygons located at the given layer.
virtual bool removePOI (int layer, const std::string &id) throw ()
 Removes a PoI from the container.
virtual bool removePolygon (int layer, const std::string &id) throw ()
 Removes a polygon from the container.
 ShapeContainer () throw ()
 Constructor.
virtual ~ShapeContainer () throw ()
 Destructor.

Private Attributes

int myMaxLayer
int myMinLayer
 The minimum and the maximum layers.
std::map< int, NamedObjectCont
< PointOfInterest * > > 
myPOILayers
 POI layers.
std::map< int, NamedObjectCont
< Polygon2D * > > 
myPolygonLayers
 Polygon layers.

Constructor & Destructor Documentation

ShapeContainer::ShapeContainer (  )  throw ()

Constructor.

Definition at line 56 of file ShapeContainer.cpp.

00057         : myMinLayer(100), myMaxLayer(-100) {}

ShapeContainer::~ShapeContainer (  )  throw () [virtual]

Destructor.

Definition at line 60 of file ShapeContainer.cpp.

00060 {}


Member Function Documentation

bool ShapeContainer::add ( int  layer,
PointOfInterest p 
) throw () [virtual]

Adds a PoI to the container.

Parameters:
[in] layer The layer the poi is located in
[in] p The PoI to add
Returns:
Whether the PoI could be added (no other with same name existed before)

Reimplemented in GUIShapeContainer.

Definition at line 75 of file ShapeContainer.cpp.

References MAX2(), MIN2(), myMaxLayer, myMinLayer, and myPOILayers.

00075                                                          {
00076     if (myPOILayers.find(layer)==myPOILayers.end()) {
00077         myPOILayers[layer] = NamedObjectCont<PointOfInterest*>();
00078         myMinLayer = MIN2(layer, myMinLayer);
00079         myMaxLayer = MAX2(layer, myMaxLayer);
00080     }
00081     return myPOILayers[layer].add(p->getID(), p);
00082 }

bool ShapeContainer::add ( int  layer,
Polygon2D p 
) throw () [virtual]

Adds a polygon to the container.

Parameters:
[in] layer The layer the polygon is located in
[in] p The polygon to add
Returns:
Whether the polygon could be added (no other with same name existed before)

Reimplemented in GUIShapeContainer.

Definition at line 64 of file ShapeContainer.cpp.

References MAX2(), MIN2(), myMaxLayer, myMinLayer, and myPolygonLayers.

Referenced by GUIShapeContainer::add(), NLGeomShapeBuilder::addPoint(), GUIGeomShapeBuilder::addPoint(), NLGeomShapeBuilder::polygonEnd(), GUIGeomShapeBuilder::polygonEnd(), TraCIServerAPI_Polygon::processSet(), and TraCIServerAPI_POI::processSet().

00064                                                    {
00065     if (myPolygonLayers.find(layer)==myPolygonLayers.end()) {
00066         myPolygonLayers[layer] = NamedObjectCont<Polygon2D*>();
00067         myMinLayer = MIN2(layer, myMinLayer);
00068         myMaxLayer = MAX2(layer, myMaxLayer);
00069     }
00070     return myPolygonLayers[layer].add(p->getID(), p);
00071 }

int ShapeContainer::getMaxLayer (  )  const throw () [inline]

int ShapeContainer::getMinLayer (  )  const throw () [inline]

const NamedObjectCont< PointOfInterest * > & ShapeContainer::getPOICont ( int  layer  )  const throw ()

Returns the polygons located at the given layer.

Parameters:
[in] layer The layer of polygons to return
Returns:
The polygons at this layer
See also:
NamedObjectCont

Definition at line 115 of file ShapeContainer.cpp.

References MAX2(), MIN2(), myMaxLayer, myMinLayer, and myPOILayers.

Referenced by traci::TraCIServer::getPoiByExtId(), GUINet::getShapeIDs(), traci::TraCIServer::handlePoiDomain(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_POI::processSet(), and traci::TraCIServer::TraCIServer().

00115                                                   {
00116     if (myPOILayers.find(layer)==myPOILayers.end()) {
00117         myPOILayers[layer] = NamedObjectCont<PointOfInterest*>();
00118         myMinLayer = MIN2(layer, myMinLayer);
00119         myMaxLayer = MAX2(layer, myMaxLayer);
00120     }
00121     return myPOILayers[layer];
00122 }

const NamedObjectCont< Polygon2D * > & ShapeContainer::getPolygonCont ( int  layer  )  const throw ()

Returns the polygons located at the given layer.

Parameters:
[in] layer The layer of polygons to return
Returns:
The polygons at this layer
See also:
NamedObjectCont

Definition at line 104 of file ShapeContainer.cpp.

References MAX2(), MIN2(), myMaxLayer, myMinLayer, and myPolygonLayers.

Referenced by traci::TraCIServer::getPolygonByExtId(), GUINet::getShapeIDs(), traci::TraCIServer::handlePolygonDomain(), TraCIServerAPI_Polygon::processGet(), TraCIServerAPI_Polygon::processSet(), and traci::TraCIServer::TraCIServer().

00104                                                       {
00105     if (myPolygonLayers.find(layer)==myPolygonLayers.end()) {
00106         myPolygonLayers[layer] = NamedObjectCont<Polygon2D*>();
00107         myMinLayer = MIN2(layer, myMinLayer);
00108         myMaxLayer = MAX2(layer, myMaxLayer);
00109     }
00110     return myPolygonLayers[layer];
00111 }

bool ShapeContainer::removePOI ( int  layer,
const std::string &  id 
) throw () [virtual]

Removes a PoI from the container.

Parameters:
[in] layer The layer the PoI is located in
[in] id The id of the PoI
Returns:
Whether the poi could be removed

Reimplemented in GUIShapeContainer.

Definition at line 95 of file ShapeContainer.cpp.

References myPOILayers.

Referenced by TraCIServerAPI_POI::processSet(), and GUIShapeContainer::removePOI().

00095                                                                 {
00096     if (myPOILayers.find(layer)==myPOILayers.end()) {
00097         return false;
00098     }
00099     return myPOILayers.find(layer)->second.remove(id);
00100 }

bool ShapeContainer::removePolygon ( int  layer,
const std::string &  id 
) throw () [virtual]

Removes a polygon from the container.

Parameters:
[in] layer The layer the polygon is located in
[in] id The id of the polygon
Returns:
Whether the polygon could be removed

Reimplemented in GUIShapeContainer.

Definition at line 86 of file ShapeContainer.cpp.

References myPolygonLayers.

Referenced by TraCIServerAPI_Polygon::processSet(), and GUIShapeContainer::removePolygon().

00086                                                                     {
00087     if (myPolygonLayers.find(layer)==myPolygonLayers.end()) {
00088         return false;
00089     }
00090     return myPolygonLayers.find(layer)->second.remove(id);
00091 }


Field Documentation

int ShapeContainer::myMaxLayer [mutable, private]

Definition at line 127 of file ShapeContainer.h.

Referenced by add(), getMaxLayer(), getPOICont(), and getPolygonCont().

int ShapeContainer::myMinLayer [mutable, private]

The minimum and the maximum layers.

Definition at line 127 of file ShapeContainer.h.

Referenced by add(), getMinLayer(), getPOICont(), and getPolygonCont().

std::map<int, NamedObjectCont<PointOfInterest*> > ShapeContainer::myPOILayers [mutable, private]

POI layers.

Definition at line 124 of file ShapeContainer.h.

Referenced by add(), getPOICont(), and removePOI().

std::map<int, NamedObjectCont<Polygon2D*> > ShapeContainer::myPolygonLayers [mutable, private]

Polygon layers.

Definition at line 121 of file ShapeContainer.h.

Referenced by add(), getPolygonCont(), and removePolygon().


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

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