OpendTect  6.3
Macros
monitor.h File Reference
Include dependency graph for monitor.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define mImplSimpleMonitoredGet(fnnm, typ, memb)   typ fnnm() const { return getMemberSimple( memb ); }
 Defines simple MT-safe copyable member get. More...
 
#define mImplSimpleMonitoredSet(fnnm, typ, memb, chgtyp)
 Defines simple MT-safe copyable member change. More...
 
#define mImplSimpleMonitoredGetSet(pfx, fnnmget, fnnmset, typ, memb, chgtyp)
 Defines simple MT-safe copyable member access. More...
 
#define mLockMonitorable4Read(obj)   Monitorable::AccessLocker accesslocker_( obj )
 
#define mLockMonitorable4Write(obj)   Monitorable::AccessLocker accesslocker_( obj, false )
 
#define mMonitorableLock2Write(obj)   accesslocker_.convertToWrite()
 
#define mMonitorableReLock(obj)   accesslocker_.reLock()
 
#define mMonitorableUnlockAllAccess(obj)   accesslocker_.unlockNow()
 
#define mMonitorableAccessLocker(obj)   accesslocker_
 
#define mSendMonitorableChgNotif(obj, typ, id)   (obj).sendChgNotif(accesslocker_,typ,id)
 
#define mSendMonitorableEntireObjChgNotif(obj)
 
#define mLock4Read()   mLockMonitorable4Read(*this)
 
#define mLock4Write()   mLockMonitorable4Write(*this)
 
#define mLock2Write()   mMonitorableLock2Write(*this)
 
#define mReLock()   mMonitorableReLock(*this)
 
#define mUnlockAllAccess()   mMonitorableUnlockAllAccess(*this)
 
#define mAccessLocker()   mMonitorableAccessLocker(*this)
 
#define mSendChgNotif(typ, id)   mSendMonitorableChgNotif(*this,typ,id)
 
#define mSendEntireObjChgNotif()   mSendMonitorableEntireObjChgNotif(*this)
 
#define mDeclGenMonitorableAssignment(clss)
 
#define mDeclAbstractMonitorableAssignment(clss)   mDeclGenMonitorableAssignment(clss)
 Monitorable subclasses: assignment and comparison. More...
 
#define mDeclMonitorableAssignment(clss)
 like mDeclAbstractMonitorableAssignment but for non-abstract subclasses. Implements the clone() method. More...
 
#define mImplEmptyMonitorableCopyClassData(clssnm)
 
#define mImplAlwaysDifferentMonitorableCompareClassData(clssnm)
 
#define mImplEmptyMonitorableCompare(clssnm)
 
#define mGenImplMonitorableAssignment(pfx, clss, baseclss)
 Implementation of assignment and comparison methods for Monitorable's. More...
 
#define mImplMonitorableAssignment(clss, baseclss)   mGenImplMonitorableAssignment(,clss,baseclss)
 
#define mImplMonitorableAssignmentWithNoMembers(clss, baseclss)
 
#define mStartMonitorableCompare()   ChangeType chgtype = cNoChange()
 Helper macro to easily implement your compareClassData() in standard situations. More...
 
#define mHandleMonitorableCompare(memb, val)
 
#define mHandleMonitorableComparePtrContents(memb, val)
 
#define mDeliverMonitorableCompare()   return chgtype;
 
#define mDeliverSingCondMonitorableCompare(nochgcond, chgtype)   return (nochgcond) ? cNoChange() : chgtype
 Helper macro to implement a simple yes/no change compareClassData() More...
 
#define mDeliverYesNoMonitorableCompare(nochgcond)   mDeliverSingCondMonitorableCompare( nochgcond, cEntireObjectChange() )
 Helper macro to implement a simple yes/no change compareClassData() More...
 

Macro Definition Documentation

#define mAccessLocker ( )    mMonitorableAccessLocker(*this)
#define mDeclAbstractMonitorableAssignment (   clss)    mDeclGenMonitorableAssignment(clss)

Monitorable subclasses: assignment and comparison.

