Re: Glib::Property and read / write settings



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?




Please consider the Environment before printing this e-mail.

The information contained in this message (including any attachments) is confidential and may be privileged or otherwise protected from disclosure.  If you are not the intended recipient, you must not copy this message or attachment or disclose the contents to any other person.  If you have received this transmission in error, please notify the sender immediately by return e-mail and permanently delete this message and any attachments from your system.  Any dissemination, use, review, distribution, printing or copying of this message in whole or in part is strictly prohibited.  Please note that e-mails are susceptible to change.
 
SKANRAY(including its group of companies) shall not be liable for any omission or error in the message, improper or incomplete transmission of the information contained in this communication or for any delay in its receipt or damage to your system.  SKANRAY(or its group of companies) does not guarantee that the integrity of this communication has been maintained or that this communication is free of viruses, interceptions or interference.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]