⚙️ C++ SPELL DIFFICULTY: Adept Structural

The Decorator

Dynamically attaching new magical properties to an artifact.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Enchantment // Imbuing
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// EXECUTABLE C++ PATTERN //
#include <memory>
class Relic {
public: virtual ~Relic() = default; virtual void Power() = 0;
};
class Amulet : public Relic {
public: void Power() override {}
};
class RelicDecorator : public Relic {
protected:
    std::unique_ptr<Relic> wrappee;
public:
    RelicDecorator(std::unique_ptr<Relic> r) : wrappee(std::move(r)) {}
    void Power() override { wrappee->Power(); }
};
class GlowingRelic : public RelicDecorator {
public:
    GlowingRelic(std::unique_ptr<Relic> r) : RelicDecorator(std::move(r)) {}
    void Power() override { wrappee->Power(); /* Add glow */ }
};
Runic Tags: #structural #decorator #cpp