X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Fcollection.h;h=6ddbe6ed65c980d035b30160ad1eca18c0390f1f;hp=85ca843f5e1aba552ab2c2ed26a7241d30675d0b;hb=9c0da3059eed8470325477d99a0d56f0948534fd;hpb=92644bf892df1220c8df67e1fc3da85dd02c53c5 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.