Here is how my code basically looks. The properties are declared as public members of CMyClass. Hence anyone instantiating it could access it. However the property itself is initialized as a read-only property. I was expecting CAnotherClass::SomeFunction() to fail because it is attempting to modify a read-only property of another class and CMyClass::Reset() to succeed since the m_propA is a member of the same class. However both functions are executing without throwing any Glib error into the console.
class CMyClass: public Glib::Object
{
public:
CMyClass();
~CMyClass();
Glib::Property<int> m_propA;
void Reset();
private:
void PropertyChanged(const Glib::ustring & sPropertyName);
}
CMyClass::CMyClass():
Glib::ObjectBase(typeid(CMyClass)),
m_propA(*this,
"p0904",
"<some nick name>",
"<some property description",
Glib::PARAM_READABLE)
{
}
void CMyClass::Reset()
{
m_propA().set_value(5);
}
class CAnotherClass
{
public:
CAnotherClass();
~CAnotherClass();
private:
void SomeFunction();
CMyClass m_oPropClass;
}
void CAnotherClass::SomeFunction()
{
m_oPropClass.m_propA().set_value(10);
}
The second question: The example above has just one property whereas my actual code will above about 300 properties. The class that owns these properties are required to monitor any changes in these properties and communicate it to a remote device via serial interface. Now I could get the PropertyProxy reference for each of these properties and sigc::bind it to the function CMyClass::PropertyChanged but that doesn't sound logical. The glib API reference I mentioned earlier was talking about a notify signal that is called on the owner of the properties (automatically I gather) when the set_value of any of it's properties are called, or at least that's what I understood. Is this true? Is thre a way for the owner to be notified automatically?