#include "CommandList.h" #include "Log.h" namespace core { CommandList::CommandList(std::string delimiter) : delimiter(delimiter) {} void CommandList::add(Command &command, std::string name) { commands.insert(std::make_pair(name, &command)); } void CommandList::remove(Command &command) {} bool CommandList::processRequest(coreutils::ZString &request, TCPSession &session) { if(session.grab != NULL) return session.grab->processCommand(request, session); else { if(request.equals("")) return false; request.split(delimiter); auto command = commands.find(request[0].str())->second; return command->processCommand(request, session); } return false; } bool CommandList::grabInput(TCPSession &session, Command &command) { session.grab = &command; return true; } void CommandList::clearGrab(TCPSession &session) { session.grab = NULL; } int CommandList::processCommand(coreutils::ZString &request, TCPSession &session) { // for(Command *command : commands) // session.out << command->getName() << std::endl; return true; } }