X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fobjectloader.h;h=978366f730e51cc197fe7dd20ab7f56f4b52e84e;hb=refs%2Fheads%2Fwip;hp=5928714215cd056297cab8fd79e1f9647fe648e2;hpb=f51adf2b95f32bdda4d90eb52431405c3ecf8db1;p=libs%2Fdatafile.git diff --git a/source/objectloader.h b/source/objectloader.h index 5928714..978366f 100644 --- a/source/objectloader.h +++ b/source/objectloader.h @@ -1,18 +1,12 @@ #ifndef MSP_DATAFILE_OBJECTLOADER_H_ #define MSP_DATAFILE_OBJECTLOADER_H_ -#include +#include "except.h" #include "loader.h" namespace Msp { namespace DataFile { -class no_collection: public std::runtime_error -{ -public: - no_collection(const std::type_info &); -}; - class Collection; /** @@ -20,7 +14,7 @@ Provides the basic functionality of an object loader. Deriving from this allows loading values directly into member variables of the objects. */ template -class ObjectLoader: public Loader +class ObjectLoader: virtual public Loader { public: typedef O Object; @@ -40,7 +34,7 @@ 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 +class DerivedObjectLoader: public B { public: typedef O Object; @@ -48,7 +42,8 @@ public: protected: O &obj; - DerivedObjectLoader(O &o): B::Loader(o), obj(o) { } + template + DerivedObjectLoader(O &o, Args &&... a): B(o, std::forward(a)...), obj(o) { } public: O &get_object() const { return obj; } @@ -66,7 +61,7 @@ public: typedef C Collection; protected: - C *coll; + C *coll = nullptr; CollectionObjectLoader(O &o, C *c): ObjectLoader(o), coll(c) { }