Declares assignment method that will emit notifications, by default 'Entire Object'. Because of the locking, assignment operators are essential. These will need to copy both the 'own' members aswell as base class members, and emit the notification afterwards. For this, you have to implement a function that copies only the class' own data (unlocked): void copyClassData(const clss&).

To be able to provide more fine-grained notifications than always 'Entire Object Changed', you also have to provide a method compareClassData(). in this way we also define the equality operators (== and !=).

The stuff with clone() vs getClone() is because of Windows, and my obsession to make clone() return a pointer to the actual class.

#define mDeclGenMonitorableAssignment (   clss)
Value:
private: \
void copyClassData(const clss&); \
ChangeType compareClassData(const clss&) const; \
protected: \
void copyAll(const clss&); \
public: \
clss(const clss&); \
clss& operator =(const clss&); \
bool operator ==(const clss&) const; \
inline bool operator !=( const clss& oth ) const \
{ return !(*this == oth); } \
virtual clss* clone() const { return (clss*)getClone(); } \
ChangeType compareWith(const Monitorable&) const
Object that can be MT-safely monitored from cradle to grave.
Definition: monitorable.h:76
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:51
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:60
TypeSetBase< T, int > & operator=(const TypeSetBase< T, int > &ts)
Definition: typeset.h:33
#define mDeclMonitorableAssignment (   clss)
Value:
virtual clss* getClone() const { return new clss( *this ); }
#define mDeclGenMonitorableAssignment(clss)
Definition: monitor.h:71

like mDeclAbstractMonitorableAssignment but for non-abstract subclasses. Implements the clone() method.

#define mDeliverMonitorableCompare ( )    return chgtype;
#define mDeliverSingCondMonitorableCompare (   nochgcond,
  chgtype 
)    return (nochgcond) ? cNoChange() : chgtype

Helper macro to implement a simple yes/no change compareClassData()

#define mDeliverYesNoMonitorableCompare (   nochgcond)    mDeliverSingCondMonitorableCompare( nochgcond, cEntireObjectChange() )

Helper macro to implement a simple yes/no change compareClassData()

#define mGenImplMonitorableAssignment (   pfx,
  clss,
  baseclss 
)

Implementation of assignment and comparison methods for Monitorable's.

you have to implement the copyClassData and compareClassData functions yourself. These functions are calles in a locked state, so do not use locking member functions.

void MyClass::copyClassData( const MyClass& oth ) { x_ = oth.x_; y_ = oth.y_; } bool MyClass::compareClassData( const MyClass& oth ) const { if ( x_ != oth.x_ ) return cXChanged(); if ( y_ != oth.y_ ) return cYChanged(); return cNoChange(); }

For standard situations, there are macros to help you implement the compareClassData function.

Usually, you can use the mImplMonitorableAssignment macro.

#define mHandleMonitorableCompare (   memb,
  val 
)
Value:
if ( !(memb == oth.memb) ) \
{ \
if ( chgtype == cNoChange() || chgtype == val ) \
chgtype = val; \
else \
return cEntireObjectChange(); \
}
#define mHandleMonitorableComparePtrContents (   memb,
  val 
)
Value:
if ( (memb && !oth.memb) || (!memb && oth.memb) || !(*memb == *oth.memb) ) \
{ \
if ( chgtype == cNoChange() || chgtype == val ) \
chgtype = val; \
else \
return cEntireObjectChange(); \
}
#define mImplAlwaysDifferentMonitorableCompareClassData (   clssnm)
Value:
Monitorable::ChangeType clssnm::compareClassData( const clssnm& oth ) const \
{ \
return cEntireObjectChange(); \
}
int ChangeType
Definition: monitorable.h:80
#define mImplEmptyMonitorableCompare (   clssnm)
Value:
Monitorable::ChangeType clssnm::compareClassData( const clssnm& oth ) const \
{ \
return cNoChange(); \
}
int ChangeType
Definition: monitorable.h:80
#define mImplEmptyMonitorableCopyClassData (   clssnm)
Value:
void clssnm::copyClassData( const clssnm& oth ) \
{ \
}
#define mImplMonitorableAssignment (   clss,
  baseclss 
)    mGenImplMonitorableAssignment(,clss,baseclss)
#define mImplMonitorableAssignmentWithNoMembers (   clss,
  baseclss 
)
Value:
mImplEmptyMonitorableCopyClassData( clss ) \
mImplEmptyMonitorableCompare( clss )
#define mImplMonitorableAssignment(clss, baseclss)
Definition: monitor.h:205
#define mImplSimpleMonitoredGet (   fnnm,
  typ,
  memb 
)    typ fnnm() const { return getMemberSimple( memb ); }

