From: Mikko Rasa Date: Thu, 7 Oct 2021 12:54:23 +0000 (+0300) Subject: Tweak DynamicObjectLoader to make it extensible X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f2f933f53cd729ca034e054085b96107f64f3928;p=libs%2Fdatafile.git Tweak DynamicObjectLoader to make it extensible Subclasses can now override te type handler and access the object without clearing it, for example to perform some custom initialization after the object has been created. --- diff --git a/source/dynamicobjectloader.h b/source/dynamicobjectloader.h index e29633d..551a0a6 100644 --- a/source/dynamicobjectloader.h +++ b/source/dynamicobjectloader.h @@ -31,8 +31,8 @@ protected: typedef Msp::TypeRegistry TypeRegistry; Collection *coll; -private: T *object; +private: Loader *obj_loader; std::function store_func; @@ -50,9 +50,10 @@ public: T *get_object() { T *o = object; object = 0; return o; } T *store_object(Collection &, const std::string &); -private: - void type(const Symbol &); +protected: + virtual void type(const Symbol &); +private: template typename std::enable_if::value, typename U::Loader *>::type create_object_loader(U &obj) const;