#include <MSJunctionControl.h>

Definition at line 53 of file MSJunctionControl.h.
Public Member Functions | |
| virtual bool | add (const std::string &id, MSJunction *item) throw () |
| Adds an item. | |
| const std::vector< MSJunction * > & | buildAndGetStaticVector () const throw () |
| void | clear () throw () |
| Removes all items from the container (deletes them, too). | |
| bool | erase (const std::string &id) throw () |
| Removes the named item from the container. | |
| MSJunction * | get (const std::string &id) const throw () |
| Retrieves an item. | |
| const std::map< std::string, MSJunction * > & | getMyMap () const throw () |
| std::vector< MSJunction * > | getTempVector () const throw () |
| void | insertIDs (std::vector< std::string > &into) const throw () |
| MSJunctionControl () throw () | |
| Constructor. | |
| void | postloadInitContainer () throw (ProcessError) |
| Closes building of junctions. | |
| virtual bool | remove (const std::string &id) throw () |
| Removes an item. | |
| void | resetRequests () throw () |
| Resets the requests for all lanes. | |
| void | setAllowed () throw () |
| Sets the responds. | |
| unsigned int | size () const throw () |
| Returns the number of items within the container. | |
| ~MSJunctionControl () throw () | |
| Destructor. | |
Private Member Functions | |
| MSJunctionControl (const MSJunctionControl &) | |
| Invalidated copy constructor. | |
| MSJunctionControl & | operator= (const MSJunctionControl &) |
| Invalidated assignment operator. | |
| MSJunctionControl::MSJunctionControl | ( | ) | throw () |
| MSJunctionControl::~MSJunctionControl | ( | ) | throw () |
| MSJunctionControl::MSJunctionControl | ( | const MSJunctionControl & | ) | [private] |
Invalidated copy constructor.
| virtual bool NamedObjectCont< MSJunction * >::add | ( | const std::string & | id, | |
| MSJunction * | item | |||
| ) | throw () [inline, virtual, inherited] |
Adds an item.
If another item with the same name is already known, false is reported and the item is not added.
| [in] | id | The id of the item to add |
| [in] | item | The item to add |
Definition at line 74 of file NamedObjectCont.h.
00074 { 00075 if (myMap.find(id)!=myMap.end()) { 00076 return false; 00077 } 00078 myMap.insert(std::make_pair(id, item)); 00079 myHaveChanged = true; 00080 return true; 00081 }
| const std::vector<MSJunction * >& NamedObjectCont< MSJunction * >::buildAndGetStaticVector | ( | ) | const throw () [inline, inherited] |
Definition at line 173 of file NamedObjectCont.h.
Referenced by postloadInitContainer(), resetRequests(), and setAllowed().
00173 { 00174 if (myHaveChanged) { 00175 myVector.clear(); 00176 typename IDMap::const_iterator i; 00177 for (i=myMap.begin(); i!=myMap.end(); ++i) { 00178 myVector.push_back((*i).second); 00179 } 00180 myHaveChanged = false; 00181 } 00182 return myVector; 00183 }
| void NamedObjectCont< MSJunction * >::clear | ( | ) | throw () [inline, inherited] |
Removes all items from the container (deletes them, too).
Definition at line 117 of file NamedObjectCont.h.
00117 { 00118 for (typename IDMap::iterator i=myMap.begin(); i!=myMap.end(); i++) { 00119 delete(*i).second; 00120 } 00121 myMap.clear(); 00122 myVector.clear(); 00123 myHaveChanged = true; 00124 }
| bool NamedObjectCont< MSJunction * >::erase | ( | const std::string & | id | ) | throw () [inline, inherited] |
Removes the named item from the container.
If the named object exists, it is deleted, the key is removed from the map, and true is returned. If the id was not known, false is returned.
| [in] | id | The id of the item to delete |
Definition at line 145 of file NamedObjectCont.h.
00145 { 00146 typename IDMap::iterator i=myMap.find(id); 00147 if (i==myMap.end()) { 00148 return false; 00149 } 00150 T o = (*i).second; 00151 myMap.erase(i); 00152 // and from the vector 00153 typename ObjectVector::iterator i2 = 00154 find(myVector.begin(), myVector.end(), o); 00155 myHaveChanged = true; 00156 if (i2!=myVector.end()) { 00157 myVector.erase(i2); 00158 } 00159 delete o; 00160 return true; 00161 }
| MSJunction * NamedObjectCont< MSJunction * >::get | ( | const std::string & | id | ) | const throw () [inline, inherited] |
Retrieves an item.
Returns 0 when no item with the given id is stored within the container
| [in] | id | The id of the item to retrieve |
Definition at line 107 of file NamedObjectCont.h.
00107 { 00108 typename std::map<std::string, T>::const_iterator i = myMap.find(id); 00109 if (i==myMap.end()) { 00110 return 0; 00111 } 00112 return (*i).second; 00113 }
| const std::map<std::string, MSJunction * >& NamedObjectCont< MSJunction * >::getMyMap | ( | ) | const throw () [inline, inherited] |
| std::vector<MSJunction * > NamedObjectCont< MSJunction * >::getTempVector | ( | ) | const throw () [inline, inherited] |
Definition at line 193 of file NamedObjectCont.h.
00193 { 00194 std::vector<T> ret; 00195 typename IDMap::const_iterator i; 00196 for (i=myMap.begin(); i!=myMap.end(); ++i) { 00197 ret.push_back((*i).second); 00198 } 00199 return ret; 00200 }
| void NamedObjectCont< MSJunction * >::insertIDs | ( | std::vector< std::string > & | into | ) | const throw () [inline, inherited] |
Definition at line 206 of file NamedObjectCont.h.
00206 { 00207 typename IDMap::const_iterator i; 00208 for (i=myMap.begin(); i!=myMap.end(); ++i) { 00209 into.push_back((*i).first); 00210 } 00211 }
| MSJunctionControl& MSJunctionControl::operator= | ( | const MSJunctionControl & | ) | [private] |
Invalidated assignment operator.
| void MSJunctionControl::postloadInitContainer | ( | ) | throw (ProcessError) |
Closes building of junctions.
Calls "postloadInit" on all stored junctions.
| ProcessError | From the called "postloadInit" |
Definition at line 51 of file MSJunctionControl.cpp.
References NamedObjectCont< MSJunction * >::buildAndGetStaticVector().
Referenced by MSNet::closeBuilding().
00051 { 00052 const std::vector<MSJunction*> &junctions = buildAndGetStaticVector(); 00053 for (std::vector<MSJunction*>::const_iterator i=junctions.begin(); i!=junctions.end(); ++i) { 00054 (*i)->postloadInit(); 00055 } 00056 }
| virtual bool NamedObjectCont< MSJunction * >::remove | ( | const std::string & | id | ) | throw () [inline, virtual, inherited] |
Removes an item.
| [in] | id | The id of the item to remove |
Definition at line 88 of file NamedObjectCont.h.
00088 { 00089 if (myMap.find(id)==myMap.end()) { 00090 return false; 00091 } 00092 typename std::map<std::string, T>::iterator i = myMap.find(id); 00093 delete i->second; 00094 myMap.erase(i); 00095 myHaveChanged = true; 00096 return true; 00097 }
| void MSJunctionControl::resetRequests | ( | ) | throw () |
Resets the requests for all lanes.
Calls "clearRequests" for all stored junctions.
Definition at line 60 of file MSJunctionControl.cpp.
References NamedObjectCont< MSJunction * >::buildAndGetStaticVector(), and MSJunction::clearRequests().
00060 { 00061 const std::vector<MSJunction*> &junctions = buildAndGetStaticVector(); 00062 std::for_each(junctions.begin(), junctions.end(), std::mem_fun(& MSJunction::clearRequests)); 00063 }
| void MSJunctionControl::setAllowed | ( | ) | throw () |
Sets the responds.
Calls "setAllowed" for all stored junctions.
Definition at line 67 of file MSJunctionControl.cpp.
References NamedObjectCont< MSJunction * >::buildAndGetStaticVector(), and MSJunction::setAllowed().
Referenced by MSNet::simulationStep().
00067 { 00068 const std::vector<MSJunction*> &junctions = buildAndGetStaticVector(); 00069 std::for_each(junctions.begin(), junctions.end(), std::mem_fun(& MSJunction::setAllowed)); 00070 }
| unsigned int NamedObjectCont< MSJunction * >::size | ( | ) | const throw () [inline, inherited] |
Returns the number of items within the container.
Definition at line 131 of file NamedObjectCont.h.
00131 { 00132 return (unsigned int) myMap.size(); 00133 }
1.5.6