Commit 86e8db71 authored by yannick legoc's avatar yannick legoc

Added get variable list request in CommandZoneResponder for the list of...

Added get variable list request in CommandZoneResponder for the list of available loop variables in a given command box
parent 912e5f86
......@@ -149,6 +149,8 @@ message Message {
CheckStaticPropertyExpression = 80;
SetPropertyExpression = 81;
GetPropertyExpression = 82;
GetVariableList = 85;
}
required Type type = 1;
......
......@@ -152,6 +152,7 @@ void CommandZoneResponder::initProcessFunctions() {
m_processFunctions[commandzone::Message::CheckStaticPropertyExpression] = &CommandZoneResponder::processCheckStaticPropertyExpression;
m_processFunctions[commandzone::Message::SetPropertyExpression] = &CommandZoneResponder::processSetPropertyExpression;
m_processFunctions[commandzone::Message::GetPropertyExpression] = &CommandZoneResponder::processGetPropertyExpression;
m_processFunctions[commandzone::Message::GetVariableList] = &CommandZoneResponder::processGetVariableList;
}
CommandBox* CommandZoneResponder::getCommandBox(unsigned long commandBoxID) {
......@@ -2709,6 +2710,40 @@ void CommandZoneResponder::processGetPropertyExpression(const std::string & mess
responseMessage.SerializeToString(&response);
}
void CommandZoneResponder::processGetVariableList(const std::string & message, std::string & response) {
commandzone::CommandBoxRequest messageRequest;
messageRequest.ParseFromString(message);
common::StringArrayResponse responseMessage;
CommandBox* commandBox = getCommandBox(messageRequest.commandboxid());
if (commandBox == 0) {
responseMessage.set_error(common::Error::COMMAND_BOX_NOT_FOUND);
}
else {
try {
// Get the variables.
std::vector<std::string> variableNames;
commandBox->addVariableNamesToList(variableNames);
// Copy the values.
vector<string>::const_iterator it;
for (it = variableNames.begin(); it != variableNames.end(); it++) {
responseMessage.add_value(*it);
}
}
catch (common::Exception& e) {
err << e.printStack() << eol;
}
}
// Serialize the response.
responseMessage.SerializeToString(&response);
}
void CommandZoneResponder::loop() {
// Initialize the map of functions.
......
......@@ -171,6 +171,8 @@ private:
void processSetPropertyExpression(const std::string & message, std::string & response);
void processGetPropertyExpression(const std::string & message, std::string & response);
void processGetVariableList(const std::string & message, std::string & response);
std::auto_ptr<boost::thread> m_thread;
std::auto_ptr<cameo::application::Responder> m_responder;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment