Commit 3ccaf769 authored by legoc's avatar legoc

Added enumerated values and labels at the dynamic property level

parent 74f91790
......@@ -3809,7 +3809,7 @@ void Database::setEnumeratedValuesProperty(unsigned long propertyID, unsigned lo
// sets the property
ScopedLock lock(_lockManager->lockPropertyForWriting(propertyID, common::eol));
BaseElementaryProperty * property = dynamic_cast<BaseElementaryProperty *>(getPropertyFromKeyID(propertyID));
BaseProperty * property = getPropertyFromKeyID(propertyID);
if (property == 0) {
throw BadPropertyTypeException(propertyID, "?", property->getType());
......@@ -3823,7 +3823,7 @@ void Database::setEnumeratedLabelsProperty(unsigned long propertyID, unsigned lo
// sets the property
ScopedLock lock(_lockManager->lockPropertyForWriting(propertyID, common::eol));
BaseElementaryProperty * property = dynamic_cast<BaseElementaryProperty *>(getPropertyFromKeyID(propertyID));
BaseProperty * property = getPropertyFromKeyID(propertyID);
if (property == 0) {
throw BadPropertyTypeException(propertyID, "?", property->getType());
......
......@@ -629,3 +629,11 @@ std::map<std::string, std::string> PropertyManager::getAliasPropertyMap() const
void PropertyManager::sendArrayEvent(const std::string& propertyName) {
getProperty(propertyName)->update();
}
void PropertyManager::setEnumeratedValues(unsigned long propertyID, unsigned long valuesPropertyID) const {
_propertyAccessor->setEnumeratedValues(propertyID, valuesPropertyID);
}
void PropertyManager::setEnumeratedLabels(unsigned long propertyID, unsigned long labelsPropertyID) const {
_propertyAccessor->setEnumeratedLabels(propertyID, labelsPropertyID);
}
......@@ -122,6 +122,16 @@ public:
*/
static DynamicPropertyInfo getDynamicPropertyInfo(const std::string& propertyName);
/**
* Sets the enumerated values property.
*/
void setEnumeratedValues(unsigned long propertyID, unsigned long valuesPropertyID) const;
/**
* Sets the enumerated labels property.
*/
void setEnumeratedLabels(unsigned long propertyID, unsigned long labelsPropertyID) const;
private:
void createProperties(const std::string & servantType, const std::vector<PropertyDescription*>& description);
......
......@@ -35,6 +35,7 @@ public:
using ValueDynamicProperty<Type>::m_enumeratedValuesID;
using ValueDynamicProperty<Type>::m_enumeratedLabelsID;
using ValueDynamicProperty<Type>::m_size;
using ValueDynamicProperty<Type>::m_ID;
using BaseDynamicProperty::m_propertyManager;
using BaseDynamicProperty::m_name;
using BaseDynamicProperty::m_logLevel;
......@@ -183,7 +184,10 @@ void DynamicProperty<Type>::setEnumeratedValues(const DynamicProperty<Type>& val
m_enumeratedValuesID = valuesProperty.getID();
// set all the properties
// Set the dynamic property.
m_propertyManager->setEnumeratedValues(m_ID, m_enumeratedValuesID);
// Set all the properties.
for (int32 i = 0; i < m_size; ++i) {
AnyProperty * property = m_propertyManager->getProperty(propertyNameAtIndex(m_name, i));
property->setEnumeratedValues(m_enumeratedValuesID);
......@@ -195,7 +199,10 @@ void DynamicProperty<Type>::setEnumeratedLabels(const DynamicProperty<std::strin
m_enumeratedLabelsID = labelsProperty.getID();
// set all the properties
// Set the dynamic property.
m_propertyManager->setEnumeratedValues(m_ID, m_enumeratedLabelsID);
// Set all the properties.
for (int32 i = 0; i < m_size; ++i) {
AnyProperty * property = m_propertyManager->getProperty(propertyNameAtIndex(m_name, i));
property->setEnumeratedLabels(m_enumeratedLabelsID);
......
......@@ -34,6 +34,7 @@ public:
using ValueDynamicProperty2<Type>::m_enumeratedValuesID;
using ValueDynamicProperty2<Type>::m_enumeratedLabelsID;
using ValueDynamicProperty2<Type>::m_size;
using ValueDynamicProperty2<Type>::m_ID;
using BaseDynamicProperty::m_propertyManager;
using BaseDynamicProperty::m_name;
using BaseDynamicProperty::m_logLevel;
......@@ -185,7 +186,10 @@ void DynamicProperty2<Type>::setEnumeratedValues(const DynamicProperty<Type>& va
m_enumeratedValuesID = valuesProperty.getID();
// set all the properties
// Set the dynamic property.
m_propertyManager->setEnumeratedValues(m_ID, m_enumeratedValuesID);
// Set all the properties.
int32 size1 = getSize();
for (int32 i = 0; i < size1; ++i) {
int32 size2 = getSize(i);
......@@ -201,7 +205,10 @@ void DynamicProperty2<Type>::setEnumeratedLabels(const DynamicProperty<std::stri
m_enumeratedLabelsID = labelsProperty.getID();
// set all the properties
// Set the dynamic property.
m_propertyManager->setEnumeratedValues(m_ID, m_enumeratedLabelsID);
// Set all the properties.
int32 size1 = getSize();
for (int32 i = 0; i < size1; ++i) {
int32 size2 = getSize(i);
......
......@@ -63,8 +63,7 @@ public:
m_fromType = ServantType::TYPE;
m_servantProperty = new ServantDynamicProperty<ServantType, Type>(servant, name);
// no need to get the ID, the model must be different if we want to implement
// the enumerated values
m_ID = servant->getPropertyManager()->addDynamicProperty(name, PropertyTypeToString<Type>::value);
m_unitValue = "";
m_unitPropertyID = 0;
m_enumeratedValuesID = 0;
......@@ -84,8 +83,7 @@ public:
m_size = property.m_size;
m_fromType = property.m_fromType;
m_servantProperty = new ServantDynamicProperty<ServantType, Type>(servant, property.m_name);
// no need to get the ID, the model must be different if we want to implement
// the enumerated values
m_ID = servant->getPropertyManager()->addDynamicProperty(m_name, PropertyTypeToString<Type>::value);
m_unitValue = property.m_unitValue;
m_unitPropertyID = property.m_unitPropertyID;
m_enumeratedValuesID = property.m_enumeratedValuesID;
......
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