43 typedef std::map< std::string, T >
IDMap;
48 for (
auto i :
myMap) {
62 bool add(
const std::string&
id, T item) {
66 myMap.insert(std::make_pair(
id, item));
75 bool remove(
const std::string&
id,
const bool del =
true) {
76 auto it =
myMap.find(
id);
77 if (it ==
myMap.end()) {
95 T
get(
const std::string&
id)
const {
96 auto it =
myMap.find(
id);
97 if (it ==
myMap.end()) {
106 for (
auto i :
myMap) {
114 return (
int)
myMap.size();
121 for (
auto i :
myMap) {
122 into.push_back(i.first);
127 bool changeID(
const std::string& oldId,
const std::string& newId) {
128 auto i =
myMap.find(oldId);
129 if (i ==
myMap.end()) {
135 myMap.insert(std::make_pair(newId, item));
141 typename IDMap::const_iterator
begin()
const {
142 return myMap.begin();
146 typename IDMap::const_iterator
end()
const {
A map of named object pointers.
void clear()
Removes all items from the container (deletes them, too)
IDMap myMap
The map from key to object.
std::map< std::string, T > IDMap
Definition of the key to pointer map type.
T get(const std::string &id) const
Retrieves an item.
void insertIDs(std::vector< std::string > &into) const
IDMap::const_iterator begin() const
Returns a reference to the begin iterator for the internal map.
IDMap::const_iterator end() const
Returns a reference to the end iterator for the internal map.
int size() const
Returns the number of stored items within the container.
bool changeID(const std::string &oldId, const std::string &newId)
change ID of a stored object
virtual ~NamedObjectCont()
Destructor.
bool remove(const std::string &id, const bool del=true)
Removes an item.
bool add(const std::string &id, T item)
Adds an item.