51 #ifndef __HelperInterface__ 52 #define __HelperInterface__ 54 #include "InterfaceFactory.h" 55 #include "IPMPersist.h" 56 #include "PersistUtils.h" 57 #include "IViewObjectChanges.h" 58 #include "IControllingUnknown.h" 59 #include "DBChangesMonitorDisabler.h" 70 friend class ObjectModelBase;
76 fInterfaceRefCount(0),
88 if (interfaceID == IID_IINTERFACEREFCOUNT)
91 if (interfaceID == IID_ICONTROLLINGUNKNOWN && fBoss)
108 fInterfaceRefCount++;
122 fInterfaceRefCount--;
150 mutable size_t fInterfaceRefCount;
161 IPMUnknown *QueryInterface(PMIID interfaceID) const; \ 162 void AddRef() const; \ 163 void Release() const; \ 164 void PreDirty(ImplementationID prop = kInvalidImpl, bool16 allowModification = kTrue); \ 165 void PreDirtyNoMessage(ImplementationID prop = kInvalidImpl, bool16 allowModification = kTrue); \ 167 HelperInterface fHelperInterface; 169 #define DECLARE_VIEW_HELPER_METHODS() \ 174 void* fViewIFaceConsistencyChecker;\ 177 #define DECLARE_PERSIST_DONTSNAPHOT_HELPER_METHODS() \ 182 void* fDontSnapshotIFaceConsistencyChecker;\ 191 #define DEFINE_BASIC_HELPER_METHODS(cn) \ 192 IPMUnknown * cn::QueryInterface( PMIID interfaceID) const \ 193 {return fHelperInterface.QueryInterface(interfaceID); } \ 194 void cn::AddRef() const \ 195 { fHelperInterface.AddRef(); } \ 196 void cn::Release() const\ 197 { fHelperInterface.Release(); } 199 #define DEFINE_BASIC_HELPER_METHODS(cn) \ 200 IPMUnknown * cn::QueryInterface( PMIID interfaceID) const \ 202 if (interfaceID == IID_IGETINTERFACEIMPL) \ 203 {return const_cast<cn*>(this);} \ 204 return fHelperInterface.QueryInterface(interfaceID); \ 206 void cn::AddRef() const \ 207 { fHelperInterface.AddRef(); } \ 208 void cn::Release() const \ 209 { fHelperInterface.Release(); } 212 #define DEFINE_HELPER_METHODS(cn) \ 213 DEFINE_BASIC_HELPER_METHODS(cn)\ 214 void cn::PreDirty(ImplementationID prop, bool16 allowModification) \ 215 { ::PreDirty(fHelperInterface.GetBoss(), this, prop, allowModification); } \ 216 void cn::PreDirtyNoMessage(ImplementationID prop, bool16 allowModification) \ 217 { ::PreDirtyNoMessage(fHelperInterface.GetBoss(), this, prop, allowModification); } 219 #define DEFINE_VIEW_HELPER_METHODS(cn) \ 220 DEFINE_BASIC_HELPER_METHODS(cn)\ 221 void cn::PreDirty(ImplementationID prop, bool16 allowModification) \ 223 InterfacePtr<IViewObjectChanges>viewObjectChanges (this, UseDefaultIID());\ 224 if (viewObjectChanges)\ 225 viewObjectChanges->SetDirty(fHelperInterface.GetBoss(), this, prop, allowModification);\ 227 void cn::PreDirtyNoMessage(ImplementationID prop, bool16 allowModification) \ 228 { ASSERT_FAIL("Not appropriate for ViewInterfaces"); } 230 #define DEFINE_PERSIST_DONTSNAPHOT_HELPER_METHODS(cn) \ 231 DEFINE_BASIC_HELPER_METHODS(cn)\ 232 void cn::PreDirty(ImplementationID prop, bool16 allowModification) \ 234 IDataBase* db = ::GetDataBase(fHelperInterface.GetBoss());\ 235 DBChangesMonitorDisabler disabler(db);\ 236 ::PreDirty(fHelperInterface.GetBoss(), this, prop, allowModification); \ 238 void cn::PreDirtyNoMessage(ImplementationID prop, bool16 allowModification) \ 240 IDataBase* db = ::GetDataBase(fHelperInterface.GetBoss());\ 241 DBChangesMonitorDisabler disabler(db);\ 242 ::PreDirtyNoMessage(fHelperInterface.GetBoss(), this, prop, allowModification);\ 248 #define HELPER_METHODS_INIT(boss) fHelperInterface(boss) 252 #define DONTSNAPSHOT_HELPER_METHODS_INIT(boss) HELPER_METHODS_INIT(boss), fDontSnapshotIFaceConsistencyChecker(nil) 254 #endif // __HelperInterface__