GME
13
|
00001 // MgaContext.h: interface for the CMgaContext class. 00002 // 00004 00005 #if !defined(AFX_MGACONTEXT_H__48B8CD86_FF78_4183_8360_D33CE1792CD7__INCLUDED_) 00006 #define AFX_MGACONTEXT_H__48B8CD86_FF78_4183_8360_D33CE1792CD7__INCLUDED_ 00007 00008 #if _MSC_VER > 1000 00009 #pragma once 00010 #endif // _MSC_VER > 1000 00011 00012 00013 00014 class CMgaContext 00015 { 00016 friend class CCurrentProject; 00017 00018 int m_nPendingTransactions; 00019 void SetTransactionState(int nValue); 00020 public: 00021 void SetEventTransactionMode(bool bOnOff); 00022 00023 CComPtr<IMgaProject> m_ccpProject; 00024 CComPtr<IMgaTerritory> m_ccpTerritory; 00025 00026 00027 void CreateContext(IMgaEventSink& rMgaEventSink,LPUNKNOWN pMgaProject); 00028 void CloseContext(); 00029 CComPtr<IMgaComponentEx> FindConstraintManager(); 00030 00031 bool AbortTransaction(); 00032 bool CommitTransaction(); 00033 bool BeginTransaction(bool bIsReadOnly = true); 00034 bool BeginTransaction(transactiontype_enum type); 00035 bool IsInTransaction(); 00036 CMgaContext(); 00037 virtual ~CMgaContext(); 00038 00039 private: 00040 bool m_bEventTransactionMode; 00041 }; 00042 00043 class Utils 00044 { 00045 public: 00046 static CComPtr<IGMEOLEApp> get_GME( CComPtr<IMgaProject> p_mgaproject) 00047 { 00048 CComPtr<IGMEOLEApp> gme; 00049 if( p_mgaproject) { 00050 CComBSTR bstrName("GME.Application"); 00051 CComPtr<IMgaClient> pClient; 00052 HRESULT hr = p_mgaproject->GetClientByName(bstrName, &pClient); 00053 if (SUCCEEDED(hr) && pClient) { 00054 CComPtr<IDispatch> pDispatch; 00055 hr = pClient->get_OLEServer(&pDispatch); 00056 if (SUCCEEDED(hr) && pDispatch) { 00057 hr = pDispatch.QueryInterface(&gme); 00058 if (FAILED(hr)) { 00059 gme = NULL; 00060 } 00061 } 00062 } 00063 } 00064 return gme; 00065 } 00066 00067 static void put2Console( CComPtr<IGMEOLEApp> gme, CComBSTR msg, msgtype_enum typ) 00068 { 00069 if(gme) 00070 gme->ConsoleMessage( msg, typ); 00071 } 00072 }; 00073 00074 #endif // !defined(AFX_MGACONTEXT_H__48B8CD86_FF78_4183_8360_D33CE1792CD7__INCLUDED_)