 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
18 #ifndef NamedObjectCont_h
19 #define NamedObjectCont_h
46 typedef std::map< std::string, T >
IDMap;
51 for (
auto i :
myMap) {
65 bool add(
const std::string&
id, T item) {
69 myMap.insert(std::make_pair(
id, item));
78 bool remove(
const std::string&
id,
const bool del =
true) {
79 auto it =
myMap.find(
id);
80 if (it ==
myMap.end()) {
98 T
get(
const std::string&
id)
const {
99 auto it =
myMap.find(
id);
100 if (it ==
myMap.end()) {
109 for (
auto i :
myMap) {
117 return (
int)
myMap.size();
124 for (
auto i :
myMap) {
125 into.push_back(i.first);
130 bool changeID(
const std::string& oldId,
const std::string& newId) {
131 auto i =
myMap.find(oldId);
132 if (i ==
myMap.end()) {
138 myMap.insert(std::make_pair(newId, item));
144 typename IDMap::const_iterator
begin()
const {
145 return myMap.begin();
149 typename IDMap::const_iterator
end()
const {
void insertIDs(std::vector< std::string > &into) const
virtual ~NamedObjectCont()
Destructor.
int size() const
Returns the number of stored items within the container.
A map of named object pointers.
bool remove(const std::string &id, const bool del=true)
Removes an item.
IDMap::const_iterator begin() const
Returns a reference to the begin iterator for the internal map.
IDMap myMap
The map from key to object.
IDMap::const_iterator end() const
Returns a reference to the end iterator for the internal map.
bool changeID(const std::string &oldId, const std::string &newId)
change ID of a stored object
T get(const std::string &id) const
Retrieves an item.
void clear()
Removes all items from the container (deletes them, too)
std::map< std::string, T > IDMap
Definition of the key to pointer map type.
bool add(const std::string &id, T item)
Adds an item.