From f2f933f53cd729ca034e054085b96107f64f3928 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 7 Oct 2021 15:54:23 +0300 Subject: [PATCH] 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. --- source/dynamicobjectloader.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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; -- 2.45.2