00001 // ***************************************************************************** 00002 // ***************************************************************************** 00003 // oaObserver.h 00004 // 00005 // This file contains the definition for the oaBaseObserver class. This is an 00006 // abstract class used as the base for all types of observers in OpenAccess. 00007 // Capabilities it supports includes: 00008 // 00009 // 1) Observers can be enabled or disabled as desired. Disabled observers are 00010 // not called. 00011 // 2) Observers are ordered by priority. Observers with higher priority (i.e. 00012 // lower priority numbers) are called first. 00013 // 00014 // oaBaseObserver 00015 // This is the base class for the following template classes which support 00016 // observer signatures for OpenAccess. 00017 // 00018 // oaStdObserver<> 00019 // This class, in turn, is the base class for the oaVersionedObserver<> 00020 // template class definition and several specializations of 00021 // oaVersionedObserver<>. This class covers the postCreate, preDestroy, 00022 // preModify, and postModify signatures. 00023 // 00024 // oaVersionedObserver<T, rev> 00025 // This class supports the multiple versions of observer signatures which 00026 // have been added. Applications can instantiate one of the following two 00027 // revisions which select appropriate observer version. Version 1 00028 // corresponds to the oaStdObserver<> signatures and is the current default. 00029 // Version 2 adds the scoped notification signatures onBeginCreate, 00030 // onEndCreate, onBeginDestroy, and onEndDestory. Selection of the 00031 // revision should be done using oaRevisionTraits<T>. 00032 // 00033 // 00034 // ***************************************************************************** 00035 // Except as specified in the OpenAccess terms of use of Cadence or Silicon 00036 // Integration Initiative, this material may not be copied, modified, 00037 // re-published, uploaded, executed, or distributed in any way, in any medium, 00038 // in whole or in part, without prior written permission from Cadence. 00039 // 00040 // Copyright 2002-2008 Cadence Design Systems, Inc. 00041 // All Rights Reserved. 00042 // 00043 // $Author: dell $ 00044 // $Revision: #9 $ 00045 // $Date: 2008/05/30 $ 00046 // $State: Exp $ 00047 // ***************************************************************************** 00048 // ***************************************************************************** 00049 00050 00051 00052 #if !defined(oaObserver_P) 00053 #define oaObserver_P 00054 00055 00056 00057 // ***************************************************************************** 00058 // Nested includes 00059 // ***************************************************************************** 00060 #include "oaBaseTypes.h" 00061 #include "oaRevisionTraits.h" 00062 #include "oaObject.h" 00063 00064 00065 // ***************************************************************************** 00066 // Declare and define types in the OpenAccess namespace. 00067 // ***************************************************************************** 00068 BEGIN_OA_NAMESPACE 00069 00070 00071 00072 // ***************************************************************************** 00073 // oaBaseObserver 00074 // ***************************************************************************** 00075 class OA_BASE_DLL_API oaBaseObserver { 00076 public: 00077 oaBaseObserver(oaUInt4 priorityIn, 00078 oaBoolean enabledIn = true); 00079 virtual ~oaBaseObserver(); 00080 00081 oaBoolean isEnabled() const; 00082 00083 void enable(oaBoolean enabledIn); 00084 00085 protected: 00086 oaBoolean enabled; 00087 oaUInt4 priority; 00088 }; 00089 00090 00091 00092 // ***************************************************************************** 00093 // oaStdObserver<> 00094 // ***************************************************************************** 00095 template <class T, typename D> 00096 class oaStdObserver : public oaBaseObserver { 00097 public: 00098 oaStdObserver(oaUInt4 priorityIn, 00099 oaBoolean enabledIn = true); 00100 virtual ~oaStdObserver(); 00101 00102 virtual void onPostCreate(T *object); 00103 virtual void onPreDestroy(T *object); 00104 virtual void onPreModify(T *object, 00105 D modType); 00106 virtual void onPostModify(T *object, 00107 D modType); 00108 00109 static oaBoolean hasObservers(); 00110 static void notifyPostCreateObservers(T *object); 00111 static void notifyPreDestroyObservers(T *object); 00112 static void notifyPreModifyObservers(T *object, 00113 D modType); 00114 static void notifyPostModifyObservers(T *object, 00115 D modType); 00116 00117 protected: 00118 oaStdObserver<T, D> *next; 00119 00120 static oaStdObserver<T, D> *first; 00121 }; 00122 00123 00124 00125 // ***************************************************************************** 00126 // oaObserver 00127 // ***************************************************************************** 00128 #if !defined(oaObserver) 00129 #define oaObserver oaVersionedObserver 00130 #endif 00131 00132 00133 // ***************************************************************************** 00134 // oaVersionedObserver 00135 // ***************************************************************************** 00136 template <class T, oaUInt4 rev = (oaUInt4) oaRevisionTraits<T>::observerRevision> 00137 class oaVersionedObserver : public oaStdObserver<T, typename oaTraits<T>::modTypeType> { 00138 public: 00139 oaVersionedObserver(oaUInt4 priorityIn, 00140 oaBoolean enabledIn = true); 00141 }; 00142 // <JR> Adding correct class name per Dell "oaVersionedObserver<T, V>" 00143 template <class T> 00144 class oaVersionedObserver<T, V> : public oaStdObserver<T, typename oaTraits<T>::modTypeType> { 00145 public: 00146 oaVersionedObserver(oaUInt4 priorityIn, 00147 oaBoolean enabledIn = true); 00148 virtual ~oaVersionedObserver(); 00149 00150 virtual void onBeginCreate(oaObject *owner, 00151 oaUInt4 scopeID); 00152 virtual void onEndCreate(T *object, 00153 oaUInt4 scopeID); 00154 virtual void onBeginDestroy(T *object, 00155 oaUInt4 scopeID); 00156 virtual void onEndDestroy(oaObject *owner, 00157 oaUInt4 scopeID); 00158 00159 static oaBoolean hasObservers(); 00160 00161 /* <JR> Not needed 00162 static void notifyPreModifyObservers(T *object, 00163 typename oaTraits<T>::modTypeType modType); 00164 static void notifyPostModifyObservers(T *object, 00165 typename oaTraits<T>::modTypeType modType); 00166 static void notifyBeginCreateObservers(oaObject *owner, 00167 oaUInt4 scopeID); 00168 static void notifyEndCreateObservers(T *object, 00169 oaUInt4 scopeID); 00170 static void notifyBeginDestroyObservers(T *object, 00171 oaUInt4 scopeID); 00172 static void notifyEndDestroyObservers(oaObject *owner, 00173 oaUInt4 scopeID); 00174 */ 00175 00176 protected: 00177 oaVersionedObserver<T, oacObserverVersion2> *next; 00178 00179 static oaVersionedObserver<T, oacObserverVersion2> *first; 00180 }; 00181 00182 00183 00184 END_OA_NAMESPACE 00185 00186 #endif
Copyright © 2002 - 2010 Cadence Design Systems, Inc.
All Rights Reserved.