19 #ifndef NamedObjectCont_h 20 #define NamedObjectCont_h 47 typedef std::map< std::string, T >
IDMap;
52 for (
auto i :
myMap) {
66 bool add(
const std::string&
id, T item) {
70 myMap.insert(std::make_pair(
id, item));
79 bool remove(
const std::string& id,
const bool del =
true) {
80 auto it =
myMap.find(
id);
81 if (it ==
myMap.end()) {
99 T
get(
const std::string& id)
const {
100 auto it =
myMap.find(
id);
101 if (it ==
myMap.end()) {
110 for (
auto i :
myMap) {
118 return (
int)
myMap.size();
125 for (
auto i :
myMap) {
126 into.push_back(i.first);
131 bool changeID(
const std::string& oldId,
const std::string& newId) {
132 auto i =
myMap.find(oldId);
133 if (i ==
myMap.end()) {
139 myMap.insert(std::make_pair(newId, item));
145 typename IDMap::const_iterator
begin()
const {
146 return myMap.begin();
150 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.