X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Fobjectloader.h;h=a2a8720e840e6393f3e185950741fc6ba0df5729;hp=f1cb6ffe051c5f8405fa652a67d36b3001dee380;hb=07d4c0e55aa9571c9f24cf39d134f1f7474fd7cb;hpb=302f73123da1194dd91b43138cd880cae9318a14 diff --git a/source/objectloader.h b/source/objectloader.h index f1cb6ff..a2a8720 100644 --- a/source/objectloader.h +++ b/source/objectloader.h @@ -35,6 +35,29 @@ 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 +{ +public: + typedef O Object; + +protected: + O &obj; + + DerivedObjectLoader(O &o): B(o), obj(o) { } + + template + DerivedObjectLoader(O &o, T &a): B(o, a), 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.