From: Mikko Rasa Date: Thu, 18 Oct 2007 13:43:18 +0000 (+0000) Subject: Add Collection::get_list X-Git-Tag: 1.0~14 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=9c0da3059eed8470325477d99a0d56f0948534fd;p=libs%2Fdatafile.git Add Collection::get_list --- 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.