[GME-commit] GMESRC/GME/Core CoreBinFile.cpp,1.17,1.18 CoreBinFile.h,1.11,1.12

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Fri May 19 18:12:55 CDT 2006


Update of /project/gme-repository/GMESRC/GME/Core
In directory escher:/tmp/cvs-serv2950

Modified Files:
	CoreBinFile.cpp CoreBinFile.h 
Log Message:
If loading an MgaProject (BinFile) without ATTRID_GUID1..4 attributes of fcos and folders, then create & assign new values to all objects.


CVS User: Zoltan Molnar, ISIS (zolmol)

Index: CoreBinFile.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Core/CoreBinFile.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** CoreBinFile.cpp	26 Jan 2005 17:28:24 -0000	1.17
--- CoreBinFile.cpp	19 May 2006 17:12:52 -0000	1.18
***************
*** 3,7 ****
  #include "CoreBinFile.h"
  #include "CommonCollection.h"
! 
  
  
--- 3,7 ----
  #include "CoreBinFile.h"
  #include "CommonCollection.h"
! #include "..\Mga\MgaGeneric.h"
  
  
***************
*** 61,64 ****
--- 61,143 ----
  
  // --------------------------- BinObject
+ void getMeAGuid( long *p_l1, long *p_l2, long *p_l3, long *p_l4)
+ {
+ 	GUID t_guid = GUID_NULL;
+ 	COMTHROW(CoCreateGuid(&t_guid));
+ 		
+ 	ASSERT(t_guid != GUID_NULL);
+ 	//char buff[39];
+ 	//sprintf( buff, "{%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}",
+ 	//	t_guid.Data1, t_guid.Data2, t_guid.Data3,
+ 	//	t_guid.Data4[0], t_guid.Data4[1], t_guid.Data4[2], t_guid.Data4[3],
+ 	//	t_guid.Data4[4], t_guid.Data4[5], t_guid.Data4[6], t_guid.Data4[7]);
+ 
+ 	// thus replace the old guid with a new one
+ 	*p_l1 = t_guid.Data1; // Data1: 32 b, Data2, Data 3: 16 b, Data4: 64 bit
+ 	*p_l2 = (t_guid.Data2 << 16) + t_guid.Data3;
+ 	*p_l3 = (((((t_guid.Data4[0] << 8) + t_guid.Data4[1]) << 8) + t_guid.Data4[2]) << 8) + t_guid.Data4[3];
+ 	*p_l4 = (((((t_guid.Data4[4] << 8) + t_guid.Data4[5]) << 8) + t_guid.Data4[6]) << 8) + t_guid.Data4[7];
+ }
+ 
+ bool BinObject::HasGuidAttributes()
+ {
+ 	int a1( 0), a2( 0), a3( 0), a4( 0);
+ 
+ 	binattrs_iterator i = binattrs.begin();
+ 	binattrs_iterator e = binattrs.end();
+ 	while( i != e)
+ 	{
+ 		switch( (*i)->attrid)
+ 		{
+ 			case ATTRID_GUID1: ++a1;break;
+ 			case ATTRID_GUID2: ++a2;break;
+ 			case ATTRID_GUID3: ++a3;break;
+ 			case ATTRID_GUID4: ++a4;break;
+ 		};
+ 
+ 		++i;
+ 	}
+ 
+ 	// a1, a2, a3, a4 should be equal & have the 0 or 1 value
+ 	ASSERT( (a1 == 0 || a1 == 1) && a1 == a2 && a1 == a3 && a1 == a4);
+ 
+ 	return a1 && a2 && a3 && a4;
+ }
+ 
+ // this method will create Guid attributes for mga objects
+ // loaded from MGA files saved with a previous version of gme
+ void BinObject::CreateGuidAttributes( CCoreBinFile* p_bf)
+ {
+ 	// create a new guid
+ 	CComVariant l1, l2, l3, l4;
+ 	l4.vt = l3.vt = l2.vt = l1.vt = VT_I4;
+ 	getMeAGuid( &l1.lVal, &l2.lVal, &l3.lVal, &l4.lVal);
+ 
+ 	// create BinAttrs of LONG type
+ 	BinAttrBase *binattr1 = BinAttrBase::Create( VALTYPE_LONG);
+ 	BinAttrBase *binattr2 = BinAttrBase::Create( VALTYPE_LONG);
+ 	BinAttrBase *binattr3 = BinAttrBase::Create( VALTYPE_LONG);
+ 	BinAttrBase *binattr4 = BinAttrBase::Create( VALTYPE_LONG);
+ 
+ 	// fill the only public field
+ 	binattr1->attrid = ATTRID_GUID1;
+ 	binattr2->attrid = ATTRID_GUID2;
+ 	binattr3->attrid = ATTRID_GUID3;
+ 	binattr4->attrid = ATTRID_GUID4;
+ 
+ 	// set the values
+ 	binattr1->Set( p_bf, l1);
+ 	binattr2->Set( p_bf, l2);
+ 	binattr3->Set( p_bf, l3);
+ 	binattr4->Set( p_bf, l4);
+ 
+ 	// insert the objects into the container
+ 	// these objects will be destructed later 
+ 	// by BinObject::DestroyAttributes
+ 	binattrs.push_back( binattr1);
+ 	binattrs.push_back( binattr2);
+ 	binattrs.push_back( binattr3);
+ 	binattrs.push_back( binattr4);
+ }
  
  void BinObject::CreateAttributes(ICoreMetaObject *metaobject)
***************
*** 766,769 ****
--- 845,856 ----
  		opened_object->second.deleted = false;
  		opened_object->second.Read(this);
+ 		
+ 		// if the object read is folder or fco and it does NOT have guid attributes (old version mga file)
+ 		if( metaid >= DTID_MODEL && metaid <= DTID_FOLDER	// 101 .. 106
+ 			&& !opened_object->second.HasGuidAttributes())
+ 		{
+ 			// we will create guid attributes for it
+ 			opened_object->second.CreateGuidAttributes( this);
+ 		}
  	}
  

Index: CoreBinFile.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Core/CoreBinFile.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** CoreBinFile.h	26 Jan 2005 17:28:24 -0000	1.11
--- CoreBinFile.h	19 May 2006 17:12:52 -0000	1.12
***************
*** 45,48 ****
--- 45,51 ----
  	bool deleted;
  
+ 	bool HasGuidAttributes();
+ 	void CreateGuidAttributes( CCoreBinFile* p_bf);
+ 
  	BinAttrBase *Find(attrid_type attrid)
  	{



More information about the GME-commit mailing list