Property framework

System to access object properties.

System to access object properties.

Introduction

The property framework introduces the ability to access attributes (member variables) of a class by name without knowing the class type. It's like the reflection mechanism of Java or C#. This ability is introduced by the App::PropertyContainer class and can be used by all derived classes.

This makes it possible in the first place to make an automatic mapping to python (e.g. in App::FeaturePy) and abstract editing properties in Gui::PropertyEditor.

Examples

Here some little examples how to use it:

// search in PropertyList
Property *prop = _pcFeature->getPropertyByName(attr);
if(prop)
{
return prop->getPyObject();
}

or:

void PropertyContainer::Restore(Base::Reader &reader)
{
reader.readElement("Properties");
int Cnt = reader.getAttributeAsInteger("Count");
for(int i=0 ;i<Cnt ;i++)
{
reader.readElement("Property");
string PropName = reader.getAttribute("name");
Property* prop = getPropertyByName(PropName.c_str());
if(prop)
prop->Restore(reader);
reader.readEndElement("Property");
}
reader.readEndElement("Properties");
}