GUISelectedStorage::SingleTypeSelections Class Reference

#include <GUISelectedStorage.h>


Detailed Description

A container for ids of selected objects of a certain type.

Definition at line 247 of file GUISelectedStorage.h.


Public Member Functions

void clear () throw ()
 Clears the list of selected objects.
void deselect (GLuint id) throw ()
 Deselects the object with the given id from the list of selected objects.
const std::vector< GLuint > & getSelected () const throw ()
 Returns the list of selected ids.
bool isSelected (GLuint id) throw ()
 Returns the information whether the object with the given id is qithin the selection.
void load (const std::string &filename) throw (IOError)
 Loads the list of selected objects to a file named as given.
void save (const std::string &filename) throw (IOError)
 Saves the list of selected objects to a file named as given.
void select (GLuint id) throw ()
 Adds the object with the given id to the list of selected objects.
 SingleTypeSelections () throw ()
 Constructor.
 ~SingleTypeSelections () throw ()
 Destructor.

Private Attributes

std::vector< GLuint > mySelected
 The list of selected ids.

Constructor & Destructor Documentation

GUISelectedStorage::SingleTypeSelections::SingleTypeSelections (  )  throw ()

Constructor.

Definition at line 50 of file GUISelectedStorage.cpp.

00050 {}

GUISelectedStorage::SingleTypeSelections::~SingleTypeSelections (  )  throw ()

Destructor.

Definition at line 53 of file GUISelectedStorage.cpp.

00053 {}


Member Function Documentation

void GUISelectedStorage::SingleTypeSelections::clear (  )  throw ()

Clears the list of selected objects.

Definition at line 82 of file GUISelectedStorage.cpp.

References mySelected.

Referenced by GUISelectedStorage::clear().

00082                                                       {
00083     mySelected.clear();
00084 }

void GUISelectedStorage::SingleTypeSelections::deselect ( GLuint  id  )  throw ()

Deselects the object with the given id from the list of selected objects.

Parameters:
[in] id The id of the object

Definition at line 73 of file GUISelectedStorage.cpp.

References mySelected.

Referenced by GUISelectedStorage::deselect().

00073                                                                   {
00074     std::vector<GLuint>::iterator i = find(mySelected.begin(), mySelected.end(), id);
00075     if (i!=mySelected.end()) {
00076         mySelected.erase(i);
00077     }
00078 }

const std::vector< GLuint > & GUISelectedStorage::SingleTypeSelections::getSelected (  )  const throw ()

Returns the list of selected ids.

Returns:
A list containing the ids of all selected objects

Definition at line 113 of file GUISelectedStorage.cpp.

References mySelected.

Referenced by GUISelectedStorage::getSelected().

00113                                                                   {
00114     return mySelected;
00115 }

bool GUISelectedStorage::SingleTypeSelections::isSelected ( GLuint  id  )  throw ()

Returns the information whether the object with the given id is qithin the selection.

Parameters:
[in] id The id of the object
Returns:
Whether the object is selected

Definition at line 57 of file GUISelectedStorage.cpp.

References mySelected.

Referenced by GUISelectedStorage::isSelected().

00057                                                                     {
00058     std::vector<GLuint>::iterator i = find(mySelected.begin(), mySelected.end(), id);
00059     return i!=mySelected.end();
00060 }

void GUISelectedStorage::SingleTypeSelections::load ( const std::string &  filename  )  throw (IOError)

Loads the list of selected objects to a file named as given.

Parameters:
[in] filename The name of the file to read the list from
Exceptions:
IOError recheck!!!
Todo:
Recheck: is this used(?)
Todo:
Recheck usage of IOError

Definition at line 88 of file GUISelectedStorage.cpp.

Referenced by GUISelectedStorage::load().

00088                                                                                      {
00089     std::ifstream strm(filename.c_str());
00090     while (strm.good()) {
00091         std::string name;
00092         strm >> name;
00093     }
00094 }

void GUISelectedStorage::SingleTypeSelections::save ( const std::string &  filename  )  throw (IOError)

Saves the list of selected objects to a file named as given.

Parameters:
[in] filename The name of the file to save the list into
Exceptions:
IOError recheck!!!
Todo:
Recheck: is this used(?)
Todo:
Recheck usage of IOError

Definition at line 98 of file GUISelectedStorage.cpp.

References OutputDevice::close(), OutputDevice::getDevice(), GUIGlObject::getFullName(), GUIGlObjectStorage::getObjectBlocking(), GUIGlObjectStorage::gIDStorage, mySelected, and GUIGlObjectStorage::unblockObject().

Referenced by GUISelectedStorage::save().

00098                                                                                      {
00099     OutputDevice &dev = OutputDevice::getDevice(filename);
00100     for (std::vector<GLuint>::iterator i=mySelected.begin(); i!=mySelected.end(); ++i) {
00101         GUIGlObject *object = GUIGlObjectStorage::gIDStorage.getObjectBlocking(*i);
00102         if (object!=0) {
00103             std::string name = object->getFullName();
00104             dev << name << "\n";
00105             GUIGlObjectStorage::gIDStorage.unblockObject(*i);
00106         }
00107     }
00108     dev.close();
00109 }

void GUISelectedStorage::SingleTypeSelections::select ( GLuint  id  )  throw ()

Adds the object with the given id to the list of selected objects.

Parameters:
[in] id The id of the object

Definition at line 64 of file GUISelectedStorage.cpp.

References mySelected.

Referenced by GUISelectedStorage::select().

00064                                                                 {
00065     std::vector<GLuint>::iterator i = find(mySelected.begin(), mySelected.end(), id);
00066     if (i==mySelected.end()) {
00067         mySelected.push_back(id);
00068     }
00069 }


Field Documentation

The list of selected ids.

Definition at line 304 of file GUISelectedStorage.h.

Referenced by clear(), deselect(), getSelected(), isSelected(), save(), and select().


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

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