X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Fobjectloader.h;h=5928714215cd056297cab8fd79e1f9647fe648e2;hp=f1cb6ffe051c5f8405fa652a67d36b3001dee380;hb=f51adf2b95f32bdda4d90eb52431405c3ecf8db1;hpb=61f6f66a7db1a074143cd0e9948a262d30876dea 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.