diff options
| author | Thomas Holder <thomas@thomas-holder.de> | 2019-10-28 11:32:35 +0000 |
|---|---|---|
| committer | Thomas Holder <thomas@thomas-holder.de> | 2019-10-28 11:32:35 +0000 |
| commit | 98cbf65b029df0cfb9f6b7d34538258fe4ee96c5 (patch) | |
| tree | 43153dccc9e85e8aafb9288fc08521d35161e739 /src/style-internal.h | |
| parent | refactor: private SPIBase::_name (diff) | |
| download | inkscape-98cbf65b029df0cfb9f6b7d34538258fe4ee96c5.tar.gz inkscape-98cbf65b029df0cfb9f6b7d34538258fe4ee96c5.zip | |
refactor: TypedSPI
Diffstat (limited to 'src/style-internal.h')
| -rw-r--r-- | src/style-internal.h | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/style-internal.h b/src/style-internal.h index 2b6e2802b..8975072cd 100644 --- a/src/style-internal.h +++ b/src/style-internal.h @@ -22,6 +22,7 @@ #include <vector> #include <map> +#include "attributes.h" #include "style-enums.h" #include "color.h" @@ -207,7 +208,8 @@ public: return !(*this == rhs); } - Glib::ustring const &name() const { return _name; } + virtual SPAttributeEnum id() const { return SP_ATTR_INVALID; } + Glib::ustring const &name() const; private: Glib::ustring _name; @@ -225,6 +227,29 @@ public: SPStyle* style; // Used by SPIPaint, SPIFilter... to find values of other properties }; + +/** + * Decorator which overrides SPIBase::id() + */ +template <SPAttributeEnum Id, class Base> +class TypedSPI : public Base { + public: + using Base::Base; + + /** + * Get the attribute enum + */ + SPAttributeEnum id() const override { return Id; } + static SPAttributeEnum static_id() { return Id; } + + /** + * Upcast to the base class + */ + Base *upcast() { return static_cast<Base *>(this); } + Base const *upcast() const { return static_cast<Base const *>(this); } +}; + + /// Float type internal to SPStyle. (Only 'stroke-miterlimit') class SPIFloat : public SPIBase { |
