class CMyClass : public Dapfor::Common::CDataObject
{
public:
enum
{
FidPrice,
...
};
public:
double GetPrice() const;
...
void SetPrice(double newPrice);
...
private:
double m_Price;
...
mutable Dapfor::Common::CSyncObject m_Sync;
DF_DECLARE_FIELD_MAP();
};
DF_BEGIN_FIELD_MAP(CMyClass)
DF_DOUBLE_ID(FidPrice, "Price", &CMyClass::GetPrice, &CMyClass::SetPrice, 0)
...
DF_END_FIELD_MAP()
double CMyClass::GetPrice() const
{
Dapfor::Common::CLock lock(m_Sync);
return m_Price;
}
...
void CMyClass::SetPrice(double newPrice)
{
bool sendNotification = false;
{
Dapfor::Common::CLock lock(m_Sync);
if(m_Price != newPrice)
{
m_Price = newPrice;
sendNotification = true;
}
}
if(sendNotification)
{
NotifyUpdate(FidPrice);
}
}