Defines simple MT-safe copyable member get.

#define mImplSimpleMonitoredGetSet (   pfx,
  fnnmget,
  fnnmset,
  typ,
  memb,
  chgtyp 
)
Value:
pfx mImplSimpleMonitoredGet(fnnmget,typ,memb) \
pfx mImplSimpleMonitoredSet(fnnmset,const typ&,memb,chgtyp)
#define mImplSimpleMonitoredGet(fnnm, typ, memb)
Defines simple MT-safe copyable member get.
Definition: monitor.h:21
#define mImplSimpleMonitoredSet(fnnm, typ, memb, chgtyp)
Defines simple MT-safe copyable member change.
Definition: monitor.h:26

Defines simple MT-safe copyable member access.

Example:

mImplSimpleMonitoredGetSet( inline, color, setColor, Color, color_, cColorChange() );

#define mImplSimpleMonitoredSet (   fnnm,
  typ,
  memb,
  chgtyp 
)
Value:
void fnnm( typ _set_to_ ) { setMemberSimple( memb, _set_to_, chgtyp, \
cUnspecChgID() ); }

Defines simple MT-safe copyable member change.

#define mLock2Write ( )    mMonitorableLock2Write(*this)
#define mLock4Read ( )    mLockMonitorable4Read(*this)
#define mLock4Write ( )    mLockMonitorable4Write(*this)
#define mLockMonitorable4Read (   obj)    Monitorable::AccessLocker accesslocker_( obj )
#define mLockMonitorable4Write (   obj)    Monitorable::AccessLocker accesslocker_( obj, false )
#define mMonitorableAccessLocker (   obj)    accesslocker_
#define mMonitorableLock2Write (   obj)    accesslocker_.convertToWrite()
#define mMonitorableReLock (   obj)    accesslocker_.reLock()
#define mMonitorableUnlockAllAccess (   obj)    accesslocker_.unlockNow()
#define mReLock ( )    mMonitorableReLock(*this)
#define mSendChgNotif (   typ,
  id 
)    mSendMonitorableChgNotif(*this,typ,id)
#define mSendEntireObjChgNotif ( )    mSendMonitorableEntireObjChgNotif(*this)
#define mSendMonitorableChgNotif (   obj,
  typ,
  id 
)    (obj).sendChgNotif(accesslocker_,typ,id)
#define mSendMonitorableEntireObjChgNotif (   obj)
Value:
static ChangeType cEntireObjectChange()
Definition: monitorable.h:104
#define mSendMonitorableChgNotif(obj, typ, id)
Definition: monitor.h:53
static IDType cEntireObjectChgID()
Definition: monitorable.h:110
#define mStartMonitorableCompare ( )    ChangeType chgtype = cNoChange()

Helper macro to easily implement your compareClassData() in standard situations.

The idea is that a single change type can be returned, if more than one change has happened you need to return cEntireObjectChange().

Example:

Monitorable::ChangeType Well::Info::compareClassData( const Info& oth ) const { mStartMonitorableCompare(); mHandleMonitorableCompare( uwid_, cUWIDChange() ); mHandleMonitorableCompare( oper_, cInfoChange() ); mHandleMonitorableComparePtrContents( a_ptr_, cDataChange() ); mDeliverMonitorableCompare(); }

#define mUnlockAllAccess ( )    mMonitorableUnlockAllAccess(*this)

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2017