aboutsummaryrefslogtreecommitdiffstats
path: root/include/Handler.hpp
diff options
context:
space:
mode:
authorNiklas Halle <niklas@niklashalle.net>2020-08-26 14:38:20 +0200
committerNiklas Halle <niklas@niklashalle.net>2020-08-26 14:38:20 +0200
commitafdd7e9b69b26aa7fadb65a0da6aa9a21341bc4c (patch)
tree44fea26701a3258f50500af1b3fb91b84d23ecb8 /include/Handler.hpp
parente78a940d37e8ab614fd566ee840d00fbaa577c40 (diff)
downloadn_core-afdd7e9b69b26aa7fadb65a0da6aa9a21341bc4c.tar.gz
n_core-afdd7e9b69b26aa7fadb65a0da6aa9a21341bc4c.zip
:(
Diffstat (limited to 'include/Handler.hpp')
-rw-r--r--include/Handler.hpp28
1 files changed, 7 insertions, 21 deletions
diff --git a/include/Handler.hpp b/include/Handler.hpp
index 63efa5d..7bbefcd 100644
--- a/include/Handler.hpp
+++ b/include/Handler.hpp
@@ -13,30 +13,16 @@ namespace Handler {
void *payload)> handler_function;
struct CommandHandler {
- CommandHandler(std::string command, handler_function func, std::vector<json> *description, void *payload = nullptr)
- : command{std::move(command)}, func{std::move(func)}, description{description}, payload{payload} {}
-
- ~CommandHandler() {
- delete description;
- description = nullptr;
- }
-
- CommandHandler(CommandHandler &&o) noexcept {
- command = std::move(o.command);
- func = std::move(o.func);
- description = o.description;
- o.description = nullptr;
- payload = o.payload;
- o.payload = nullptr;
- }
-
- [[nodiscard]] json exec(std::string const &arguments, std::string const &session) const {
- return func(arguments, session, payload);
- }
+ CommandHandler(std::string command, handler_function func, std::vector<json> *description,
+ void *payload = nullptr);
+
+ CommandHandler(CommandHandler &&o) noexcept;
+
+ [[nodiscard]] json exec(std::string const &arguments, std::string const &session) const;
std::string command;
handler_function func{nullptr};
- // handler takes ownership of the description, using it after passing is unsafe
+ // handler does NOT take ownership of the description, you have to delete it - after this object is destroyed
std::vector<json> *description{nullptr};
void *payload{nullptr};
};