msh-console/commands.cpp

30 lines
571 B
C++

#include "commands.h"
using namespace Cmds;
Commands::Commands()
{
if(created) throw CommandsAlreadyCreatedException();
created=true;
}
void Commands::add(Command* cmd){
commands.push_back(cmd);
}
size_t Commands::howMany(){
return commands.size();
}
int Commands::launch(const vector<string>* args){
for(unsigned int i=0; i<commands.size(); i++){
if((commands[i]->getName())==args->operator [](0)){
return commands[i]->execute(args);
}
}
throw CommandNotFoundException();
}
bool Commands::created = false;