VR-Link API Documentation for DIS
vlDeclNotifier.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 1992-2010 VT MAK
00003 ** All rights reserved.
00004 *********************************************************************/
00008 #pragma once
00009 
00010 #include "vlAbsNotifyObs.h"
00011 
00026 #define DtDECLARE_OBSERVER_NOTIFIER(ClassName)                  \
00027 class DT_DLL_VLUTIL DtObservee;                                 \
00028 class DT_DLL_VLUTIL ClassName##Notifier : public DtAbsNotifyObserver          \
00029 {                                                               \
00030 public:                                                         \
00031                                                                 \
00032    ClassName##Notifier(ClassName* observer);                    \
00033                                                                 \
00034    virtual ~ClassName##Notifier();                              \
00035                                                                 \
00036    ClassName##Notifier(const ClassName##Notifier& orig);        \
00037                                                                 \
00038    ClassName##Notifier& operator=(const ClassName##Notifier& orig); \
00039                                                                 \
00040    virtual bool notifyFromObserved(DtObservee* observed,        \
00041       const DtObservee::DtWhyNotifyObserver& why);              \
00042                                                                 \
00043 protected:                                                      \
00044                                                                 \
00045    ClassName* myObjectToNotify;                                 \
00046                                                                 \
00047 };                                                              \
00048                                                                
00049 
00050 
00056 #define DtDEFINE_OBSERVER_NOTIFIER(ClassName) \
00057 ClassName##Notifier::ClassName##Notifier(ClassName* observer) : \
00058    DtAbsNotifyObserver(),                                       \
00059    myObjectToNotify(observer)                                   \
00060 {                                                               \
00061 }                                                               \
00062                                                                 \
00063 ClassName##Notifier::~ClassName##Notifier()                     \
00064 {                                                               \
00065 }                                                               \
00066                                                                 \
00067 ClassName##Notifier::ClassName##Notifier(                       \
00068    const ClassName##Notifier& orig) :                           \
00069    DtAbsNotifyObserver(orig),                                   \
00070    myObjectToNotify(orig.myObjectToNotify)                      \
00071 {                                                               \
00072 }                                                               \
00073                                                                 \
00074 ClassName##Notifier& ClassName##Notifier::operator=(            \
00075    const ClassName##Notifier& orig)                             \
00076 {                                                               \
00077    if (this == &orig)                                           \
00078    {                                                            \
00079       return *this;                                             \
00080    }                                                            \
00081                                                                 \
00082    DtAbsNotifyObserver::operator=(orig);                        \
00083                                                                 \
00084    myObjectToNotify = orig.myObjectToNotify;                    \
00085                                                                 \
00086    return *this;                                                \
00087 }                                                               \
00088                                                                 \
00089 bool ClassName##Notifier::notifyFromObserved(                   \
00090    DtObservee* observed,                                        \
00091    const DtObservee::DtWhyNotifyObserver& why)                  \
00092 {                                                               \
00093    if (!myObjectToNotify)                                       \
00094    {                                                            \
00095       return false;                                             \
00096    }                                                            \
00097                                                                 \
00098    myObjectToNotify->notifyFromYourObserved(observed, why);     \
00099                                                                 \
00100    return true;                                                 \
00101 }                                                               \
00102 

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)