22 #ifndef NamedObjectCont_h 23 #define NamedObjectCont_h 57 typedef std::map< std::string, T >
IDMap;
65 for (
typename IDMap::iterator i =
myMap.begin(); i !=
myMap.end(); i++) {
79 virtual bool add(
const std::string&
id, T item) {
83 myMap.insert(std::make_pair(
id, item));
93 virtual bool remove(
const std::string& id) {
94 typename std::map<std::string, T>::iterator it =
myMap.find(
id);
95 if (it ==
myMap.end()) {
112 T
get(
const std::string& id)
const {
113 typename std::map<std::string, T>::const_iterator it =
myMap.find(
id);
114 if (it ==
myMap.end()) {
123 for (
typename IDMap::iterator i =
myMap.begin(); i !=
myMap.end(); i++) {
133 return (
int)
myMap.size();
146 typename IDMap::iterator i =
myMap.find(
id);
147 if (i ==
myMap.end()) {
153 typename ObjectVector::iterator i2 =
168 typename IDMap::const_iterator i;
169 for (i =
myMap.begin(); i !=
myMap.end(); ++i) {
170 into.push_back((*i).first);
175 bool changeID(
const std::string& oldId,
const std::string& newId) {
176 typename IDMap::iterator i =
myMap.find(oldId);
177 if (i ==
myMap.end()) {
181 T item = (*i).second;
183 myMap.insert(std::make_pair(newId, item));
ObjectVector myVector
The stored vector of all known items.
std::vector< T > ObjectVector
Definition objects vector.
IDMap myMap
The map from key to object.
bool changeID(const std::string &oldId, const std::string &newId)
change ID of a stored object
std::map< std::string, T > IDMap
Definition of the key to pointer map type.
bool erase(const std::string &id)
Removes the named item from the container.
virtual bool add(const std::string &id, T item)
Adds an item.
A map of named object pointers.
void clear()
Removes all items from the container (deletes them, too)
IDMap::iterator myContIt
Definition of the container type iterator.
void insertIDs(std::vector< std::string > &into) const
const IDMap & getMyMap() const
Returns a reference to the internal map.
virtual ~NamedObjectCont()
Destructor.
bool myHaveChanged
Information whether the vector is out of sync with the map.
NamedObjectCont()
Constructor.
int size() const
Returns the number of stored items within the container.