bool TLVExecutor::execute(Cmd& cmd) { if(cmd.size() < 2) { log("Error cmd with no params:%s", printCmd(cmd)); return false; } const char* key = cmd[0].c_str(); if(0 == strcasecmp("settag", key)) { CheckParam(2); return TLVInterface::setTag(atoi(getp(1)),getp(2)); } else if(0 == strcasecmp("gettag", key)) { CheckParam(2); return TLVInterface::getTag(atoi(getp(1)),getp(2)); } else if(0 == strcasecmp("addtag", key)) { CheckParam(2); return TLVInterface::addTag(atoi(getp(1)),getp(2)); } return false; }
bool CmdsExecutor::doExecute(Cmd& cmd) { if(cmd.size() < 2) { log("Error cmd with no params:%s", printCmd(cmd)); return false; } ExecutorPtr it = m_executors.begin(); for(; it != m_executors.end(); it++) { if((*it)->execute(cmd)) { return true; } } log("Command not run: %s", printCmd(cmd)); return false; }