Commit 912e5f86 authored by yannick legoc's avatar yannick legoc

Replaced the call to Database::getPropertyInfoItems by...

Replaced the call to Database::getPropertyInfoItems by Database::getAllPropertyInfoItems in different variables classes of implementation
parent ae51c313
......@@ -623,7 +623,7 @@ double * MathExpression::addValue(const char * valueName, void * pUserData) {
string controllerType = DataAccess::getInstance()->getControllerType(databaseID, servantID);
// Get the property infos.
vector<DataAccess::PropertyInfoItem> items = DataAccess::getInstance()->getPropertyInfoItems(databaseID, controllerType);
vector<DataAccess::PropertyInfoItem> items = DataAccess::getInstance()->getAllPropertyInfoItems(databaseID, controllerType);
string propertyName = variableInfos.name;
......@@ -666,7 +666,7 @@ double * MathExpression::addValue(const char * valueName, void * pUserData) {
string controllerType = DataAccess::getInstance()->getControllerType(databaseID, servantID);
// Get the property infos.
vector<DataAccess::PropertyInfoItem> items = DataAccess::getInstance()->getPropertyInfoItems(databaseID, controllerType);
vector<DataAccess::PropertyInfoItem> items = DataAccess::getInstance()->getAllPropertyInfoItems(databaseID, controllerType);
// Test if is a dynamic property.
unsigned long propertyID = 0;
......
......@@ -81,7 +81,7 @@ std::string MathExpressionRenamer::getNewVariableName(const std::string& variabl
unsigned long dynamicPropertyID = DataAccess::getInstance()->getPropertyID(0, servantID, variableInfos.name);
// Get the property infos.
vector<DataAccess::PropertyInfoItem> items = DataAccess::getInstance()->getPropertyInfoItems(0, controllerType);
vector<DataAccess::PropertyInfoItem> items = DataAccess::getInstance()->getAllPropertyInfoItems(0, controllerType);
// Look for the existence of an alias.
// If the alias is not found, then take the property as is.
......@@ -109,7 +109,7 @@ std::string MathExpressionRenamer::getNewVariableName(const std::string& variabl
}
else {
// Get the property infos.
vector<DataAccess::PropertyInfoItem> items = DataAccess::getInstance()->getPropertyInfoItems(0, controllerType);
vector<DataAccess::PropertyInfoItem> items = DataAccess::getInstance()->getAllPropertyInfoItems(0, controllerType);
// Look for the existence of an alias.
// If the alias is not found, then take the property as is.
......
......@@ -130,7 +130,7 @@ DataAccess::PropertyInfo DataAccess::getPropertyInfo(unsigned long databaseID, c
string propertyName = _propertyAccessor->getPropertyName(databaseID, propertyID);
info.aliasPropertyName = propertyName;
vector<Database::PropertyInfoItem> items = _propertyAccessor->getPropertyInfoItems(databaseID, controllerType);
vector<Database::PropertyInfoItem> items = _propertyAccessor->getAllPropertyInfoItems(databaseID, controllerType);
for (auto item : items) {
......@@ -255,6 +255,27 @@ std::vector<DataAccess::PropertyInfoItem> DataAccess::getPropertyInfoItems(unsig
return result;
}
std::vector<DataAccess::PropertyInfoItem> DataAccess::getAllPropertyInfoItems(unsigned long databaseID, const std::string& controllerType) {
vector<PropertyInfoItem> result;
vector<Database::PropertyInfoItem> items = _propertyAccessor->getAllPropertyInfoItems(databaseID, controllerType);
for (auto i : items) {
PropertyInfoItem item;
item.actualPropertyName = i.actualPropertyName;
item.setpointPropertyName = i.setpointPropertyName;
item.offsetPropertyName = i.offsetPropertyName;
item.aliasPropertyName = i.aliasPropertyName;
item.isScan = i.isScan;
item.isSpy = i.isSpy;
item.isDynamic = i.isDynamic;
result.push_back(item);
}
return result;
}
unsigned long DataAccess::getEnumeratedValues(unsigned long databaseID, unsigned long propertyID) {
return _propertyAccessor->getEnumeratedValues(databaseID, propertyID);
......
......@@ -264,6 +264,11 @@ public :
*/
std::vector<PropertyInfoItem> getPropertyInfoItems(unsigned long databaseID, const std::string& controllerType);
/**
* Gets the property info items.
*/
std::vector<PropertyInfoItem> getAllPropertyInfoItems(unsigned long databaseID, const std::string& controllerType);
/**
* Gets the enumerated values.
*/
......
......@@ -3680,6 +3680,42 @@ std::vector<Database::PropertyInfoItem> Database::getPropertyInfoItems(const std
return result;
}
std::vector<Database::PropertyInfoItem> Database::getAllPropertyInfoItems(const std::string & servantType) const {
vector<PropertyInfoItem> result;
if (_controllerTypeInheritance.find(servantType)) {
deque<string> types = _controllerTypeInheritance.get(servantType);
if (types.front() != servantType) {
types.push_front(servantType);
}
for (deque<string>::const_iterator t = types.begin(); t != types.end(); ++t) {
const string& inheritedType = *t;
// Iterate on setpoint properties.
for (auto p = _setpointPropertyInfoMap.begin(); p != _setpointPropertyInfoMap.end(); p++) {
if (p->first.controllerType == inheritedType) {
result.push_back(p->second);
}
}
// Iterate on no setpoint properties.
for (auto p = _noSetpointPropertyInfoMap.begin(); p != _noSetpointPropertyInfoMap.end(); p++) {
if (p->first.controllerType == inheritedType) {
result.push_back(p->second);
}
}
}
}
return result;
}
void Database::addPropertyInfoItem(const std::string & servantType, const std::string & setpointPropertyName, const std::string & actualPropertyName, const std::string & offsetPropertyName, const std::string & aliasPropertyName, bool isScan, bool isSpy, bool isDynamic) {
// We separate between setpoint properties and no setpoint properties.
......
......@@ -1223,10 +1223,14 @@ public:
/**
* Gets the property info items.
* first : wanted property name
*/
std::vector<PropertyInfoItem> getPropertyInfoItems(const std::string & servantType) const;
/**
* Gets all the property info items including the inherited ones.
*/
std::vector<PropertyInfoItem> getAllPropertyInfoItems(const std::string & servantType) const;
/**
* Adds the property info item.
*/
......
......@@ -545,6 +545,10 @@ std::vector<Database::PropertyInfoItem> PropertyAccessorDirectImpl::getPropertyI
return Database::getInstance(databaseID)->getPropertyInfoItems(controllerType);
}
std::vector<Database::PropertyInfoItem> PropertyAccessorDirectImpl::getAllPropertyInfoItems(unsigned long databaseID, const std::string & controllerType) const {
return Database::getInstance(databaseID)->getAllPropertyInfoItems(controllerType);
}
void PropertyAccessorDirectImpl::addPropertyInfoItem(unsigned long databaseID, const std::string & controllerType, const std::string & wantedPropertyName, const std::string & actualPropertyName, const std::string & offsetPropertyName, const std::string & shortPropertyName, bool isScan, bool isSpy, bool isDynamic) {
Database::getInstance(databaseID)->addPropertyInfoItem(controllerType, wantedPropertyName, actualPropertyName, offsetPropertyName, shortPropertyName, isScan, isSpy, isDynamic);
}
......
......@@ -377,6 +377,12 @@ public:
*/
std::vector<Database::PropertyInfoItem> getPropertyInfoItems(unsigned long databaseID, const std::string & controllerType) const;
/**
* Gets the property infos.
* throw NoSuchPropertyException
*/
std::vector<Database::PropertyInfoItem> getAllPropertyInfoItems(unsigned long databaseID, const std::string & controllerType) const;
/**
* Adds the property info.
*/
......
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