[GME-commit] GMESRC/GME/Mga MgaLibRefr.cpp, 1.7, 1.8 MgaLibRefr.h, 1.4, 1.5

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Wed Mar 7 16:12:34 CST 2007


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

Modified Files:
	MgaLibRefr.cpp MgaLibRefr.h 
Log Message:
Relids not changed upon refresh.
Some useless parameters eliminated (hashmaps).

DependencyInfo changed from ID to GUID, that's why reapplyLibFlagToChangedLibs() changed.



CVS User: Zoltan Molnar, ISIS (zolmol)

Index: MgaLibRefr.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaLibRefr.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** MgaLibRefr.cpp	21 Feb 2007 22:17:41 -0000	1.7
--- MgaLibRefr.cpp	7 Mar 2007 22:12:32 -0000	1.8
***************
*** 11,14 ****
--- 11,15 ----
  /*static*/
  bool SearchTool::m_optimized = false;
+ bool RefreshManager::m_alterRelids = false;
  
  short RefreshManager::distance( CoreObj& derd)
***************
*** 1525,1530 ****
--- 1526,1533 ----
  			// delete the connection
  			try {
+ #ifdef _DEBUG
  				long ci = CoreObj(cn_i)[ATTRID_RELID];
  				++ci;
+ #endif
  				//COMTHROW( cn_i->DestroyObject());
  				ObjForCore( CoreObj(cn_i))->inDeleteObject();
***************
*** 2097,2101 ****
  // priAdaptiveObj as the primary derived (previously detached)
  void RefreshManager::SyncDerObjs( const CoreObj &masterobj, CoreObj &adaptiveobj
! 								 , coreobjpairhash &crealist, long instance, bool prim
  								 , const CoreObj &priMasterObj, const CoreObj &priAdaptiveObj)
  {
--- 2100,2104 ----
  // priAdaptiveObj as the primary derived (previously detached)
  void RefreshManager::SyncDerObjs( const CoreObj &masterobj, CoreObj &adaptiveobj
! 								 , long instance, bool prim
  								 , const CoreObj &priMasterObj, const CoreObj &priAdaptiveObj)
  {
***************
*** 2186,2190 ****
  										if( meta_id == DTID_MODEL)//!meta_id == DTID_CONNECTION
  										{
! 											SyncDerObjs( outer_ITER, ITER, crealist, instance, false, priMasterObj, priAdaptiveObj);
  										}   // nothing to do for connections since they have no inner objects
  
--- 2189,2193 ----
  										if( meta_id == DTID_MODEL)//!meta_id == DTID_CONNECTION
  										{
! 											SyncDerObjs( outer_ITER, ITER, instance, false, priMasterObj, priAdaptiveObj);
  										}   // nothing to do for connections since they have no inner objects
  
***************
*** 2262,2270 ****
  					CoreObj prev_detached( prev_detached_obj);
  					CoreObj frsh_base( lib_base);
- 					coreobjpairhash crealist2;
  					
  					// sync structure of fresh base with detached derive
  					// the last two parameters helps in redirection of the internal references
! 					SyncDerObjs( frsh_base, prev_detached, crealist2, 0, true, frsh_base, prev_detached);
  					
  					PROJ_ID b_id, d_id;
--- 2265,2272 ----
  					CoreObj prev_detached( prev_detached_obj);
  					CoreObj frsh_base( lib_base);
  					
  					// sync structure of fresh base with detached derive
  					// the last two parameters helps in redirection of the internal references
! 					SyncDerObjs( frsh_base, prev_detached, 0, true, frsh_base, prev_detached);
  					
  					PROJ_ID b_id, d_id;
***************
*** 2341,2349 ****
  	{
  		CoreObj libroot;
! 		bool all_right = SearchTool::findTopLibInProj( m_mgaproject, it.getCurrentBstr(), libroot);
! 		ASSERT( all_right && libroot);
! 		if( all_right && libroot)
! 			// this lib may have gotten new elements during refresh
! 			applyLibFlag( libroot);
  	}
  }
--- 2343,2358 ----
  	{
  		CoreObj libroot;
! 		CComPtr<IMgaFolders> coll;
! 		COMTHROW( m_mgaproject->GetTopLibraries( it.getCurrentBstr(), &coll));
! 		// this lib may have gotten new elements during refresh, that's why
! 		// for all such libs reapply the LIB flag onto the hierarchy
! 		long len( 0);
! 		if( coll) COMTHROW( coll->get_Count( &len));
! 		for( long i = 1; i <= len; ++i)
! 		{
! 			CComPtr<IMgaFolder> ele;
! 			COMTHROW( coll->get_Item( i, &ele));
! 			applyLibFlag( CoreObj( ele));
! 		}
  	}
  }
***************
*** 2364,2367 ****
--- 2373,2377 ----
  void RefreshManager::PropObjRelidIncrease( CoreObj& obj)
  {
+ 	ASSERT( m_alterRelids);
  	// for all deriveds from obj
  	CoreObjs deriveds = obj[ATTRID_DERIVED + ATTRID_COLLECTION];
***************
*** 2391,2394 ****
--- 2401,2405 ----
  void RefreshManager::PropObjRelidDecrease( CoreObj& obj, long level)
  {
+ 	ASSERT( m_alterRelids);
  	// for all deriveds from obj
  	CoreObjs deriveds = obj[ATTRID_DERIVED + ATTRID_COLLECTION];
***************
*** 2412,2416 ****
  }
  
! void RefreshManager::DetachObjFromLibBase( const CoreObj& p_baseObj, CoreObj& p_derdObj, coreobjpairhash& crealist, unsigned long nextrelid, bool prim)
  {
  	bool has_last_relid_attr = false;
--- 2423,2427 ----
  }
  
! void RefreshManager::DetachObjFromLibBase( const CoreObj& p_baseObj, CoreObj& p_derdObj, unsigned long nextrelid, bool prim)
  {
  	bool has_last_relid_attr = false;
***************
*** 2453,2457 ****
  					case ATTRID_RELID:
  					{
! 						if( !prim) // it was a child of a primary derived, being detached
  						{
  							// since it was called recursively we know for sure that
--- 2464,2468 ----
  					case ATTRID_RELID:
  					{
! 						if( m_alterRelids && !prim) // it was a child of a primary derived, being detached
  						{
  							// since it was called recursively we know for sure that
***************
*** 2562,2566 ****
  								{
  									// detach it as well from its base
! 									DetachObjFromLibBase( base, ITER, crealist, 0, false);
  								}
  								else 
--- 2573,2577 ----
  								{
  									// detach it as well from its base
! 									DetachObjFromLibBase( base, ITER, 0, false);
  								}
  								else 
***************
*** 2591,2595 ****
  							// remove the ATTRID_DERIVED attrs if any?
  							// NOTE: 1st parameter is a dummy one: ITER
! 							DetachObjFromLibBase( ITER, ITER, crealist, 0, false);
  						}
  					}
--- 2602,2606 ----
  							// remove the ATTRID_DERIVED attrs if any?
  							// NOTE: 1st parameter is a dummy one: ITER
! 							DetachObjFromLibBase( ITER, ITER, 0, false);
  						}
  					}
***************
*** 2605,2609 ****
  }
  
! void RefreshManager::AttachDerObjs( const CoreObj &p_baseObj, CoreObj &p_derdObj, coreobjpairhash &crealist, long instance, bool prim) 
  {
  	long nb_of_children = 0;
--- 2616,2620 ----
  }
  
! void RefreshManager::AttachDerObjs( const CoreObj &p_baseObj, CoreObj &p_derdObj, long instance, bool prim) 
  {
  	long nb_of_children = 0;
***************
*** 2642,2646 ****
  					case ATTRID_RELID: 
  					{
! 						if( !prim)
  						{
  							p_derdObj[ai] = p_derdObj[ai]+RELIDSPACE;//shift its own relid
--- 2653,2657 ----
  					case ATTRID_RELID: 
  					{
! 						if( m_alterRelids && !prim)
  						{
  							p_derdObj[ai] = p_derdObj[ai]+RELIDSPACE;//shift its own relid
***************
*** 2711,2715 ****
  								if( found)
  								{
! 									AttachDerObjs( bs, ITER, crealist, instance, false);
  								}
  
--- 2722,2726 ----
  								if( found)
  								{
! 									AttachDerObjs( bs, ITER, instance, false);
  								}
  
***************
*** 3113,3117 ****
  			// objects survive the death of bs object
  			CoreObj derd( sub);
! 			DetachObjFromLibBase( one_fco, derd, coreobjpairhash(), 0, true);
  
  			// shift relids for the subtypes of derdchildren
--- 3124,3128 ----
  			// objects survive the death of bs object
  			CoreObj derd( sub);
! 			DetachObjFromLibBase( one_fco, derd, 0, true);
  
  			// shift relids for the subtypes of derdchildren
***************
*** 3120,3124 ****
  			// because a secondary derived object's distance from
  			// its topmost basetype is calc'ed based on relid
! 			if( derd.IsContainer()) 
  			{
  				CoreObjs children = derd[ ATTRID_FCOPARENT + ATTRID_COLLECTION];
--- 3131,3135 ----
  			// because a secondary derived object's distance from
  			// its topmost basetype is calc'ed based on relid
! 			if( m_alterRelids && derd.IsContainer()) 
  			{
  				CoreObjs children = derd[ ATTRID_FCOPARENT + ATTRID_COLLECTION];
***************
*** 3142,3147 ****
  					// by removing the dependency me help derd 
  					// objects survive the death of bs object
! 					coreobjpairhash crealist2;
! 					DetachObjFromLibBase( bs, derd, crealist2, 0, true);
  
  					// shift relids for the subtypes of derdchildren
--- 3153,3157 ----
  					// by removing the dependency me help derd 
  					// objects survive the death of bs object
! 					DetachObjFromLibBase( bs, derd, 0, true);
  
  					// shift relids for the subtypes of derdchildren
***************
*** 3189,3197 ****
  		bool is_instance     ( i->second.second);
  		
! 		AttachDerObjs( fresh_base, prev_detached, coreobjpairhash(), is_instance?VARIANT_TRUE:VARIANT_FALSE, true);
  
  		// relids inside prev_detached have changed
  		// let's propagate them
! 		if( prev_detached.IsContainer())
  		{
  			CoreObjs children = prev_detached[ATTRID_FCOPARENT + ATTRID_COLLECTION];
--- 3199,3207 ----
  		bool is_instance     ( i->second.second);
  		
! 		AttachDerObjs( fresh_base, prev_detached, is_instance?VARIANT_TRUE:VARIANT_FALSE, true);
  
  		// relids inside prev_detached have changed
  		// let's propagate them
! 		if( m_alterRelids && prev_detached.IsContainer())
  		{
  			CoreObjs children = prev_detached[ATTRID_FCOPARENT + ATTRID_COLLECTION];

Index: MgaLibRefr.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaLibRefr.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** MgaLibRefr.h	12 Feb 2007 18:24:30 -0000	1.4
--- MgaLibRefr.h	7 Mar 2007 22:12:32 -0000	1.5
***************
*** 564,567 ****
--- 564,586 ----
  	}
  
+ 	static CoreObj findTopLibrary( CoreObj& p_folder, CComBSTR& p_libId)
+ 	{
+ 		ITERATE_THROUGH( p_folder[ATTRID_FCOPARENT+ATTRID_COLLECTION]) 
+ 		{
+ 			metaid_type mi = ITER.GetMetaID();
+ 			long pm = ITER[ATTRID_PERMISSIONS];
+ 			if( mi == DTID_FOLDER && (pm & LIBROOT_FLAG))
+ 			{
+ 				//BinGuid lib_id = Identifier::getPersistentIdOf( ITER);
+ 				CComBSTR lib_id;
+ 				ObjForCore( ITER)->GetGuidDisp( &lib_id);
+ 				if( lib_id == p_libId)
+ 					return ITER;
+ 			}
+ 		}
+ 
+ 		return CoreObj();
+ 	}
+ 
  	static bool findTopLibInProj(       CMgaProject*       p_mgaProject
  	                            , const PROJ_ID&           p_idOfLib
***************
*** 829,834 ****
  	void applyLibFlag( CoreObj& p_libObj);
  
! 	void DetachObjFromLibBase( const CoreObj& baseObj, CoreObj& derdObj, coreobjpairhash& crealist, unsigned long nextrelid, bool prim);
! 	void AttachDerObjs( const CoreObj& baseObj, CoreObj& derdObj, coreobjpairhash& crealist, long instance, bool prim);
  
  	// cuts or detaches libraryderived objects
--- 848,853 ----
  	void applyLibFlag( CoreObj& p_libObj);
  
! 	void DetachObjFromLibBase( const CoreObj& baseObj, CoreObj& derdObj, unsigned long nextrelid, bool prim);
! 	void AttachDerObjs( const CoreObj& baseObj, CoreObj& derdObj, long instance, bool prim);
  
  	// cuts or detaches libraryderived objects
***************
*** 838,841 ****
--- 857,862 ----
  	void reattachSubtypesInstances();// CoreObj& ofolder, CoreObj& nfolder);
  	
+ 	// relids altered?
+ 	static bool m_alterRelids;
  	// -after the cut we decrease relids to seem consistent
  	// (to be consistent with the changed hierarchy)
***************
*** 856,860 ****
  	// propagates any change in the base object
  	// into subtypes aggregated by collectDersFromLib
! 	void SyncDerObjs( const CoreObj &freshMasterObj, CoreObj &adaptiveObj, coreobjpairhash &crealist, long instance, bool prim, const CoreObj &priMasterObj, const CoreObj &priAdaptiveObj);
  	void SyncObjectName( const CoreObj& p_masterObj, CoreObj &p_adaptiveObj);
  	void SyncDerSets( const CoreObj &freshMasterSet, CoreObj &adaptiveSet, const CoreObj &freshMasterPar, CoreObj &adaptivePar);
--- 877,881 ----
  	// propagates any change in the base object
  	// into subtypes aggregated by collectDersFromLib
! 	void SyncDerObjs( const CoreObj &freshMasterObj, CoreObj &adaptiveObj, long instance, bool prim, const CoreObj &priMasterObj, const CoreObj &priAdaptiveObj);
  	void SyncObjectName( const CoreObj& p_masterObj, CoreObj &p_adaptiveObj);
  	void SyncDerSets( const CoreObj &freshMasterSet, CoreObj &adaptiveSet, const CoreObj &freshMasterPar, CoreObj &adaptivePar);



More information about the GME-commit mailing list