[GME-commit] GMESRC/GME/Mga MgaFCO.cpp,1.31,1.32 MgaFCO.h,1.18,1.19
MgaFolder.cpp,1.24,1.25 MgaProject.cpp,1.57,1.58
MgaProject.h,1.26,1.27
gme-commit at list.isis.vanderbilt.edu
gme-commit at list.isis.vanderbilt.edu
Mon Sep 27 17:40:11 CDT 2004
- Previous message: [GME-commit]
GMESRC/GME/Parser Helper.cpp,NONE,1.1 Helper.h,NONE,1.1
MgaParserBC.cpp,NONE,1.1 MgaParserClosureHelper.cpp,NONE,1.1
MgaParserSC.cpp,NONE,1.1 mgaclosure.dtd,NONE,1.1
MgaDumper.cpp,1.18,1.19 MgaDumper.h,1.11,1.12
MgaParser.cpp,1.24,1.25 MgaParser.h,1.9,1.10 Parser.dsp,1.13,1.14
mga.dtd,1.9,1.10
- Next message: [GME-commit] GMESRC/GME/MgaUtil ClosureKindSel.cpp,NONE,1.1
ClosureKindSel.h,NONE,1.1 ClosureSmart.cpp,NONE,1.1
ClosureSmart.h,NONE,1.1 ClosureDlg.cpp,1.3,1.4 ClosureDlg.h,1.3,1.4
MakeClosure.cpp,1.8,1.9 MakeClosure.h,1.4,1.5
MgaClosure.cpp,1.3,1.4 MgaClosure.h,1.2,1.3 MgaUtil.dsp,1.24,1.25
MgaUtil.rc,1.40,1.41 resource.h,1.25,1.26
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/gme/GMESRC/GME/Mga
In directory braindrain:/tmp/cvs-serv13896
Modified Files:
MgaFCO.cpp MgaFCO.h MgaFolder.cpp MgaProject.cpp MgaProject.h
Log Message:
NthObjectByName method introduced to search on relative position.
CVS User: zolmol
Index: MgaFCO.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/Mga/MgaFCO.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** MgaFCO.cpp 22 Jul 2004 16:14:33 -0000 1.31
--- MgaFCO.cpp 27 Sep 2004 21:40:09 -0000 1.32
***************
*** 1,3 ****
--- 1,4 ----
#include "stdafx.h"
+ #include <stdio.h>
#include "MgaFCO.h"
***************
*** 420,444 ****
};
// gives back the path to an object starting from the rootfolder (does not include project name)
HRESULT FCO::get_AbsPath(BSTR *pVal) {
COMTRY {
! CComBSTR path("/@");
! path.Append( self[ATTRID_NAME]);
CoreObj par = self[ATTRID_PARENT];
! while( par.GetMetaID() != DTID_ROOT)
{
CComBSTR tp("/@");
! tp.Append( par[ATTRID_NAME]);
! par = par[ATTRID_PARENT];
! if( par.GetMetaID() != DTID_ROOT) // do not include project name
! {
! tp.AppendBSTR( path);
! path = tp;
! }
!
}
CheckDeletedRead();
--- 421,477 ----
};
+ void giveme( CMgaProject *mgaproject, CoreObj par, CoreObj cur, CComBSTR cur_kind, int *relpos)
+ {
+ int count_lower_ids = 0;
+ CComBSTR cur_name = cur[ATTRID_NAME];
+ objid_type cur_id = cur.GetObjID();
+
+ CoreObjs children = par[ATTRID_FCOPARENT+ATTRID_COLLECTION];
+ ITERATE_THROUGH(children) {
+ CComBSTR n = ITER[ATTRID_NAME];
+
+ CComBSTR kind;
+ COMTHROW( mgaproject->FindMetaRef( ITER[ATTRID_META])->get_Name( &kind));
+
+ bool similar = n == cur_name;
+ //similar = similar || ITER[ATTRID_PERMISSIONS] == LIBROOT_FLAG && libraryNameEqual(n, name_b);
+ similar = similar && kind == cur_kind;
+ if( similar) // similar name
+ {
+ objid_type id = ITER.GetObjID();
+ if( cur_id > id)
+ ++count_lower_ids;
+ }
+ }
+ *relpos = count_lower_ids;
+ }
// gives back the path to an object starting from the rootfolder (does not include project name)
HRESULT FCO::get_AbsPath(BSTR *pVal) {
COMTRY {
! CComBSTR path("");
CoreObj par = self[ATTRID_PARENT];
! CoreObj cur = self;
! while( !par.IsRootFolder())
{
CComBSTR tp("/@");
! tp.Append( cur[ATTRID_NAME]);
! tp.Append("|kind=");
! CComBSTR metakind;
! COMTHROW( mgaproject->FindMetaRef( cur[ATTRID_META])->get_Name( &metakind));
! tp.Append( metakind);
! int n;
! giveme( mgaproject, par, cur, metakind, &n);
! char p[10]; sprintf( p, "%d", n);
! CComBSTR relative_pos;
! tp.Append("|relpos=");tp.Append( p);
!
! tp.Append( path);
! path = tp;
! cur = par;
! par = par[ATTRID_PARENT];
}
CheckDeletedRead();
Index: MgaFCO.h
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/Mga/MgaFCO.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** MgaFCO.h 30 Jun 2004 17:50:47 -0000 1.18
--- MgaFCO.h 27 Sep 2004 21:40:09 -0000 1.19
***************
*** 151,154 ****
--- 151,156 ----
STDMETHOD(get_ObjectByPath)(BSTR path, IMgaObject **pVal)
{ return inFCO->get_ObjectByPath(path, pVal); }
+ STDMETHOD(get_NthObjectByPath)(long n_th, BSTR path, IMgaObject **pVal)
+ { return inFCO->get_NthObjectByPath(n_th, path, pVal); }
***************
*** 352,355 ****
--- 354,358 ----
HRESULT get_ChildObjectByRelID(long relid, IMgaObject **pVal);
HRESULT get_ObjectByPath(BSTR path, IMgaObject **pVal);
+ HRESULT get_NthObjectByPath(long n_th, BSTR path, IMgaObject **pVal);
Index: MgaFolder.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/Mga/MgaFolder.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** MgaFolder.cpp 23 Jul 2004 21:55:24 -0000 1.24
--- MgaFolder.cpp 27 Sep 2004 21:40:09 -0000 1.25
***************
*** 1,4 ****
--- 1,6 ----
// MgaFolder.cpp : Implementation of FCO Folder and container operations
#include "stdafx.h"
+ #include <map>
+ #include <stdio.h>
#include "MgaFCO.h"
#include "MgaLibOps.h" // by ZolMol
***************
*** 179,183 ****
CoreObj curr_parent = cur[ATTRID_FCOPARENT];
! if( IsFolderContained( self, cur)) COMTHROW(E_MGA_OP_REFUSED);// do not allow moving a parent (grandparent...) into its child
if( !COM_EQUAL( curr_parent, self)) {
--- 181,185 ----
CoreObj curr_parent = cur[ATTRID_FCOPARENT];
! if( IsFolderContained( self, cur)) COMTHROW(E_MGA_INVALID_ARG);// do not allow moving a parent (grandparent...) into its child
if( !COM_EQUAL( curr_parent, self)) {
***************
*** 434,438 ****
// MGA=F:tMp2.MGA
// MGA=tMp2.MGA
! bool libraryNameEqual( CComBSTR& n1, CComBSTR& n2)
{
n1.ToUpper(); n2.ToUpper();
--- 436,440 ----
// MGA=F:tMp2.MGA
// MGA=tMp2.MGA
! bool libraryNameEqual( CComBSTR n1, CComBSTR n2)
{
n1.ToUpper(); n2.ToUpper();
***************
*** 465,471 ****
p++;
! CComBSTR name_b;
OLECHAR * p2 = p;
! while ( *p2 != '/' && *p2 != '#' && *p2 != '@' && *p2 != 0)
{
name_b.Append( p2, 1);
--- 467,474 ----
p++;
! CComBSTR name_b, kind_b, relpos_b;
! name_b.Append("");//prepare for empty names, name_b.p is not 0 anymore
OLECHAR * p2 = p;
! while ( *p2 != '/' && *p2 != '#' && *p2 != '@' && *p2 != 0 && *p2 != '|')
{
name_b.Append( p2, 1);
***************
*** 473,482 ****
}
bool found = false;
CoreObjs children = self[ATTRID_FCOPARENT+ATTRID_COLLECTION];
ITERATE_THROUGH(children) {
! CComBSTR n = ITER[ATTRID_NAME];
bool similar = n == name_b;
similar = similar || ITER[ATTRID_PERMISSIONS] == LIBROOT_FLAG && libraryNameEqual(n, name_b);
if( similar && !found)
{
--- 476,509 ----
}
+ // "|kind=" test
+ if( *p2++ == '|' && *p2++ =='k' && *p2++ =='i' && *p2++ =='n' && *p2++ =='d' && *p2++ =='=')
+ {
+ while ( *p2 != '/' && *p2 != '#' && *p2 != '@' && *p2 != 0 && *p2 != '|')
+ {
+ kind_b.Append( p2, 1);
+ ++p2;
+ }
+ }
+ // "|relpos=" test
+ if( *p2++ == '|' && *p2++ =='r' && *p2++ =='e' && *p2++ =='l' && *p2++ =='p' && *p2++ =='o' && *p2++ =='s' && *p2++ =='=')
+ {
+ while ( *p2 != '/' && *p2 != '#' && *p2 != '@' && *p2 != 0 && *p2 != '|')
+ {
+ relpos_b.Append( p2, 1);
+ ++p2;
+ }
+ }
+
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
! CComBSTR kind;
! COMTHROW( mgaproject->FindMetaRef( ITER[ATTRID_META])->get_Name( &kind));
!
bool similar = n == name_b;
similar = similar || ITER[ATTRID_PERMISSIONS] == LIBROOT_FLAG && libraryNameEqual(n, name_b);
+ similar = similar && kind == kind_b;
if( similar && !found)
{
***************
*** 493,496 ****
--- 520,545 ----
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)
+ {
+ //COMTHROW(); //identical name found at this level and down below to the bottom
+ conflict = true;
+ *pVal = 0;
+ }
+
+ }
+ else
+ {
+ //COMTHROW(); //identical name found
+ conflict = true;
+ *pVal = 0;
+
+ }
+ }
}
}
***************
*** 507,510 ****
--- 556,692 ----
}
+ HRESULT FCO::get_NthObjectByPath(long n_th, BSTR path, IMgaObject ** pVal) {
+ COMTRY {
+ CHECK_OUTPTRPAR(pVal);
+ CheckRead();
+
+ OLECHAR *p = path;
+ if(*p == '/') p++;
+ CComPtr<IMgaObject> pp;
+ if(*p == '@') { // implemented by ZolMol
+ p++;
+
+ CComBSTR name_b, kind_b, relpos_b;
+ name_b.Append("");//prepare for empty names, name_b.p is not 0 anymore
+ OLECHAR * p2 = p;
+ while ( *p2 != '/' && *p2 != '#' && *p2 != '@' && *p2 != 0 && *p2 != '|')
+ {
+ name_b.Append( p2, 1);
+ ++p2;
+ }
+
+ // "|kind=" test
+ if( *p2++ == '|' && *p2++ =='k' && *p2++ =='i' && *p2++ =='n' && *p2++ =='d' && *p2++ =='=')
+ {
+ while ( *p2 != '/' && *p2 != '#' && *p2 != '@' && *p2 != 0 && *p2 != '|')
+ {
+ kind_b.Append( p2, 1);
+ ++p2;
+ }
+ }
+
+ // "|relpos=" test
+ if( *p2++ == '|' && *p2++ =='r' && *p2++ =='e' && *p2++ =='l' && *p2++ =='p' && *p2++ =='o' && *p2++ =='s' && *p2++ =='=')
+ {
+ while ( *p2 != '/' && *p2 != '#' && *p2 != '@' && *p2 != 0 && *p2 != '|')
+ {
+ relpos_b.Append( p2, 1);
+ ++p2;
+ }
+ }
+
+ bool found = false;
+ map< objid_type, vector<CoreObj> > samename_objs;
+ 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
+ CComBSTR kind;
+ COMTHROW( mgaproject->FindMetaRef( ITER[ATTRID_META])->get_Name( &kind));
+
+ bool similar = n == name_b;
+ similar = similar || ITER[ATTRID_PERMISSIONS] == LIBROOT_FLAG && libraryNameEqual(n, name_b);
+ similar = similar && kind == kind_b;
+ if( similar)
+ {
+ objid_type id = ITER.GetObjID();
+ ASSERT( samename_objs.find( id) == samename_objs.end());
+
+ samename_objs[ id].push_back( ITER);
+ }
+ }
+
+ if( samename_objs.empty()) return S_OK;
+
+ #ifdef DEBUG
+ map< objid_type, vector<CoreObj> >::iterator i = samename_objs.begin();
+ map< objid_type, vector<CoreObj> >::iterator e = samename_objs.end();
+ for( ; i != e; ++i)
+ {
+ ASSERT( i->second.size() == 1); // the id is unique, one element in the vector
+ }
+ #endif
+
+ string relpos_str;
+ CopyTo( relpos_b, relpos_str);
+
+ int relpos;
+ sscanf( relpos_str.c_str(), "%d", &relpos);
+
+ // take from the samename_objs map the element at relpos relative position
+ map< objid_type, vector<CoreObj> >::iterator ii = samename_objs.begin();
+ map< objid_type, vector<CoreObj> >::iterator ee = samename_objs.end();
+ for( int count = 0; count < relpos && ii != ee; ++ii)
+ ++count;
+
+ CoreObj the_right_one;
+ if( ii == ee) // no samename objects are present in such number
+ {
+ map< objid_type, vector<CoreObj> >::reverse_iterator rev_i = samename_objs.rbegin();
+ the_right_one = *(rev_i->second.begin());
+ }
+ else if( ii->second.size() > 0)
+ the_right_one = *(ii->second.begin());
+
+
+ // continue the search for the remaining part of the string: p2
+ if ( *p2 != 0)
+ {
+ ObjForCore(the_right_one)->get_NthObjectByPath(n_th, p2, pVal);
+ }
+ else
+ {
+ ObjForCore(the_right_one)->getinterface( pVal);
+ }
+
+ if ( *pVal)
+ found = true;
+
+ /*CoreObjs children = self[ATTRID_FCOPARENT+ATTRID_COLLECTION];
+ ITERATE_THROUGH(children) {
+ CComBSTR n = ITER[ATTRID_NAME];
+ CComBSTR kind;
+ COMTHROW( mgaproject->FindMetaRef( ITER[ATTRID_META])->get_Name( &kind));
+
+ bool similar = n == name_b;
+ similar = similar || ITER[ATTRID_PERMISSIONS] == LIBROOT_FLAG && libraryNameEqual(n, name_b);
+ similar = similar && kind == kind_b;
+ if( similar && !found)
+ {
+ if ( *p2 != 0)
+ {
+ ObjForCore(ITER)->get_NthObjectByPath(n_th, p2, pVal);
+ }
+ else
+ {
+ ObjForCore(ITER)->getinterface( pVal);
+ }
+
+ if ( *pVal)
+ found = true;
+ }
+ }*/
+ }
+ } COMCATCH(;);
+ }
//##ModelId=3C5AA097033E
Index: MgaProject.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/Mga/MgaProject.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -C2 -d -r1.57 -r1.58
*** MgaProject.cpp 14 Sep 2004 14:13:55 -0000 1.57
--- MgaProject.cpp 27 Sep 2004 21:40:09 -0000 1.58
***************
*** 725,728 ****
--- 725,737 ----
}
+ STDMETHODIMP CMgaProject::get_NthObjectByPath(long n_th, BSTR path, IMgaObject **pVal) {
+ COMTRY {
+ CHECK_INSTRPAR(path);
+ CHECK_OUTPTRPAR(pVal);
+ CComPtr<IMgaFolder> f;
+ COMTHROW(get_RootFolder(&f));
+ COMTHROW(f->get_NthObjectByPath(n_th, path, pVal));
+ } COMCATCH(;);
+ }
// ----------------------------------------
Index: MgaProject.h
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/Mga/MgaProject.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** MgaProject.h 20 Jul 2004 16:01:39 -0000 1.26
--- MgaProject.h 27 Sep 2004 21:40:09 -0000 1.27
***************
*** 119,122 ****
--- 119,123 ----
STDMETHOD(GetStatistics)(BSTR *statstr);
STDMETHOD(get_ObjectByPath)(BSTR path, IMgaObject **pVal);
+ STDMETHOD(get_NthObjectByPath)(long n_th, BSTR path, IMgaObject **pVal);
STDMETHOD(GetFolderByPath)(BSTR path, IMgaFolder **pVal);
STDMETHOD(GetFCOsByName)(BSTR name, IMgaFCOs **pVal);
- Previous message: [GME-commit]
GMESRC/GME/Parser Helper.cpp,NONE,1.1 Helper.h,NONE,1.1
MgaParserBC.cpp,NONE,1.1 MgaParserClosureHelper.cpp,NONE,1.1
MgaParserSC.cpp,NONE,1.1 mgaclosure.dtd,NONE,1.1
MgaDumper.cpp,1.18,1.19 MgaDumper.h,1.11,1.12
MgaParser.cpp,1.24,1.25 MgaParser.h,1.9,1.10 Parser.dsp,1.13,1.14
mga.dtd,1.9,1.10
- Next message: [GME-commit] GMESRC/GME/MgaUtil ClosureKindSel.cpp,NONE,1.1
ClosureKindSel.h,NONE,1.1 ClosureSmart.cpp,NONE,1.1
ClosureSmart.h,NONE,1.1 ClosureDlg.cpp,1.3,1.4 ClosureDlg.h,1.3,1.4
MakeClosure.cpp,1.8,1.9 MakeClosure.h,1.4,1.5
MgaClosure.cpp,1.3,1.4 MgaClosure.h,1.2,1.3 MgaUtil.dsp,1.24,1.25
MgaUtil.rc,1.40,1.41 resource.h,1.25,1.26
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the GME-commit
mailing list