summaryrefslogtreecommitdiff
path: root/commands.h
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-01-02 03:55:52 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2011-01-02 03:55:52 +0100
commite19efcb8e7ba2cf4d4ce59c5f76e78a41a19ba24 (patch)
treeef89bb164d0e06f30396e84804cbc33c074ac065 /commands.h
parent0473fa912e2d2531529fec14a201efa3b20e2ef3 (diff)
Command handling changes as a result of adding the update command.
Diffstat (limited to 'commands.h')
-rw-r--r--commands.h28
1 files changed, 24 insertions, 4 deletions
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 <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