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++) {
80 virtual bool add(
const std::string&
id, T item) {
84 myMap.insert(std::make_pair(
id, item));
94 virtual bool remove(
const std::string& id) {
98 typename std::map<std::string, T>::iterator i =
myMap.find(
id);
113 T
get(
const std::string& id)
const {
114 typename std::map<std::string, T>::const_iterator i =
myMap.find(
id);
115 if (i ==
myMap.end()) {
124 for (
typename IDMap::iterator i =
myMap.begin(); i !=
myMap.end(); i++) {
138 return (
int)
myMap.size();
152 typename IDMap::iterator i =
myMap.find(
id);
153 if (i ==
myMap.end()) {
159 typename ObjectVector::iterator i2 =
182 typename IDMap::const_iterator i;
183 for (i =
myMap.begin(); i !=
myMap.end(); ++i) {
201 typename IDMap::const_iterator i;
202 for (i =
myMap.begin(); i !=
myMap.end(); ++i) {
203 ret.push_back((*i).second);
213 typename IDMap::const_iterator i;
214 for (i =
myMap.begin(); i !=
myMap.end(); ++i) {
215 into.push_back((*i).first);
ObjectVector myVector
The stored vector of all known items.
std::vector< T > ObjectVector
Definition objects vector.
IDMap myMap
The map from key to 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
std::vector< T > getTempVector() const
const IDMap & getMyMap() const
virtual ~NamedObjectCont()
Destructor.
const std::vector< T > & buildAndGetStaticVector() const
bool myHaveChanged
Information whether the vector is out of sync with the map.
NamedObjectCont()
Constructor.
int size() const
Returns the number of items within the container.