From 9c0da3059eed8470325477d99a0d56f0948534fd Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 18 Oct 2007 13:43:18 +0000 Subject: [PATCH] Add Collection::get_list --- source/collection.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/source/collection.h b/source/collection.h index 85ca843..6ddbe6e 100644 --- a/source/collection.h +++ b/source/collection.h @@ -251,11 +251,26 @@ public: { std::list result; for(ItemMap::const_iterator i=items.begin(); i!=items.end(); ++i) - if(dynamic_cast *>(i->second)) + if(dynamic_cast::Type> *>(i->second)) result.push_back(i->first); return result; } + /** + Returns a list of objects of a specific type in the collection. + */ + template + std::list get_list() const + { + typedef typename RemoveConst::Type NCT; + + std::list result; + for(ItemMap::const_iterator i=items.begin(); i!=items.end(); ++i) + if(Item *item=dynamic_cast *>(i->second)) + result.push_back(item->data); + return result; + } + /** Checks whether a name exists in the collection. Does not care about the type of the object. -- 2.45.2