[GME-commit] GMESRC/GME/Mga MgaFolder.cpp,1.28,1.29

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Fri Apr 15 19:24:12 CDT 2005


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

Modified Files:
	MgaFolder.cpp 
Log Message:
GME:
'gme' variable comes to live when gme starts.
'it' variable is available when there is opened model

Mga:
ObjectByPath method can search based on plain name sequences


CVS User: Zoltan Molnar, ISIS (zolmol)

Index: MgaFolder.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaFolder.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** MgaFolder.cpp	1 Feb 2005 22:26:11 -0000	1.28
--- MgaFolder.cpp	15 Apr 2005 18:24:10 -0000	1.29
***************
*** 500,507 ****
  
  // The FCO::get_ObjectByPath ignores all the time the leading '/'
  // searches based on name and kind: "/@MyFolder|kind=OneFolder/@MySubFolder|kind=AnotherFolder" (the project name must not be included)
! // incoming path may contain misleading relpos tokens as well: /@MyFolder|kind=OneFolder|relpos=1/@MySubFolder|kind=AnotherFolder|relpos=2" these are disregarded
  // if several objects are found 0 is returned !
- // experimental: the @| format might be mixed with the #i (relid) format like: /@MyFolder|kind=OneFolder|relpos=1/#2" which means that the child of MyFolder with Relid = 2 will be selected
  HRESULT FCO::get_ObjectByPath(BSTR path, IMgaObject ** pVal) {
  	COMTRY {
--- 500,511 ----
  
  // The FCO::get_ObjectByPath ignores all the time the leading '/'
+ //
+ // main delimiter in the path is the slash character: '/'
  // searches based on name and kind: "/@MyFolder|kind=OneFolder/@MySubFolder|kind=AnotherFolder" (the project name must not be included)
! //       or based on plain name:    "/MyFolder/MySubFolder"
! //       or based on relid:         "/#1/#3"
! // these may be mixed like:         "/@MyFolder|kind=OneFolder|relpos=1/#2" which means that look for MyFolder, then select its child with Relid = 2
! // incoming path may contain 'misleading' relpos tokens as well: /@MyFolder|kind=OneFolder|relpos=1/@MySubFolder|kind=AnotherFolder|relpos=2" these are disregarded
  // if several objects are found 0 is returned !
  HRESULT FCO::get_ObjectByPath(BSTR path, IMgaObject ** pVal) {
  	COMTRY {
***************
*** 571,576 ****
  			}
  		}
! 		else {
! 			if(*p == '#') p++;
  			long relid = wcstol(p,&p,0);
  			COMTHROW(get_ChildObjectByRelID(relid, &pp));
--- 575,581 ----
  			}
  		}
! 		else if(*p == '#')
! 		{
! 			p++;
  			long relid = wcstol(p,&p,0);
  			COMTHROW(get_ChildObjectByRelID(relid, &pp));
***************
*** 581,587 ****
--- 586,650 ----
  			}
  		}
+ 		else // regular name
+ 		{
+ 			CComBSTR name_b;
+ 			name_b.Append("");//prepare for empty names, name_b.p is not 0 anymore
+ 			OLECHAR * p2 = p;
+ 
+ 			str_scan_name( &p2, name_b, CComBSTR(), CComBSTR()); // disregard kind and relpos
+ 			ASSERT( name_b != 0);
+ 
+ 			bool found = false;
+ 			bool conflict = false;
+ 			CoreObjs children = self[ATTRID_FCOPARENT+ATTRID_COLLECTION];
+ 			ITERATE_THROUGH(children) {
+ 				CComBSTR n = ITER[ATTRID_NAME];//if name is empty then n = "" and n.p != 0 that is why we added to name_b the "" value
+ 
+ 				bool similar = n == name_b;
+ 				if( similar && !found)
+ 				{
+ 					if ( *p2 != 0)
+ 					{
+ 						ObjForCore(ITER)->get_ObjectByPath( p2, pVal);
+ 					}
+ 					else
+ 					{
+ 						ObjForCore(ITER)->getinterface( pVal);
+ 					}
+ 
+ 					if ( *pVal)
+ 						found = true;
+ 				}
+ 				else if( similar && found) // found at least two objects with similar names at this level (samename syblings) and the first sibling contains the needed object already
+ 				{
+ 					if ( *p2 != 0)
+ 					{
+ 						CComObjPtr<IMgaObject> pdummyVal;
+ 						ObjForCore(ITER)->get_ObjectByPath( p2, PutOut(pdummyVal));
+ 						if( pdummyVal)
+ 						{
+ 							//identical name found at this level and down below to the bottom
+ 							conflict = true;
+ 							*pVal = 0;
+ 						}
+ 
+ 					}
+ 					else
+ 					{
+ 						//identical name found
+ 						conflict = true;
+ 						*pVal = 0;
+ 
+ 					}
+ 				}
+ 			}
+ 		}
  	} COMCATCH(;);
  }
  
+ // main delimiter in the path is the slash character: '/'
+ // searches based on name, kind and relpos: "/@MyFolder|kind=OneFolder/@MySubFolder|kind=AnotherFolder" (the project name must not be included)
+ // if several objects are found with the same name and kind then relpos decides among them (relpos <==> the order of creation)
+ // if relpos indicates larger number then the existing samename children then the one with the largest id (the youngest) is selected
  HRESULT FCO::get_NthObjectByPath(long n_th, BSTR path, IMgaObject ** pVal) {
  	COMTRY {



More information about the GME-commit mailing list