[GME-commit] GMESRC/GME/Mga MgaProject.cpp,1.66,1.67 MgaProject.h,1.30,1.31 MgaLibOps.cpp,1.9,1.10

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Mon May 22 18:11:09 CDT 2006


Update of /project/gme-repository/GMESRC/GME/Mga
In directory escher:/tmp/cvs-serv10243

Modified Files:
	MgaProject.cpp MgaProject.h MgaLibOps.cpp 
Log Message:
Update mgaversion attribute to 2 (upon Save) of the oldformat projects which have been opened & saved with this GME.

Perform an old refresh mechanism on the previously attached libraries.



CVS User: Zoltan Molnar, ISIS (zolmol)

Index: MgaLibOps.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaLibOps.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** MgaLibOps.cpp	19 May 2006 18:35:31 -0000	1.9
--- MgaLibOps.cpp	22 May 2006 17:11:07 -0000	1.10
***************
*** 170,174 ****
  }
  
! void CreateLibraryImage(CMgaProject *mgaproject, CComBSTR &connstr, CoreObj &libimgroot) {
  	CComPtr<IMgaProject> p;
  	PointerFixup fixup;
--- 170,174 ----
  }
  
! void CreateLibraryImage(CMgaProject *mgaproject, CComBSTR &connstr, CoreObj &libimgroot, bool p_tolerateOldMga, bool *p_ptrIsOldMga) {
  	CComPtr<IMgaProject> p;
  	PointerFixup fixup;
***************
*** 191,201 ****
  		}
  
  		// check version of the mga file to be attached
  		if( mga_ver < 2)
  		{
! 			MyCComBSTR msg( "Library is in old MGA format. To update please open it as a project, save it and only then can be attached!");
! 			Reporter( mgaproject).show( msg);
! 			
! 			COMTHROW(E_MGA_NOT_SUPPORTED);
  		}
  
--- 191,212 ----
  		}
  
+ 		*p_ptrIsOldMga = mga_ver < 2;
+ 
  		// check version of the mga file to be attached
  		if( mga_ver < 2)
  		{
! 			if( p_tolerateOldMga)
! 			{
! 				MyCComBSTR msg( "Library copy is in old MGA format. Library Refresh feature ver.1 (old) can be used only!");
! 				msg.Append( "To benefit from the new Library Refresh ver.2 feature please open/save the library with GME, then reattach it to this project.");
! 				Reporter( mgaproject).show( msg);
! 			}
! 			else
! 			{
! 				MyCComBSTR msg( "Library is in old MGA format. To update please open it as a project, save it and only then can be attached!");
! 				Reporter( mgaproject).show( msg);
! 				
! 				COMTHROW(E_MGA_NOT_SUPPORTED);
! 			}
  		}
  
***************
*** 232,236 ****
  			
  		CoreObj libimgroot;
! 		CreateLibraryImage(mgaproject, CComBSTR(libname), libimgroot);
  
  		assignnewchild(libimgroot);
--- 243,249 ----
  			
  		CoreObj libimgroot;
! 		bool accept_old_lib( false); // don't tolerate old format MGA files (attachment of such a library fails)
! 		bool is_old_lib( false);
! 		CreateLibraryImage(mgaproject, CComBSTR(libname), libimgroot, accept_old_lib, &is_old_lib);
  
  		assignnewchild(libimgroot);
***************
*** 380,427 ****
  			MyCComBSTR msg( "Inner library can't be refreshed in this project!");
  			Reporter( mgaproject).show( msg);
! 		} else {
  
! 		CheckWrite();
! 		if(!(self[ATTRID_PERMISSIONS] & LIBROOT_FLAG)) {
! 			COMTHROW(E_MGA_OP_REFUSED);
! 		}
  
! 		CComBSTR ln(libname);
! 		if(!ln) COMTHROW(get_LibraryName(&ln));
! 		CoreObj libimgroot;
! 		CreateLibraryImage(mgaproject, ln, libimgroot);
!  
! 		libimgroot[ATTRID_PARENT] = self[ATTRID_PARENT];
! 		libimgroot[ATTRID_RELID] = self[ATTRID_RELID];
  
! 		MyCComBSTR msg( "---------------------Library refresh started---------------------");
! 		Reporter( mgaproject).show( msg, false);
! 		
! 		RefreshManager rm( mgaproject, self, libimgroot);
! 		ASSERT( Identifier::isLibRoot( self));
  
! 		rm.collectDependencies( self);
! 		rm.cutRelations( self);
! 		//redo_derivs(mgaproject, self, libimgroot, false);
! 		rm.restoreDependencies();
! 		rm.clearDepStorage();
  
! 		inDeleteObject();
  
! 		try {
! 			docheck(mgaproject);
  
! 			MyCComBSTR msg;
! 			msg.Append( "----------------------Library refresh done--------");
! 			rm.getNumOfErrors( msg);
! 			msg.Append( "--");
! 			Reporter( mgaproject).show( msg, false);
  
! 		} catch(hresult_exception& ) {
! 			MyCComBSTR msg( "Check failed after refresh!");
! 			Reporter( mgaproject).show( msg);
! 			throw;
! 		}
! 		}
  	} COMCATCH_IN_TRANSACTION( Reporter(mgaproject).show( MyCComBSTR( "----------------------Library refresh failed----------------------")));
  }
--- 393,455 ----
  			MyCComBSTR msg( "Inner library can't be refreshed in this project!");
  			Reporter( mgaproject).show( msg);
