[GME-commit] GMESRC/GME/Mga MgaConnection.cpp,1.17,1.18 MgaConnection.h,1.7,1.8

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Mon Jun 26 14:49:28 CDT 2006


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

Modified Files:
	MgaConnection.cpp MgaConnection.h 
Log Message:
Fix for JIRA-130.
Connection creation could not be committed in basetype because, it was not propagated well into its derivedtype.


CVS User: Zoltan Molnar, ISIS (zolmol)

Index: MgaConnection.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaConnection.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** MgaConnection.h	26 Jan 2005 17:30:47 -0000	1.7
--- MgaConnection.h	26 Jun 2006 13:49:26 -0000	1.8
***************
*** 113,116 ****
--- 113,126 ----
  };
  
+ class AddConnPTask : public DeriveTreeTask {
+ 	CComBSTR rolename;
+ 	long maxinrole;
+ 
+ 	bool Do(CoreObj self, std::vector<CoreObj> *peers);
+ 
+ public:
+ 	AddConnPTask(long mr, BSTR rn) : maxinrole(mr), rolename(rn) { endreserve = 1; }
+ 	CoreObj retval;
+ };
  
  #endif //__MGACONNECTION_H_

Index: MgaConnection.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaConnection.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** MgaConnection.cpp	26 Jan 2005 17:30:46 -0000	1.17
--- MgaConnection.cpp	26 Jun 2006 13:49:26 -0000	1.18
***************
*** 137,181 ****
  //    (it is protected by endreserve, and updated manually below)
  
! class AddConnPTask : public DeriveTreeTask {
! 	CComBSTR rolename;
! 	bool Do(CoreObj self, std::vector<CoreObj> *peers) {
! 	   CoreObj role;
! 	   CMgaProject *mgaproject = ObjForCore(self)->mgaproject;
! 	   if(maxinrole > 0) {
! 		   long rolesofname = 0;
! 		   ITERATE_THROUGH(self[ATTRID_CONNROLE+ATTRID_COLLECTION]) {
! 			   if(rolename == CComBSTR(ITER[ATTRID_NAME])) rolesofname++;
! 		   }
! 		   if(rolesofname >= maxinrole) {
! 			   if(!(*peers)[peercnt-1]) {  // if this is the master connection
! 				   COMTHROW(E_MGA_CONNROLE_USED);  // indicate error
! 			   }
! 			   return false;			   // ... else silently ignore it
! 		   }
! 	   }
! 	   COMTHROW(mgaproject->dataproject->CreateObject(DTID_CONNROLE,&role.ComPtr()));
! 	   role[ATTRID_NAME] = rolename;
! 	   role[ATTRID_CONNROLE] = self;
! 	   role[ATTRID_XREF] = (*peers)[peercnt-2];
! 	   role[ATTRID_MASTEROBJ] = (*peers)[peercnt-1];
! 	   for(int i = 0; i < peercnt-2; i++) {
! 			CoreObj seg;
! 			COMTHROW(mgaproject->dataproject->CreateObject(DTID_CONNROLESEG,&seg.ComPtr()));
! 			seg[ATTRID_CONNSEG] = role;
! 			seg[ATTRID_SEGORDNUM] = i+1;
! 			seg[ATTRID_SEGREF] = (*peers)[i];
! 	   }
  
! 	   COMTHROW(ObjForCore(self)->Check());
! 	   ObjForCore((*peers)[0])->SelfMark(OBJEVENT_CONNECTED);
! 	   ObjForCore(self)->SelfMark(OBJEVENT_RELATION);
! 	   (*peers)[peercnt-1] = role;
! 	   return true;
  	}
! 	long maxinrole;
! public:
! 	AddConnPTask(long mr, BSTR rn) : maxinrole(mr), rolename(rn) { endreserve = 1; }
! 	CoreObj retval;
! };
  
  HRESULT FCO::AddConnPoint(BSTR rolename, long maxinrole, IMgaFCO *target, IMgaFCOs *refs, IMgaConnPoint **pVal) {
--- 137,189 ----
  //    (it is protected by endreserve, and updated manually below)
  
! bool AddConnPTask::Do(CoreObj self, std::vector<CoreObj> *peers) {
! 	CoreObj role;
! 	CMgaProject *mgaproject = ObjForCore(self)->mgaproject;
! 	if(maxinrole > 0) {
! 		long rolesofname = 0;
! 		ITERATE_THROUGH(self[ATTRID_CONNROLE+ATTRID_COLLECTION]) {
! 			if(rolename == CComBSTR(ITER[ATTRID_NAME])) rolesofname++;
! 		}
! 		if(rolesofname >= maxinrole) {
! 			if(!(*peers)[peercnt-1]) {  // if this is the master connection
! 				COMTHROW(E_MGA_CONNROLE_USED);  // indicate error
! 			}
! 			return false;			   // ... else silently ignore it
! 		}
! 	}
! 	COMTHROW(mgaproject->dataproject->CreateObject(DTID_CONNROLE,&role.ComPtr()));
! 	role[ATTRID_NAME] = rolename;
! 	role[ATTRID_CONNROLE] = self;
! 	role[ATTRID_XREF] = (*peers)[peercnt-2];
! 	role[ATTRID_MASTEROBJ] = (*peers)[peercnt-1];
! 	for(int i = 0; i < peercnt-2; i++) {
! 		CoreObj seg;
! 		COMTHROW(mgaproject->dataproject->CreateObject(DTID_CONNROLESEG,&seg.ComPtr()));
! 		seg[ATTRID_CONNSEG] = role;
! 		seg[ATTRID_SEGORDNUM] = i+1;
! 		seg[ATTRID_SEGREF] = (*peers)[i];
! 	}
  
! 	if( peercnt-2 >= 1) // additional check
! 	{
! 		CoreObj last_ref = (*peers)[peercnt - 3];
! 		CoreObj tgt_model= last_ref[ATTRID_REFERENCE];
! 		CoreObj tgt_elem = (*peers)[peercnt - 2];
! 		CoreObj parent   = tgt_elem[ATTRID_FCOPARENT];
! 		CoreObj bas_model= tgt_model[ATTRID_DERIVED]; // tgt_model must be a derived for GetDerivedEquivalent to succeed
! 		if( !COM_EQUAL(parent, tgt_model) && bas_model) { // JIRA:130?
! 			CoreObj new_tgt_elem;
! 			GetDerivedEquivalent( tgt_elem, tgt_model, new_tgt_elem);
! 			if( new_tgt_elem) // found tgt_elem's equivalent in tgt_model
! 				role[ATTRID_XREF] = new_tgt_elem; // overwrite the previous value: (*peers)[peercnt-2];
! 		}
  	}
! 
! 	COMTHROW(ObjForCore(self)->Check());
! 	ObjForCore((*peers)[0])->SelfMark(OBJEVENT_CONNECTED);
! 	ObjForCore(self)->SelfMark(OBJEVENT_RELATION);
! 	(*peers)[peercnt-1] = role;
! 	return true;
! }
  
  HRESULT FCO::AddConnPoint(BSTR rolename, long maxinrole, IMgaFCO *target, IMgaFCOs *refs, IMgaConnPoint **pVal) {



More information about the GME-commit mailing list