|
// Notifications interface added to Serialiasable Generic Objects
#ifndef NOTIFSERIALGENOBJ_H
#define NOTIFSERIALGENOBJ_H
/* disable MSVC warnings about STL in debug mode */
#if _MSC_VER > 1000
#pragma warning (disable: 4786)
#pragma warning (disable: 4748)
#pragma warning (disable: 4103)
#endif /* _MSC_VER > 1000 */
#include "SerialGenObj.h"
// Class
#define NOTIFSERIALGENOBJ_CLASSNAME _T("CNotifSerialGenObj")
// messages
#include "GenObjectMsgCodes.h"
// Attribute names
#define IDC_DEROBJ_ATTRNAME_address _T("address")
#define IDC_DEROBJ_ATTRNAME_bool _T("bool")
// an observer object
class sObserverListObj {
public:
CWnd *pObj;
UINT msgId;
WPARAM code;
sObserverListObj() { pObj=NULL; msgId=0; code=0; };
~sObserverListObj() {};
};
// the observer list
typedef list<sObserverListObj*> DefRegisteredObj;
class CNotifSerialGenObj : public CSerialGenObj
{
public:
CNotifSerialGenObj(void);
CNotifSerialGenObj( const CNotifSerialGenObj& ObjSrc );
const CNotifSerialGenObj& operator=(CNotifSerialGenObj const& ObjSrc);
virtual ~CNotifSerialGenObj(void);
private:
void BuildSpecificCopy( const CNotifSerialGenObj& ObjSrc );
protected:
// Notifications interface:
public:
bool RegisterObserver(CWnd *pWnd, UINT nMsgId, WPARAM nCode = 0x0);
bool UnRegisterObserver(CWnd *pWnd);
void NotifyOutOfSyncAll(CNotifSerialGenObj* pObjToSend = NULL);
void NotifySpecificObserverOutOfSync(CWnd *pObj, CNotifSerialGenObj* pObjToSend = NULL);
void NotifySpecificMessageOutOfSync (UINT nMsgId,CNotifSerialGenObj* pObjToSend = NULL);
bool NotifyInSyncAll(CNotifSerialGenObj* pObjToSend = NULL);
bool NotifySpecificObserverInSync(CWnd *pObj, CNotifSerialGenObj* pObjToSend = NULL);
bool NotifySpecificMessageInSync (UINT nMsgId,CNotifSerialGenObj* pObjToSend = NULL);
protected:
bool IsAlreadyRegisteredObj(sObserverListObj* sTest);
public:
// overrides
virtual bool Execute(void) { return true; };
protected:
// Registered Object List for observer pattern
DefRegisteredObj m_RegisteredObjList;
};
#endif /* !defined (NOTIFSERIALGENOBJ_H) */
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Senior Software Developer in C/C++ and Oracle.
Ex-physicist holding a Ph.D. on x-ray lasers.