aboutsummaryrefslogtreecommitdiffstats
path: root/include/Handler.hpp
diff options
context:
space:
mode:
authorNiklas Halle <niklas@niklashalle.net>2020-08-26 17:19:19 +0200
committerNiklas Halle <niklas@niklashalle.net>2020-08-26 17:19:19 +0200
commitc5ea2cf0d741e7ced6bd32e4a013a21be3755394 (patch)
tree55e7da929f3956a90b12f67e45155a09824b949a /include/Handler.hpp
parent83572f021f3b23a9046f1988e6e0443ed6295df3 (diff)
downloadn_core-c5ea2cf0d741e7ced6bd32e4a013a21be3755394.tar.gz
n_core-c5ea2cf0d741e7ced6bd32e4a013a21be3755394.zip
more indirection always helps, right?test/new_server
Diffstat (limited to 'include/Handler.hpp')
-rw-r--r--include/Handler.hpp14
1 files changed, 9 insertions, 5 deletions
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<json(std::string const &arguments, std::string const &session,
void *payload)> handler_function;
+ typedef std::function<std::vector<json>()> description_function;
struct CommandHandler {
- CommandHandler(std::string command, handler_function func, std::vector<json> *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<json> *description{nullptr};
+ description_function get_description{nullptr};
void *payload{nullptr};
};