#include "CommandList.h"

namespace core {
   
   CommandList::CommandList() {}
   
   CommandList::~CommandList() {}
   
   void CommandList::add(Command &command, std::string name) {
      command.setName(name);
      commands.push_back(&command);

   }
   
   void CommandList::remove(Command &command) {
      
   }
   
   bool CommandList::processRequest(std::string request, Session *session, std::stringstream &data) {   
   
      for(auto *command : commands) {
         if(command->check(request)) {
            command->processCommand(request, session, data);
            return true;
         }
      }  
      return false;
   }
   
   int CommandList::processCommand(std::string request, Session *session, std::stringstream &data) {
      for(Command *command : commands) 
         data << command->getName() << std::endl;
   }
   
}



