GME
13
|
00001 // MgaProject.h : Declaration of the CMgaProject 00002 00003 #ifndef __MGAPROJECT_H_ 00004 #define __MGAPROJECT_H_ 00005 00006 #include "resource.h" // main symbols 00007 #include "MgaTrukk.h" 00008 class CMgaTerritory; 00009 class CMgaAddOn; 00010 class CMgaClient; 00011 class FCO; 00012 00013 #include "CommonVersionInfo.h" 00014 00016 // CMgaProject 00017 class ATL_NO_VTABLE CMgaProject : 00018 public CComObjectRootEx<CComSingleThreadModel>, 00019 public CComCoClass<CMgaProject, &__uuidof(MgaProject)>, 00020 public IDispatchImpl<IMgaProject, &__uuidof(IMgaProject), &__uuidof(__MGALib)>, 00021 public ISupportErrorInfoImpl<&__uuidof(IMgaProject)>, 00022 public IGMEVersionInfoImpl 00023 { 00024 00025 DEFSIG; 00026 CComPtr<IUnknown> inner; 00027 CMgaProject *mgaproject; 00028 public: 00029 CMgaProject(); 00030 STDMETHOD(FinalConstruct)(); 00031 00032 ~CMgaProject(); 00033 00034 DECLARE_REGISTRY_RESOURCEID(IDR_MGAPROJECT) 00035 00036 DECLARE_PROTECT_FINAL_CONSTRUCT() 00037 00038 BEGIN_COM_MAP(CMgaProject) 00039 COM_INTERFACE_ENTRY(IMgaProject) 00040 COM_INTERFACE_ENTRY(IDispatch) 00041 COM_INTERFACE_ENTRY_IID(IID_ISupportErrorInfo, IMyErrorInfoBase) 00042 COM_INTERFACE_ENTRY_IID(__uuidof(IGMEVersionInfo), IGMEVersionInfoImpl) 00043 END_COM_MAP() 00044 00045 00046 // IMgaProject 00047 HRESULT CreateSetupData(BSTR rootname, BSTR paradigmname, VARIANT guid); 00048 public: 00049 STDMETHOD(get_MetaObj)( long id, IMgaMetaBase * *pVal); 00050 STDMETHOD(GetMetaObjDisp)( long id, IMgaMetaBase * *pVal) { return get_MetaObj( id, pVal); } 00051 00052 void OpenParadigm(BSTR s, VARIANT *pGUID); 00053 STDMETHOD(OpenParadigm)(BSTR s, BSTR ver); 00054 STDMETHOD(Create)(BSTR projectname, BSTR paradigmname) { return CreateEx(projectname, paradigmname, NULLVARIANT); } 00055 STDMETHOD(CreateEx)(BSTR projectname, BSTR paradigmname, VARIANT parguid); 00056 00057 STDMETHOD(OpenEx)(BSTR projectname, BSTR paradigmname, VARIANT paradigmGUID); 00058 STDMETHOD(Open)(BSTR projectname, VARIANT_BOOL *ro_mode = NULL); 00059 STDMETHOD(Close)(VARIANT_BOOL abort = VARIANT_FALSE); 00060 STDMETHOD(Save)(BSTR name = NULL, VARIANT_BOOL keepoldname = VARIANT_FALSE); 00061 STDMETHOD(put_Preferences)(long prefmask) { preferences = prefmask; return S_OK; }; 00062 STDMETHOD(put_OperationsMask)(long mask) { opmask = mask; return S_OK; }; 00063 STDMETHOD(get_Preferences)(long *prefmask) { 00064 COMTRY { 00065 CHECK_OUTPAR(prefmask); 00066 *prefmask = preferences; 00067 } COMCATCH(;); 00068 }; 00069 STDMETHOD(get_OperationsMask)(long *mask) { 00070 COMTRY { 00071 CHECK_OUTPAR(mask); 00072 *mask = opmask; 00073 } COMCATCH(;); 00074 }; 00075 STDMETHOD(CheckLocks)(BSTR filename, VARIANT_BOOL clearlocks); 00076 00077 STDMETHOD(CreateTerritory)(IMgaEventSink *handler, IMgaTerritory **, IMgaEventSink *h2=NULL); 00078 STDMETHOD(CreateTerritoryWithoutSink)(IMgaTerritory **); 00079 STDMETHOD(CreateAddOn)(IMgaEventSink *handler, IMgaAddOn **); 00080 STDMETHOD(get_ActiveTerritory)(IMgaTerritory **aterr); 00081 STDMETHOD(get_Territories)(IMgaTerritories **terrs); 00082 STDMETHOD(get_AddOns)(IMgaAddOns **addons); 00083 STDMETHOD(get_AddOnComponents)(IMgaComponents **comps); 00084 STDMETHOD(EnableAutoAddOns)(VARIANT_BOOL bEnable); 00085 STDMETHOD(BeginTransaction)(IMgaTerritory *, transactiontype_enum mode); 00086 STDMETHOD(BeginTransactionInNewTerr)(transactiontype_enum mode, IMgaTerritory **); 00087 STDMETHOD(AbortTransaction)(); 00088 STDMETHOD(get_ProjectStatus)(long *stat); 00089 STDMETHOD(CommitTransaction)(); 00090 STDMETHOD(CommitNotify)(); 00091 STDMETHOD(CheckSupress)(VARIANT_BOOL); 00092 STDMETHOD(GlobalNotify)(globalevent_enum msg); 00093 STDMETHOD(Notify)(globalevent_enum event); 00094 STDMETHOD(Redo)(); 00095 STDMETHOD(Undo)(); 00096 STDMETHOD(UndoRedoSize)(short *undosize, short *redosize); 00097 STDMETHOD(FlushUndoQueue)(); 00098 00099 STDMETHOD(UpdateSourceControlInfo)( BSTR param); 00100 STDMETHOD(SourceControlActiveUsers)( ); 00101 STDMETHOD(SourceControlObjectOwner)( BSTR p_optionalID); 00102 00103 STDMETHOD(get_RootFolder)( IMgaFolder **pVal); 00104 STDMETHOD(get_RootMeta)(IMgaMetaProject **pVal); 00105 00106 STDMETHOD(GetStatistics)(BSTR *statstr); 00107 STDMETHOD(get_ObjectByPath)(BSTR path, IMgaObject **pVal); 00108 STDMETHOD(get_NthObjectByPath)(long n_th, BSTR path, IMgaObject **pVal); 00109 STDMETHOD(GetFolderByPath)(BSTR path, IMgaFolder **pVal); 00110 STDMETHOD(GetFCOsByName)(BSTR name, IMgaFCOs **pVal); 00111 STDMETHOD(GetFCOByID)(BSTR id, IMgaFCO **pVal); 00112 STDMETHOD(GetObjectByID)(BSTR id, IMgaObject **pVal); 00113 STDMETHOD(EnumExtReferences)(IMgaFCOs *fcos, IMgaFCOs **pVal); 00114 00115 STDMETHOD(CreateFilter)(IMgaFilter **); 00116 STDMETHOD(AllFCOs)(IMgaFilter *, IMgaFCOs **pVal); 00117 STDMETHOD(get_Name)(BSTR *pVal); 00118 STDMETHOD(put_Name)(BSTR newVal); 00119 STDMETHOD(get_Version)(BSTR *pVal); 00120 STDMETHOD(put_Version)(BSTR newVal); 00121 STDMETHOD(get_Comment)( BSTR *pVal); 00122 STDMETHOD(put_Comment)( BSTR newVal); 00123 STDMETHOD(get_Author)( BSTR *pVal); 00124 STDMETHOD(put_Author)( BSTR pVal); 00125 STDMETHOD(get_ChangeTime)( BSTR *pVal); 00126 STDMETHOD(get_CreateTime)( BSTR *pVal); 00127 STDMETHOD(get_MetaGUID)(VARIANT *pVal); 00128 STDMETHOD(get_MetaVersion)(BSTR *pVal); 00129 STDMETHOD(get_MetaName)(BSTR *pVal); 00130 STDMETHOD(get_GUID)(VARIANT *pVal); 00131 STDMETHOD(put_GUID)(VARIANT newVal); 00132 00133 STDMETHOD(get_ProjectConnStr)(BSTR *pVal); 00134 STDMETHOD(get_ParadigmConnStr)(BSTR *pVal); 00135 00136 STDMETHOD(QueryProjectInfo)(BSTR projectname, long *mgaversion, 00137 BSTR *paradigmname, 00138 BSTR *parversion, 00139 VARIANT *paradigmGUID, 00140 VARIANT_BOOL *ro_mode); 00141 STDMETHOD(CheckCollection)(IMgaFCOs *coll); 00142 STDMETHOD(CheckFolderCollection)(IMgaFolders *coll); 00143 STDMETHOD(get_Clients)(IMgaClients **clients); 00144 STDMETHOD(RegisterClient)(BSTR name, IDispatch *OLEServer, IMgaClient **client); 00145 STDMETHOD(GetClientByName)(BSTR name, IMgaClient **client); 00146 STDMETHOD(GetTopLibraries)(BSTR name, IMgaFolders **res); 00147 #ifndef _ATL_DEBUG_INTERFACES 00148 ICoreProject* dataproject; 00149 #else 00150 bool dataprojectNull; 00151 void put_dataproject(ICoreProject* dataproject) 00152 { 00153 dataprojectNull = !!dataproject; 00154 } 00155 CComPtr<ICoreProject> get_dataproject() 00156 { 00157 if (dataprojectNull) 00158 return NULL; 00159 CComPtr<ICoreProject> ret; 00160 COMTHROW(inner->QueryInterface(__uuidof(ICoreProject), (void**)&ret.p)); 00161 return ret; 00162 } 00163 __declspec(property(get=get_dataproject, put=put_dataproject)) CComPtr<ICoreProject> dataproject; 00164 #endif 00165 void ObjMark(IMgaObject *s, long mask); 00166 void FixupGUID(bool write = true); 00167 void UpdateMGAVersion(CoreObj& p_dataroot); 00168 void SetNmspaceInMeta(); 00169 CComBSTR getNmspc(); 00170 CComBSTR prefixWNmspc( CComBSTR pKindname); 00171 00172 void StartAutoAddOns(); // start if enabled 00173 void StopAutoAddOns(); // stop them always 00174 void RemoveClients(); 00175 00176 CComPtr<IMgaMetaBase> FindMetaRef(metaref_type l); // Does not add ref 00177 00178 private: 00179 CComPtr<IMgaMetaProject> metapr; 00180 00181 public: 00182 int mgaversion; 00183 00184 typedef std::list<CMgaTerritory *> tercoll; // elements do not hold a reference!! //slist 00185 tercoll allterrs; 00186 typedef std::list<CMgaAddOn *> addoncoll; // elements do not hold a reference!! //slist 00187 addoncoll alladdons; 00188 typedef std::list< IMgaComponent *> compcoll; // this list holds a reference!!!! //slist 00189 // (however, STL does not like smart pointers) 00190 typedef std::list<CMgaClient *>clientcoll; // elements do not hold a reference!! //slist 00191 clientcoll allclients; 00192 00193 compcoll autocomps; 00194 CComPtr<CMgaTerritory> baseterr, activeterr, reserveterr; 00195 HRESULT pushterr(CMgaTerritory &terr); 00196 HRESULT popterr(); 00197 00198 typedef std::queue<FCOPtr> objcoll; 00199 objcoll changedobjs, notifyobjs, temporalobjs; 00200 typedef stdext::hash_set<FCOPtr, FCOPtr_hashfunc> objhash; 00201 objhash deferredchecks; 00202 bool checkoff; 00203 bool checkofftemporary; 00204 00205 private: 00206 bool in_nested; 00207 bool non_nestable; 00208 bool must_abort; 00209 friend class Transaction; 00210 HRESULT beginnested(); 00211 HRESULT abortnested(); 00212 HRESULT commitnested(); 00213 bool autoaddons; // automatic addon instantiation enabled 00214 bool inautoaddoncreate; // addons are just being instantiated 00215 _bstr_t autoaddoncreate_progid; 00216 #ifdef DEBUG 00217 public: 00218 #endif 00219 bool alreadynested(); 00220 00221 int getMaxUndoSize(); 00222 00223 public: 00224 long preferences; 00225 unsigned long opmask; 00226 bool read_only; 00227 00228 int guidstat; 00229 CComVariant pendingguid; 00230 enum guidmodes { CLEAN, DIRTY, PENDING, MANUAL}; 00231 00232 enum openmodes { CLOSED = 0, UNCHANGED = 1, CHANGED = 2, CLOSEERROR = 4}; 00233 int transactioncount; 00234 bool notifyqueueprocessed; 00235 00236 int opened; 00237 int aurcnt; // Abort/undo/redo count 00238 coreobjhash objstocheck; 00239 00240 CComBSTR projconn, parconn; 00241 }; 00242 00243 00244 #define MODEMASK(type, mode) ((mgaproject->opmask >> (type + mode)) & 3) 00245 #define MODEFLAG(type, flag) ((mgaproject->opmask >> (type)) & flag) 00246 00247 00248 00250 // CMgaClient 00251 class ATL_NO_VTABLE CMgaClient : 00252 public CComObjectRootEx<CComSingleThreadModel>, 00253 public CComCoClass<CMgaClient, &__uuidof(MgaClient)>, 00254 public IDispatchImpl<IMgaClient, &__uuidof(IMgaClient), &__uuidof(__MGALib)> 00255 { 00256 00257 public: 00258 00259 CComBSTR name; 00260 CComPtr<IDispatch> ole_server; 00261 CMgaProject *mgaproject; 00262 bool active; 00263 00264 CMgaClient() 00265 { 00266 } 00267 00268 ~CMgaClient() { 00269 if(active) Destroy(); 00270 } 00271 00272 DECLARE_PROTECT_FINAL_CONSTRUCT() 00273 00274 BEGIN_COM_MAP(CMgaClient) 00275 COM_INTERFACE_ENTRY(IMgaClient) 00276 COM_INTERFACE_ENTRY(IDispatch) 00277 END_COM_MAP() 00278 00279 // IMgaClient 00280 public: 00281 STDMETHOD(get_Name)( BSTR *pName ) { 00282 COMTRY { 00283 CHECK_OUTSTRPAR(pName); 00284 *pName = CComBSTR(name).Detach(); 00285 } COMCATCH(;); 00286 } 00287 00288 STDMETHOD(get_OLEServer)( IDispatch **pServer ) { 00289 COMTRY { 00290 CHECK_OUTPTRPAR(pServer); 00291 *pServer = ole_server; 00292 (*pServer)->AddRef(); 00293 } COMCATCH(;); 00294 } 00295 00296 STDMETHOD(get_Project)( IMgaProject **pVal ) { 00297 COMTRY { 00298 CHECK_OUTPTRPAR(pVal); 00299 *pVal = mgaproject; 00300 (*pVal)->AddRef(); 00301 } COMCATCH(;); 00302 } 00303 00304 STDMETHOD(Destroy)() { 00305 COMTRY { 00306 CMgaProject::clientcoll::iterator i = mgaproject->allclients.begin(), 00307 end = mgaproject->allclients.end(); 00308 for(;i != end; ++i) { 00309 if(*i == this) { 00310 mgaproject->allclients.erase(i); 00311 active = false; 00312 return S_OK; 00313 } 00314 } 00315 ASSERT(("Client was not found among project clients",false)); 00316 } COMCATCH(;); 00317 } 00318 }; 00319 00320 #endif //__MGAPROJECT_H_