diff options
Diffstat (limited to 'commands.h')
-rw-r--r-- | commands.h | 28 |
1 files changed, 24 insertions, 4 deletions
@@ -1,7 +1,10 @@ #ifndef COMMANDS_H #define COMMANDS_H +#include "music.h" + #include <boost/function.hpp> +#include <boost/asio.hpp> #include <string> #include <vector> @@ -9,8 +12,7 @@ #include <stdexcept> namespace commands { - typedef boost::function<std::vector<std::string> (const std::vector<std::string>&)> Handler; - extern std::map<std::string, commands::Handler> 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<std::string> execute(const std::vector<std::string>& args); + class Commands { + private: + typedef boost::function<std::vector<std::string> (Commands*)> Handler; + std::map<std::string, Handler> handlers; + + typedef boost::function<std::vector<MusicListing::p> (const std::string artist)> FindFunction; + std::map<std::string, FindFunction> find_handlers; + + boost::asio::io_service& io_service; + std::vector<std::string>& args; + + std::vector<std::string> ls(); + std::vector<std::string> find(); + std::vector<std::string> update(); + + public: + Commands(boost::asio::io_service& io_service, std::vector<std::string>& args); + std::vector<std::string> operator()(); + + }; }; #endif |