44 typedef std::map< std::string, T >
IDMap;
49 for (
auto i :
myMap) {
63 bool add(
const std::string&
id, T item) {
67 myMap.insert(std::make_pair(
id, item));
76 bool remove(
const std::string&
id,
const bool del =
true) {
77 auto it =
myMap.find(
id);
78 if (it ==
myMap.end()) {
96 T
get(
const std::string&
id)
const {
97 auto it =
myMap.find(
id);
98 if (it ==
myMap.end()) {
107 for (
auto i :
myMap) {
115 return (
int)
myMap.size();
122 for (
auto i :
myMap) {
123 into.push_back(i.first);
128 bool changeID(
const std::string& oldId,
const std::string& newId) {
129 auto i =
myMap.find(oldId);
130 if (i ==
myMap.end()) {
136 myMap.insert(std::make_pair(newId, item));
142 typename IDMap::const_iterator
begin()
const {
143 return myMap.begin();
147 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.