Commit fe775e0b authored by yannick legoc's avatar yannick legoc

Added the request to get the list of controller types inheriting another type

parent 2ae02c02
......@@ -57,6 +57,8 @@ message Message {
GetControllerIconKeys = 24;
UserLog = 25;
GetControllerTypesInheritingType = 26;
}
required Type type = 1;
......@@ -104,3 +106,9 @@ message UserLogRequest {
required string userName = 1;
required string message = 2;
}
message GetControllerTypesInheritingTypeRequest {
required uint32 databaseID = 1;
required string type = 2;
}
......@@ -93,6 +93,7 @@ void ServantManagerResponder::initProcessFunctions() {
m_processFunctions[servantmanager::Message::GetServantCommandsState] = &ServantManagerResponder::processGetServantCommandsState;
m_processFunctions[servantmanager::Message::GetFamilyImageKeys] = &ServantManagerResponder::processGetFamilyImageKeys;
m_processFunctions[servantmanager::Message::GetControllerIconKeys] = &ServantManagerResponder::processGetControllerIconKeys;
m_processFunctions[servantmanager::Message::GetControllerTypesInheritingType] = &ServantManagerResponder::processGetControllerTypesInheritingType;
m_processFunctions[servantmanager::Message::UserLog] = &ServantManagerResponder::processUserLog;
}
......@@ -508,6 +509,23 @@ void ServantManagerResponder::processUserLog(const std::string & message, std::s
responseMessage.SerializeToString(&response);
}
void ServantManagerResponder::processGetControllerTypesInheritingType(const std::string & message, std::string & response) {
servantmanager::GetControllerTypesInheritingTypeRequest messageRequest;
messageRequest.ParseFromString(message);
common::StringArrayResponse responseMessage;
set<string> controllerTypes = Database::getInstance(messageRequest.databaseid())->getControllerTypesInheritingType(messageRequest.type());
for (auto it = controllerTypes.begin(); it != controllerTypes.end(); it++) {
responseMessage.add_value(*it);
}
// Serialize the response.
responseMessage.SerializeToString(&response);
}
void ServantManagerResponder::loop() {
// Initialize the map of functions.
......
......@@ -95,6 +95,8 @@ private:
void processUserLog(const std::string & message, std::string & response);
void processGetControllerTypesInheritingType(const std::string & message, std::string & response);
dataprovider::ServantAccessorDirectImpl* m_servantAccessor;
std::unique_ptr<boost::thread> m_thread;
......
......@@ -2276,6 +2276,23 @@ std::deque<std::string> Database::getControllerTypes(unsigned long controllerID)
}
}
std::set<std::string> Database::getControllerTypesInheritingType(const std::string& type) {
std::set<std::string> result;
for (HashMap<string, deque<string> >::const_iterator i = _controllerTypeInheritance.begin(); i != _controllerTypeInheritance.end(); ++i) {
string servantType = i->first;
deque<string> const & types = i->second;
if (find(types.begin(), types.end(), type) != types.end()) {
result.insert(servantType);
}
}
return result;
}
void Database::setServantFamily(unsigned long servantID, const std::string& familyName, const std::string& subfamilyName) {
try {
......
......@@ -875,6 +875,11 @@ public:
*/
std::deque<std::string> getControllerTypes(unsigned long controllerID);
/**
* Gets the controller types inheriting the type.
*/
std::set<std::string> getControllerTypesInheritingType(const std::string& type);
/**
* Sets the servant family.
*/
......
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