From: Mikko Rasa Date: Tue, 10 Jul 2012 15:28:11 +0000 (+0300) Subject: Add DerivedObjectLoader class X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f51adf2b95f32bdda4d90eb52431405c3ecf8db1;p=libs%2Fdatafile.git Add DerivedObjectLoader class --- diff --git a/source/objectloader.h b/source/objectloader.h index f1cb6ff..5928714 100644 --- a/source/objectloader.h +++ b/source/objectloader.h @@ -35,6 +35,26 @@ public: }; +/** +Convenience class for loading derived objects. Inherits from the base class +loader and shadows its members with ones for the derived type. +*/ +template +class DerivedObjectLoader: public B::Loader +{ +public: + typedef O Object; + +protected: + O &obj; + + DerivedObjectLoader(O &o): B::Loader(o), obj(o) { } + +public: + O &get_object() const { return obj; } +}; + + /** Provides functionality for loading objects with a Collection. Deriving from this allows loading pointers to objects in the collection automatically.