21 #ifndef NamedObjectCont_h 22 #define NamedObjectCont_h 54 typedef std::map< std::string, T >
IDMap;
59 for (
auto i :
myMap) {
73 bool add(
const std::string&
id, T item) {
77 myMap.insert(std::make_pair(
id, item));
86 bool remove(
const std::string& id,
const bool del =
true) {
87 auto it =
myMap.find(
id);
88 if (it ==
myMap.end()) {
106 T
get(
const std::string& id)
const {
107 auto it =
myMap.find(
id);
108 if (it ==
myMap.end()) {
117 for (
auto i :
myMap) {
125 return (
int)
myMap.size();
132 for (
auto i :
myMap) {
133 into.push_back(i.first);
138 bool changeID(
const std::string& oldId,
const std::string& newId) {
139 auto i =
myMap.find(oldId);
140 if (i ==
myMap.end()) {
146 myMap.insert(std::make_pair(newId, item));
152 typename IDMap::const_iterator
begin()
const {
153 return myMap.begin();
157 typename IDMap::const_iterator
end()
const {
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.
int size() const
Returns the number of stored items within the container.
A map of named object pointers.
void insertIDs(std::vector< std::string > &into) const
bool add(const std::string &id, T item)
Adds an item.
void clear()
Removes all items from the container (deletes them, too)
virtual ~NamedObjectCont()
Destructor.
IDMap::const_iterator end() const
Returns a reference to the end iterator for the internal map.
IDMap::const_iterator begin() const
Returns a reference to the begin iterator for the internal map.