! 		} 
! 		else 
! 		{
! 			CheckWrite();
! 			if(!(self[ATTRID_PERMISSIONS] & LIBROOT_FLAG)) {
! 				COMTHROW(E_MGA_OP_REFUSED);
! 			}
  
! 			CComBSTR ln(libname);
! 			if(!ln) COMTHROW(get_LibraryName(&ln));
! 			CoreObj libimgroot;
! 			bool accept_old_lib( true); // refreshment of an old format MGA file is allowed
! 			bool is_old_lib_copy( false);
! 			CreateLibraryImage(mgaproject, ln, libimgroot, accept_old_lib, &is_old_lib_copy);
! 	 
! 			libimgroot[ATTRID_PARENT] = self[ATTRID_PARENT];
! 			libimgroot[ATTRID_RELID] = self[ATTRID_RELID];
  
! 			if( is_old_lib_copy) // do a plain old refresh
! 			{
! 				MyCComBSTR msg( "Old version of Library refresh started on library.");
! 				Reporter( mgaproject).show( msg, false);
  
! 				redo_derivs(mgaproject, self, libimgroot, false);
! 				inDeleteObject();
! 				docheck(mgaproject);
! 			}
! 			else // do a uid based refresh
! 			{
! 				MyCComBSTR msg( "---------------------Library refresh v2 started---------------------");
! 				Reporter( mgaproject).show( msg, false);
! 				
! 				RefreshManager rm( mgaproject, self, libimgroot);
! 				ASSERT( Identifier::isLibRoot( self));
  
! 				rm.collectDependencies( self);
! 				rm.cutRelations( self);
! 				//redo_derivs(mgaproject, self, libimgroot, false);
! 				rm.restoreDependencies();
! 				rm.clearDepStorage();
  
! 				inDeleteObject();
  
! 				try {
! 					docheck(mgaproject);
  
! 					MyCComBSTR msg;
! 					msg.Append( "----------------------Library refresh done--------");
! 					rm.getNumOfErrors( msg);
! 					msg.Append( "--");
! 					Reporter( mgaproject).show( msg, false);
  
! 				} catch(hresult_exception& ) {
! 					MyCComBSTR msg( "Check failed after refresh!");
! 					Reporter( mgaproject).show( msg);
! 					throw;
! 				}
! 			}
! 		} // else
  	} COMCATCH_IN_TRANSACTION( Reporter(mgaproject).show( MyCComBSTR( "----------------------Library refresh failed----------------------")));
  }

Index: MgaProject.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaProject.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** MgaProject.h	28 Nov 2005 22:09:15 -0000	1.30
--- MgaProject.h	22 May 2006 17:11:07 -0000	1.31
***************
*** 163,166 ****
--- 163,167 ----
  	void ObjMark(IMgaObject *s, long mask);
  	void FixupGUID(bool write = true);
+ 	void UpdateMGAVersion(CoreObj& p_dataroot);
  
  	void StartAutoAddOns();												// start if enabled

Index: MgaProject.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaProject.cpp,v
retrieving revision 1.66
retrieving revision 1.67
diff -C2 -d -r1.66 -r1.67
*** MgaProject.cpp	19 May 2006 20:12:07 -0000	1.66
--- MgaProject.cpp	22 May 2006 17:11:07 -0000	1.67
***************
*** 263,266 ****
--- 263,268 ----
  		    s=dataroot[ATTRID_PARADIGM];
  			mgaversion = dataroot[ATTRID_MGAVERSION];
+ 			if( mgaversion <= 1L) // Core layer changed the project by adding ATTRID_GUID1..4 for CCoreBinFile
+ 				opened = CHANGED;
  
  			pGUID=CComVariant(dataroot[ATTRID_PARGUID]);
***************
*** 382,385 ****
--- 384,389 ----
  		    s=dataroot[ATTRID_PARADIGM];
  			mgaversion = dataroot[ATTRID_MGAVERSION];
+ 			if( mgaversion <= 1L) // Core layer changed the project by adding ATTRID_GUID1..4 for CCoreBinFile
+ 				opened = CHANGED;
  
  			pGUID=CComVariant(dataroot[ATTRID_PARGUID]);
***************
*** 515,518 ****
--- 519,526 ----
  			CComPtr<IMgaTerritory> t;
  			COMTHROW(CreateTerritory(NULL, &t));
+ 			// if mga_ver<=1 the Core layer changed the project by adding ATTRID_GUID1..4
+ 			// (mgaversion <= 1L) -> (opened >= CHANGED)
+ 			ASSERT( !(mgaversion <= 1L) || opened >= CHANGED);
+ 
  			if(opened >= CHANGED) {
  				COMTHROW(BeginTransaction(t, TRANSACTION_GENERAL));
***************
*** 520,523 ****
--- 528,532 ----
  					CoreObj self;
  					COMTHROW(dataproject->get_RootObject(&self.ComPtr()));
+ 					UpdateMGAVersion( self);
  					FixupGUID();
  					locking_type ppp;
***************
*** 1611,1615 ****
  }
  
! 
  
  
--- 1620,1632 ----
  }
  
! void CMgaProject::UpdateMGAVersion(CoreObj& p_dataroot)
! {
! 	mgaversion = p_dataroot[ATTRID_MGAVERSION];
! 	if( mgaversion <= 1L)
! 	{
! 		// update done by CreateCoreMetaProject so update the ATTRID_MGAVERSION too
! 		mgaversion = p_dataroot[ATTRID_MGAVERSION] = 2L;
! 	}
! }
  
  



More information about the GME-commit mailing list