#pragma once #include #include "IProperty.h" namespace mdd { template class Property : public IProperty { PropertyValue val; std::map> _subprops; protected: virtual IPropertyValue* GetPropertyValue() { return &val; } public: typedef std::shared_ptr> Ptr; virtual std::shared_ptr GetSubProp(const std::string& name) { auto sub = _subprops.find(name); if (sub == _subprops.end()) { return std::make_shared>(); } else { return sub->second; } } template std::shared_ptr> addSubProperty(const std::string& name) { auto newprop = std::make_shared>(); _subprops[name] = newprop; return newprop; } template std::shared_ptr> addSubProperty(const std::string& name, const T& default) { auto newprop = std::make_shared>(); newprop->Value() = default; _subprops[name] = newprop; return newprop; } TYPE& Value() { return *val.value; } }; }