From f51adf2b95f32bdda4d90eb52431405c3ecf8db1 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 10 Jul 2012 18:28:11 +0300 Subject: [PATCH] Add DerivedObjectLoader class --- source/objectloader.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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. -- 2.45.2