Property library

Added by Kirill Lepski over 5 years ago

Library for management of "attributable" objects was added. Now you can easy create standard implementations of persistent objects. By example an implementation of a simple model interface could be:

class MyModelImpl: public IMyModel, public iprop::CPropiertiesManager{
public:
    // In constructor you must initialize each attribute: 
    MyModelImpl()
       :m_parameter(this, "MyParameter", "Parameter description", CF_MY_PARAMETER_CHANGE, 77) // attribute owner, ID of the attribute, attribute description, change notification flags, default value
    {
    }

    // reimplemented (IMyModel)
    virtual int GetParameter() const
    {
        return m_parameter.GetValue();
    }

    virtual void SetParameter(int value)
    {
        parameter.SetValue(value);
    }

private:
    iprop::CIntProperty m_parameter;
};

iprop::CPropiertiesManager implements model update notification for all attributes used in your implementation and persistence of your object.


Comments

Added by Kirill Lepski over 5 years ago

Now it is possible to set the attributes flags. By example you can set AF_PERSISTENT value, to signalize that the attribute must be made persistent:

class MyModelImpl: public IMyModel, public iattr::CAttributedObject {
public:
// In constructor you must initialize each attribute:
MyModelImpl()
:m_parameter(this, "MyParameter", "Parameter description", iattr:IAttribute::AF_PERSISTENT, CF_MY_PARAMETER_CHANGE, 77) // attribute owner, ID of the attribute, attribute description, flags, change notification flags, default value {
}

// reimplemented (IMyModel)
virtual int GetParameter() const {
return m_parameter.GetValue();
}
virtual void SetParameter(int value)
{
parameter.SetValue(value);
}

private:
iattr::CIntAttribute m_parameter;
};