From e19efcb8e7ba2cf4d4ce59c5f76e78a41a19ba24 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sun, 2 Jan 2011 03:55:52 +0100 Subject: Command handling changes as a result of adding the update command. --- commands.h | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'commands.h') diff --git a/commands.h b/commands.h index 42a9452..ae5dc84 100644 --- a/commands.h +++ b/commands.h @@ -1,7 +1,10 @@ #ifndef COMMANDS_H #define COMMANDS_H +#include "music.h" + #include +#include #include #include @@ -9,8 +12,7 @@ #include namespace commands { - typedef boost::function (const std::vector&)> Handler; - extern std::map handlers; + class Commands; class CommandException : public std::runtime_error { public: @@ -18,8 +20,26 @@ namespace commands { CommandException(std::string s) : std::runtime_error(s.c_str()) {}; }; - void init(); - std::vector execute(const std::vector& args); + class Commands { + private: + typedef boost::function (Commands*)> Handler; + std::map handlers; + + typedef boost::function (const std::string artist)> FindFunction; + std::map find_handlers; + + boost::asio::io_service& io_service; + std::vector& args; + + std::vector ls(); + std::vector find(); + std::vector update(); + + public: + Commands(boost::asio::io_service& io_service, std::vector& args); + std::vector operator()(); + + }; }; #endif -- cgit v1.2.3