From c1aa1d5a2b34b6a3339a157af3031b553fb8dd05 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 17 Mar 2021 17:26:55 +0000 Subject: Add a subclass of ExtensionItem exclusively for booleans. --- src/modules/m_topiclock.cpp | 56 ++------------------------------------------- 1 file changed, 2 insertions(+), 54 deletions(-) (limited to 'src/modules/m_topiclock.cpp') diff --git a/src/modules/m_topiclock.cpp b/src/modules/m_topiclock.cpp index 01060d22c..07f121faa 100644 --- a/src/modules/m_topiclock.cpp +++ b/src/modules/m_topiclock.cpp @@ -74,69 +74,17 @@ class CommandSVSTOPIC : public Command } }; -// TODO: add a BoolExtItem to replace this. -class FlagExtItem : public ExtensionItem -{ - public: - FlagExtItem(const std::string& key, Module* owner) - : ExtensionItem(owner, key, ExtensionItem::EXT_CHANNEL) - { - } - - bool Get(const Extensible* container) const - { - return (GetRaw(container) != NULL); - } - - std::string ToHuman(const Extensible* container, void* item) const noexcept override - { - // Make the human version more readable. - return "true"; - } - - std::string ToNetwork(const Extensible* container, void* item) const noexcept override - { - return "1"; - } - - void FromNetwork(Extensible* container, const std::string& value) noexcept override - { - if (value == "1") - SetRaw(container, this); - else - UnsetRaw(container); - } - - void set(Extensible* container, bool value) - { - if (value) - SetRaw(container, this); - else - UnsetRaw(container); - } - - void Unset(Extensible* container) - { - UnsetRaw(container); - } - - void Delete(Extensible* container, void* item) override - { - // nothing to free - } -}; - class ModuleTopicLock : public Module { private: CommandSVSTOPIC cmd; - FlagExtItem topiclock; + BoolExtItem topiclock; public: ModuleTopicLock() : Module(VF_VENDOR | VF_COMMON, "Allows services to lock the channel topic so that it can not be changed.") , cmd(this) - , topiclock("topiclock", this) + , topiclock(this, "topiclock", ExtensionItem::EXT_CHANNEL) { } -- cgit v1.3.1-10-gc9f91