From c5ea2cf0d741e7ced6bd32e4a013a21be3755394 Mon Sep 17 00:00:00 2001 From: Niklas Halle Date: Wed, 26 Aug 2020 17:19:19 +0200 Subject: more indirection always helps, right? --- include/Handler.hpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/Handler.hpp b/include/Handler.hpp index 7bbefcd..37f281c 100644 --- a/include/Handler.hpp +++ b/include/Handler.hpp @@ -11,19 +11,23 @@ namespace Handler { typedef crow::json::wvalue json; typedef std::function handler_function; + typedef std::function()> description_function; struct CommandHandler { - CommandHandler(std::string command, handler_function func, std::vector *description, - void *payload = nullptr); + CommandHandler(std::string command, handler_function func, description_function desc, void *payload = nullptr); - CommandHandler(CommandHandler &&o) noexcept; + CommandHandler(CommandHandler &&o) noexcept { + command = std::move(o.command); + func = std::move(o.func); + get_description = std::move(get_description); + payload = o.payload; + }; [[nodiscard]] json exec(std::string const &arguments, std::string const &session) const; std::string command; handler_function func{nullptr}; - // handler does NOT take ownership of the description, you have to delete it - after this object is destroyed - std::vector *description{nullptr}; + description_function get_description{nullptr}; void *payload{nullptr}; }; -- cgit v1.2.3-54-g00ecf