[GME-commit] GMESRC/GME/Mga MgaFCO.h,1.27,1.28 MgaFCO.cpp,1.37,1.38
MgaLibOps.h,1.5,1.6 MgaLibOps.cpp,1.16,1.17 MgaLibRefr.h,1.2,1.3
MgaLibRefr.cpp,1.4,1.5 MgaTrukk.h,1.20,1.21
gme-commit at list.isis.vanderbilt.edu
gme-commit at list.isis.vanderbilt.edu
Fri Feb 2 21:00:21 CST 2007
Update of /project/gme-repository/GMESRC/GME/Mga
In directory escher:/tmp/cvs-serv16665
Modified Files:
MgaFCO.h MgaFCO.cpp MgaLibOps.h MgaLibOps.cpp MgaLibRefr.h
MgaLibRefr.cpp MgaTrukk.h
Log Message:
Library refresh with optimalization, beta2 version.
CVS User: Zoltan Molnar, ISIS (zolmol)
Index: MgaTrukk.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaTrukk.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** MgaTrukk.h 26 Jan 2005 17:30:49 -0000 1.20
--- MgaTrukk.h 2 Feb 2007 21:00:18 -0000 1.21
***************
*** 316,320 ****
// if they still may occur (e.g. RevertToBase), use the 'endreserve' parameter to
// explicitly indicate that they are not internals
! class DeriveTreeTask {
protected:
int peercnt, internalpeercnt;
--- 316,320 ----
// if they still may occur (e.g. RevertToBase), use the 'endreserve' parameter to
// explicitly indicate that they are not internals
! /*class DeriveTreeTask {
protected:
int peercnt, internalpeercnt;
***************
*** 329,333 ****
DeriveTreeTask() : endreserve(0), masterattr(0) { };
void DoWithDeriveds(CoreObj self, std::vector<CoreObj> *peers = NULL);
! };
--- 329,333 ----
DeriveTreeTask() : endreserve(0), masterattr(0) { };
void DoWithDeriveds(CoreObj self, std::vector<CoreObj> *peers = NULL);
! };*/
Index: MgaLibRefr.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaLibRefr.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MgaLibRefr.h 18 Jan 2007 16:54:10 -0000 1.2
--- MgaLibRefr.h 2 Feb 2007 21:00:18 -0000 1.3
***************
*** 167,171 ****
// if inlib the uid, else id is filled
// we could have used a union as well
! bool inlib;
};
--- 167,173 ----
// if inlib the uid, else id is filled
// we could have used a union as well
! bool inverysamelib;
!
! bool inanotherlib;
};
***************
*** 426,429 ****
--- 428,432 ----
public:
//static std::list<BinGuid> m_sLibIdStack; // the search position is inside the topmost library right now
+ static bool m_optimized; // if the current operation in progress is optimized?
static CComPtr<IMgaFCO> findLibObj(CoreObj& folder, const UniqueId& p_toFind, const BinGuid& p_inLib = BinGuid())
***************
*** 473,477 ****
}
! if( folder) // && if optimized libraries are present // TODO
{
CoreObj parnt = folder[ATTRID_FCOPARENT];
--- 476,480 ----
}
! if( folder && m_optimized) // current operation in progress is optimized
{
CoreObj parnt = folder[ATTRID_FCOPARENT];
***************
*** 489,493 ****
{
BinGuid act_lib_id = Identifier::getPersistentIdOf( ITER);
! if( p_toFind.libId == act_lib_id)
{
CComPtr<IMgaFCO> fco = findLibObj( ITER, p_toFind);
--- 492,497 ----
{
BinGuid act_lib_id = Identifier::getPersistentIdOf( ITER);
! if( p_toFind.libId == act_lib_id // proper toplevel library found
! && act_lib_id != act_lib_cursor) // is not the very same the search already has analyzed
{
CComPtr<IMgaFCO> fco = findLibObj( ITER, p_toFind);
***************
*** 506,510 ****
static CComPtr<IMgaFCO> findObjWithDetails( CMgaProject *mgaproject, CoreObj& folder, elem_struct& elem)
{
! if( elem.inlib)
return findLibObj( folder, elem.uid);
else
--- 510,514 ----
static CComPtr<IMgaFCO> findObjWithDetails( CMgaProject *mgaproject, CoreObj& folder, elem_struct& elem)
{
! if( elem.inverysamelib)//if( elem.inlib)
return findLibObj( folder, elem.uid);
else
***************
*** 560,563 ****
--- 564,588 ----
}
+ static CoreObj findLibraryWithId( CoreObj& p_folder, PROJ_ID& p_libId)
+ {
+ ITERATE_THROUGH( p_folder[ ATTRID_FCOPARENT + ATTRID_COLLECTION])
+ {
+ metaid_type mi = ITER.GetMetaID();
+ if( mi == DTID_FOLDER)
+ {
+ long pm = ITER[ATTRID_PERMISSIONS];
+ if( pm & LIBROOT_FLAG)
+ {
+ CComBSTR id;
+ ObjForCore( ITER)->get_ID( &id);
+ if( id == p_libId)
+ return ITER;
+ }
+ }
+ }
+
+ return CoreObj();
+ }
+
};
***************
*** 570,578 ****
{
public:
! RefreshManager( CMgaProject *p_mgaproject, CoreObj& p_oldRoot, CoreObj& p_newRoot)
: m_mgaproject( p_mgaproject)
, m_newLib( p_newRoot)
, m_oldLib( p_oldRoot)
, m_reporter( p_mgaproject)
{
}
--- 595,604 ----
{
public:
! RefreshManager( CMgaProject *p_mgaproject, CoreObj& p_oldRoot, CoreObj& p_newRoot, bool p_isIncluded)
: m_mgaproject( p_mgaproject)
, m_newLib( p_newRoot)
, m_oldLib( p_oldRoot)
, m_reporter( p_mgaproject)
+ , m_isVirtuallyIncluded( p_isIncluded)
{
}
***************
*** 583,587 ****
CoreObj m_oldLib;
Reporter m_reporter;
!
// for reference recreating
//typedef std::vector< PROJ_ID > REFERENCES_VEC;
--- 609,613 ----
CoreObj m_oldLib;
Reporter m_reporter;
! bool m_isVirtuallyIncluded;
// for reference recreating
//typedef std::vector< PROJ_ID > REFERENCES_VEC;
***************
*** 772,776 ****
// TODO: this project guid changes every time the project
// is modified (?)
! std::vector<BinGuid> m_changedLibs;
// -----------------------------COLLECTORS & RESTORERS----------------------------
void reapplyLibFlagToChangedLibs();
--- 798,803 ----
// TODO: this project guid changes every time the project
// is modified (?)
! std::vector<PROJ_ID> m_changedLibs;
! void addChangedLib( elem_struct& elem);
// -----------------------------COLLECTORS & RESTORERS----------------------------
void reapplyLibFlagToChangedLibs();
***************
*** 907,910 ****
--- 934,967 ----
};
+ class Creator
+ {
+ public:
+ static const CComBSTR SrcName; // keep in sync with FCO::SrcName in MgaConnection.cpp
+ static const CComBSTR DstName; // keep in sync with FCO::DstName
+
+ static HRESULT SimpleConn( CComPtr<IMgaModel>& p_parent
+ , CComPtr<IMgaMetaRole>& p_mrole
+ , CComPtr<IMgaFCO>& p_src
+ , CComPtr<IMgaFCO>& p_dst
+ , CComPtr<IMgaFCOs>& p_srcRefs
+ , CComPtr<IMgaFCOs>& p_dstRefs
+ , CMgaProject* p_mgaProject
+ , IMgaFCO** p_newConn);
+
+ private:
+ static HRESULT Child ( CMgaProject* p_mgaProject, CComPtr<IMgaFCO>& p_parent, CComPtr<IMgaMetaRole>& metar, IMgaFCO **newobj);
+
+ static HRESULT put_NamedRole ( CMgaProject* p_mgaProject, CComPtr<IMgaFCO>& p_conn, BSTR p_rolename, IMgaFCOs* p_refs, IMgaFCO* p_endfco);
+ static HRESULT AddConnPoint ( CMgaProject* p_mgaProject, CComPtr<IMgaFCO>& p_conn, BSTR p_rolename, long p_maxinrole, IMgaFCO* p_target, IMgaFCOs* p_refs, IMgaConnPoint** pVal);
+ };
+
+ class Worker
+ {
+ public:
+ static HRESULT put_Name ( CMgaProject* p_mgaProject, CComPtr<IMgaFCO>& p_elem, CComBSTR p_newVal);
+ static HRESULT PutGuidDisp ( CMgaProject* p_mgaProject, CComPtr<IMgaFCO>& p_elem, CComBSTR p_guidStr);
+ private:
+ static HRESULT PutGuid ( CMgaProject* p_mgaProject, CComPtr<IMgaFCO>& p_elem, long l1, long l2, long l3, long l4);
+ };
#endif
Index: MgaFCO.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaFCO.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** MgaFCO.cpp 21 Jul 2006 19:11:40 -0000 1.37
--- MgaFCO.cpp 2 Feb 2007 21:00:18 -0000 1.38
***************
*** 10,14 ****
#include "MgaSet.h"
-
// ----------------------------------------
// Constructor, destructor, FinalConstruct, getinterace
--- 10,13 ----
***************
*** 353,357 ****
! class put_NameTask : public DeriveTreeTask {
CComBSTR oldname, newname;
--- 352,356 ----
! /*class put_NameTask : public DeriveTreeTask {
CComBSTR oldname, newname;
***************
*** 376,380 ****
public:
put_NameTask(BSTR oname, BSTR nname) : oldname(oname), newname(nname) { ; }
! };
--- 375,399 ----
public:
put_NameTask(BSTR oname, BSTR nname) : oldname(oname), newname(nname) { ; }
! };*/
!
! put_NameTask::put_NameTask(BSTR oname, BSTR nname) : oldname(oname), newname(nname) { ; }
!
! bool put_NameTask::Do(CoreObj self, std::vector<CoreObj> *peers /*= NULL*/) {
! if(!(oldname == CComBSTR(self[ATTRID_NAME]))) return false;
! if(ObjForCore(self)->mgaproject->preferences & MGAPREF_NODUPLICATENAMES) {
! CoreObj parent = self[ATTRID_PARENT];
! if(parent.GetMetaID() != DTID_ROOT) { // Make sure it is not rootfolder (=parent is not rootobj)
! CoreObjs children = parent[ATTRID_PARENT+ATTRID_COLLECTION];
! ITERATE_THROUGH(children) {
! CComBSTR n = ITER[ATTRID_NAME];
! if(n == newname && !COM_EQUAL(self, ITER)) COMTHROW(E_MGA_NAME_DUPLICATE);
! }
! }
! }
! self[ATTRID_NAME] = newname;
! ObjForCore(self)->SelfMark(OBJEVENT_PROPERTIES);
! if(self.IsFCO() && self.IsRootOfDeriv()) return false; // Type renaming does not affect instances
! return true;
! }
Index: MgaLibOps.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaLibOps.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** MgaLibOps.cpp 25 Jan 2007 17:48:30 -0000 1.16
--- MgaLibOps.cpp 2 Feb 2007 21:00:18 -0000 1.17
***************
*** 124,128 ****
/* *************************** Attach ********************************************* */
! void ObjTreeCopyFromExt(CMgaProject *mgaproject, const CoreObj &orig, CoreObj &nobj, PointerFixup &fixup, std::vector< std::pair< CoreObj, CoreObj > >& p_libPairs/*, bool refresh*/, std::vector< CoreObj >& p_superfluousLibs) {
metaid_type s;
COMTHROW(mgaproject->dataproject->CreateObject(s = orig.GetMetaID(), &nobj.ComPtr()));
--- 124,128 ----
/* *************************** Attach ********************************************* */
! void ObjTreeCopyFromExt(CMgaProject *mgaproject, const CoreObj &orig, CoreObj &nobj, PointerFixup &fixup, std::vector< std::pair< CoreObj, CoreObj > >& p_libPairs/*, bool refresh*/, std::vector< CoreObj >& p_superfluousLibs, bool p_indupl) {
metaid_type s;
COMTHROW(mgaproject->dataproject->CreateObject(s = orig.GetMetaID(), &nobj.ComPtr()));
***************
*** 193,197 ****
}
else {
! fixup.resolve(orig, nobj, ai);
}
}
--- 193,197 ----
}
else {
! fixup.resolve(orig, nobj, ai, p_indupl || skip_this);
}
}
***************
*** 202,206 ****
ITERATE_THROUGH(collmembers) {
CoreObj nchild;
! ObjTreeCopyFromExt(mgaproject, ITER, nchild, fixup, p_libPairs/*, refresh*/, p_superfluousLibs);
nchild[ai] = nobj;
}
--- 202,206 ----
ITERATE_THROUGH(collmembers) {
CoreObj nchild;
! ObjTreeCopyFromExt(mgaproject, ITER, nchild, fixup, p_libPairs/*, refresh*/, p_superfluousLibs, p_indupl || skip_this);
nchild[ai] = nobj;
}
***************
*** 215,218 ****
--- 215,220 ----
CComPtr<IMgaProject> p;
PointerFixup fixup;
+ std::vector< CoreObj > superfluousLibs;
+ std::vector< std::pair< CoreObj, CoreObj > > lib_pairs;
try {
COMTHROW(p.CoCreateInstance(CLSID_MgaProject));
***************
*** 309,316 ****
}
COMTHROW(p->OpenEx( upgraded?connstr_upgraded:connstr, paradigmname, paradigmGUID));
! std::vector< CoreObj > superfluousLibs;
! std::vector< std::pair< CoreObj, CoreObj > > lib_pairs;
COMTHROW(p->BeginTransaction(NULL, TRANSACTION_READ_ONLY));
--- 311,320 ----
}
+ try
+ {
COMTHROW(p->OpenEx( upgraded?connstr_upgraded:connstr, paradigmname, paradigmGUID));
! //std::vector< CoreObj > superfluousLibs;
! //std::vector< std::pair< CoreObj, CoreObj > > lib_pairs;
COMTHROW(p->BeginTransaction(NULL, TRANSACTION_READ_ONLY));
***************
*** 372,386 ****
{
fixup.setLibPairs( lib_pairs);
! ObjTreeCopyFromExt(mgaproject, CoreObj(libroot), libimgroot, fixup, lib_pairs, superfluousLibs);
}
else
{
std::vector< std::pair< CoreObj, CoreObj > > e_lib_pairs; // empty lib_pairs
! ObjTreeCopyFromExt(mgaproject, CoreObj(libroot), libimgroot, fixup, e_lib_pairs, superfluousLibs);
}
}
fixup.fixPointers();
!
!
//*************************************************
// deleting the superfl. libs
--- 376,396 ----
{
fixup.setLibPairs( lib_pairs);
! ObjTreeCopyFromExt(mgaproject, CoreObj(libroot), libimgroot, fixup, lib_pairs, superfluousLibs, false);
}
else
{
std::vector< std::pair< CoreObj, CoreObj > > e_lib_pairs; // empty lib_pairs
! ObjTreeCopyFromExt(mgaproject, CoreObj(libroot), libimgroot, fixup, e_lib_pairs, superfluousLibs, false);
}
}
fixup.fixPointers();
! }
! catch(...)
! {
! int l( 0);
! ++l;
! }
! try
! {
//*************************************************
// deleting the superfl. libs
***************
*** 391,396 ****
{
ASSERT( lw.isOptimized());
//delete it->first
! ObjForCore(*it)->inDeleteObject();
//CoreObj lib2root = it->first;
//long p1 = lib2root[ATTRID_PERMISSIONS];
--- 401,421 ----
{
ASSERT( lw.isOptimized());
+
+ CComBSTR nm, id;
+ nm = (*it)[ATTRID_NAME];
+ ObjForCore( *it)->get_ID( &id);
+
//delete it->first
! try {
! ObjForCore(*it)->inDeleteObject();
! } catch(...){
! CComBSTR msg( "Error during deleting superfluous library ");
! msg.AppendBSTR( nm);
! msg.Append( " [ ");
! msg.AppendBSTR( id);
! msg.Append( " ] ");
!
! Reporter::showIt( mgaproject, msg);
! }
//CoreObj lib2root = it->first;
//long p1 = lib2root[ATTRID_PERMISSIONS];
***************
*** 441,446 ****
--- 466,478 ----
COMTHROW(p->AbortTransaction());
COMTHROW(p->Close());
+ } catch(...)
+ {
+ int k = 0;
+ ++k;
+ }
} catch(...) {
fixup.clear();
+ superfluousLibs.clear();
+ lib_pairs.clear();
if(p) {
long st;
***************
*** 460,463 ****
--- 492,496 ----
LibWorker::LIB_MAP top_libs;
LibWorker lw( mgaproject, libname);
+ SearchTool::m_optimized = lw.isOptimized();
LibWorker::recordLibs( false, self, top_libs); // consider existing toplibs only
***************
*** 631,634 ****
--- 664,668 ----
LibWorker lw( mgaproject, libname);
+ SearchTool::m_optimized = lw.isOptimized();
if( mgaproject) Reporter::showIt( mgaproject, CComBSTR( "Examining the whole project"), false);
***************
*** 726,730 ****
Reporter( mgaproject).show( msg, false);
! RefreshManager rm( mgaproject, self, libimgroot);
ASSERT( Identifier::isLibRoot( self));
--- 760,764 ----
Reporter( mgaproject).show( msg, false);
! RefreshManager rm( mgaproject, self, libimgroot, Ozer::isIncluded( self));
ASSERT( Identifier::isLibRoot( self));
***************
*** 1014,1017 ****
--- 1048,1058 ----
}
+ bool Ozer::isIncluded( CoreObj& p_fldCore)
+ {
+ CComBSTR idlist;
+ StorageMgr::getIncludedBy( p_fldCore, idlist);
+ return idlist && idlist.Length() > 0; // if included by somebody
+ }
+
void Ozer::findReplace( CMgaProject* p_mgaproject
, CoreObj& p_libimgroot
***************
*** 1026,1048 ****
ObjForCore( p_newlibimgroot)->get_ID( &lib_id_to_add);
! const std::string& includes_vals = p_tokenizable;
!
! // skip parsing if empty
! std::string::size_type pos = includes_vals.empty()? std::string::npos : 0;
! std::string::size_type last_pos = pos-1;
! while( pos != std::string::npos)
{
- pos = includes_vals.find('\n', last_pos+1);
-
- std::string token;
- if( pos == std::string::npos)
- token = includes_vals.substr( last_pos+1);
- else
- token = includes_vals.substr( last_pos+1, pos - last_pos-1);
-
- last_pos = pos;
-
CoreObj lib;
! if( Ozer::findLibObj( p_mgaproject, token, lib))
{
bool lib_freed = false;
--- 1067,1074 ----
ObjForCore( p_newlibimgroot)->get_ID( &lib_id_to_add);
! for( Ozer::DependentIterator it( p_tokenizable); !it.isDone(); it.next())
{
CoreObj lib;
! if( Ozer::findLibObj( p_mgaproject, it.getCurrentStr(), lib))
{
bool lib_freed = false;
***************
*** 1053,1057 ****
}
}
-
}
--- 1079,1082 ----
***************
*** 1076,1113 ****
findReplace( p_mgaproject, p_libimgroot, p_newlibimgroot, vals, p_depsOrIncs);
}
-
-
- /* // don't have to remove this regnode, because the this is the old
- // top lib regnode which will be discarded
-
- // we have to remove the dependency entry in each of these libraries
- // listed in the regnode
- std::string includes_vals;
- CopyTo( includes_valb, includes_vals);
- // skip parsing if empty
- std::string::size_type pos = includes_vals.empty()? std::string::npos : 0;
- std::string::size_type last_pos = pos-1;
- while( pos != std::string::npos)
- {
- pos = includes_vals.find('\n', last_pos+1);
-
- std::string token;
- if( pos == std::string::npos)
- token = includes_vals.substr( last_pos+1);
- else
- token = includes_vals.substr( last_pos+1, pos - last_pos-1);
-
- last_pos = pos;
-
- CComBSTR lib_id_to_remove;
- ObjForCore( p_libimgroot)->get_ID( &lib_id_to_remove);
-
- CoreObj lib;
- if( Ozer::findLibObj( p_mgaproject, token, lib))
- {
- bool lib_freed = false;
- bool all_right = Ozer::loseIncludedBy( lib, lib_id_to_remove, lib_freed);
- }
- }*/
}
--- 1101,1104 ----
***************
*** 1364,1366 ****
--- 1355,1400 ----
CComBSTR path( INCLUDED_BY_STR);
writer( p_fldCore, path, p_idList);
+ }
+
+
+ Ozer::DependentIterator::DependentIterator( const CComBSTR& p_tokenizable)
+ {
+ CopyTo( p_tokenizable, m_tokenizable);
+
+ m_pos = m_tokenizable.empty()? std::string::npos : 0;
+ m_nextPos = m_tokenizable.find('\n', m_pos + 1);
+ }
+
+ Ozer::DependentIterator::DependentIterator( const std::string& p_tokenizable)
+ : m_tokenizable( p_tokenizable)
+ {
+ m_pos = m_tokenizable.empty()? std::string::npos : 0;
+ m_nextPos = m_tokenizable.find('\n', m_pos + 1);
+ }
+
+ bool Ozer::DependentIterator::isDone()
+ {
+ return m_pos == std::string::npos;
+ }
+
+ void Ozer::DependentIterator::next()
+ {
+ m_pos = m_nextPos;
+ if( !isDone())
+ m_nextPos = m_tokenizable.find('\n', m_pos + 1);
+ }
+
+ std::string Ozer::DependentIterator::getCurrentStr()
+ {
+ if( m_nextPos == std::string::npos)
+ return m_tokenizable.substr( m_pos + ( m_pos == 0?0:1));
+ else
+ return m_tokenizable.substr( m_pos + ( m_pos == 0?0:1), m_nextPos - m_pos - ( m_pos == 0?0:1));
+ }
+
+ CComBSTR Ozer::DependentIterator::getCurrentBstr()
+ {
+ CComBSTR retv;
+ CopyTo( getCurrentStr(), &retv);
+ return retv;
}
Index: MgaFCO.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaFCO.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** MgaFCO.h 19 May 2006 18:35:31 -0000 1.27
--- MgaFCO.h 2 Feb 2007 21:00:18 -0000 1.28
***************
*** 576,579 ****
--- 576,603 ----
};
+ class DeriveTreeTask {
+ protected:
+ int peercnt, internalpeercnt;
+ int endreserve; // the number of 'reserved' coreobjs at the end of the vector
+ attrid_type masterattr;
+ private:
+ std::vector<int> peerdepths;
+ int selfdepth;
+ virtual bool Do(CoreObj self, std::vector<CoreObj> *peers = NULL) = 0;
+ void _DoWithDeriveds(CoreObj self, std::vector<CoreObj> *peers = NULL);
+ public:
+ DeriveTreeTask() : endreserve(0), masterattr(0) { };
+ void DoWithDeriveds(CoreObj self, std::vector<CoreObj> *peers = NULL);
+ };
+
+ class put_NameTask : public DeriveTreeTask {
+ CComBSTR oldname, newname;
+
+ bool Do(CoreObj self, std::vector<CoreObj> *peers = NULL);
+ public:
+ put_NameTask(BSTR oname, BSTR nname);
+ };
+
+
inline FCO *ObjForCore(ICoreObject *s) {
Index: MgaLibRefr.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaLibRefr.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** MgaLibRefr.cpp 25 Jan 2007 17:48:30 -0000 1.4
--- MgaLibRefr.cpp 2 Feb 2007 21:00:18 -0000 1.5
***************
*** 3,6 ****
--- 3,7 ----
#include "MgaLibOps.h"
#include "MgaComplexOps.h"
+ #include "MgaConnection.h"
#define DONT_OPTIM 0
***************
*** 8,11 ****
--- 9,15 ----
void steal(CoreObj &o, CoreObj &n, attrid_type ai);
+ /*static*/
+ bool SearchTool::m_optimized = false;
+
short RefreshManager::distance( CoreObj& derd)
{
***************
*** 32,41 ****
VARIANT_BOOL in_lib;
COMTHROW( peer->get_IsLibObject( &in_lib));
! if( in_lib == VARIANT_TRUE) // has guid, other things will change
{
CoreObj cp( peer);
elem.uid = Identifier::getDetailsOf( cp);
! elem.inlib = true;
}
else // in project, must not have guid
--- 36,66 ----
VARIANT_BOOL in_lib;
COMTHROW( peer->get_IsLibObject( &in_lib));
! bool in_refrd_lib = false; // in the refreshed lib exactly?
! if( in_lib == VARIANT_TRUE)
! {
! BinGuid libgd1, libgd2;
! libgd1 = Identifier::getTopLibRootOf( CoreObj( peer));
! libgd2 = Identifier::getTopLibRootOf( m_oldLib);
! in_refrd_lib = libgd1 == libgd2;
! }
!
! // if m_oldlib is virtually included there might be dependent elements (like subtypes)
! // in other libraries (a previous container library)
! // from the Refresh's perspective those elements are fixed elements (can be found based on ID)
! // and are not found by the SearchTool methods which look down from a given container element
! // usually the new version of the refreshed library: m_newLib
! // these libraries can be refreshed either with or without the optimized flag (that's why we
! // rely on m_isIncluded rather than on SearchTool::m_optimized
!
! // if optimized then additional conditions apply
! // if !optimized then in_lib is enough
! if( in_lib == VARIANT_TRUE && !m_isVirtuallyIncluded
! || in_refrd_lib && m_isVirtuallyIncluded) // has guid, other things will change
{
CoreObj cp( peer);
elem.uid = Identifier::getDetailsOf( cp);
! elem.inverysamelib = true;//elem.inlib = true;
! elem.inanotherlib = false;
}
else // in project, must not have guid
***************
*** 44,48 ****
COMTHROW( peer->get_ID( &id));
elem.id = id;
! elem.inlib = false;
}
}
--- 69,74 ----
COMTHROW( peer->get_ID( &id));
elem.id = id;
! elem.inverysamelib = false;//elem.inlib = false;
! elem.inanotherlib = in_lib == VARIANT_TRUE;
}
}
***************
*** 52,59 ****
VARIANT_BOOL in_lib;
COMTHROW( ObjForCore(peer)->get_IsLibObject( &in_lib));
! if( in_lib == VARIANT_TRUE) // has guid, other things will change
{
elem.uid = Identifier::getDetailsOf( peer);
! elem.inlib = true;
}
else // in project, must not have guid
--- 78,98 ----
VARIANT_BOOL in_lib;
COMTHROW( ObjForCore(peer)->get_IsLibObject( &in_lib));
! bool in_refrd_lib = false; // in the refreshed lib exactly?
! if( in_lib == VARIANT_TRUE)
! {
! BinGuid libgd1, libgd2;
! libgd1 = Identifier::getTopLibRootOf( peer);
! libgd2 = Identifier::getTopLibRootOf( m_oldLib);
! in_refrd_lib = libgd1 == libgd2;
! }
!
! // if optimized then additional conditions apply
! // if !optimized then in_lib is enough
! if( in_lib == VARIANT_TRUE && !m_isVirtuallyIncluded
! || in_refrd_lib && m_isVirtuallyIncluded) // has guid, other things will change
{
elem.uid = Identifier::getDetailsOf( peer);
! elem.inverysamelib = true;//elem.inlib = true;
! elem.inanotherlib = false;
}
else // in project, must not have guid
***************
*** 62,66 ****
COMTHROW( ObjForCore(peer)->get_ID( &id));
elem.id = id;
! elem.inlib = false;
}
}
--- 101,106 ----
COMTHROW( ObjForCore(peer)->get_ID( &id));
elem.id = id;
! elem.inverysamelib = false;//elem.inlib = false;
! elem.inanotherlib = in_lib == VARIANT_TRUE;
}
}
***************
*** 95,99 ****
getElemDetails( base, elem_base);
! if( elem_base.inlib
&& Identifier::getTopLibRootOf( CoreObj( p_tgt)) == Identifier::getTopLibRootOf( CoreObj(base)))
*p_derdFromTheSameLib = true; // sec.derd ref from the same library as its target
--- 135,140 ----
getElemDetails( base, elem_base);
! //if( elem_base.inlib
! if( elem_base.inverysamelib // TODO?
&& Identifier::getTopLibRootOf( CoreObj( p_tgt)) == Identifier::getTopLibRootOf( CoreObj(base)))
*p_derdFromTheSameLib = true; // sec.derd ref from the same library as its target
***************
*** 144,148 ****
getElemDetails( topmost_base, elem_topbase);
! if( elem_topbase.inlib
&& Identifier::getTopLibRootOf( CoreObj( p_tgt)) == Identifier::getTopLibRootOf( CoreObj( topmost_base)))
*p_derdFromTheSameLib = true; // actually derd ref from the same library as its target
--- 185,190 ----
getElemDetails( topmost_base, elem_topbase);
! //if( elem_topbase.inlib
! if( elem_topbase.inverysamelib // TODO?
&& Identifier::getTopLibRootOf( CoreObj( p_tgt)) == Identifier::getTopLibRootOf( CoreObj( topmost_base)))
*p_derdFromTheSameLib = true; // actually derd ref from the same library as its target
***************
*** 233,237 ****
elem_struct arch_info;
getElemDetails( arch, arch_info);
! if( arch_info.inlib) // the connection's basetype is in the library
{
one_conn.baseConnId = arch_info.uid;
--- 275,279 ----
elem_struct arch_info;
getElemDetails( arch, arch_info);
! if( arch_info.inverysamelib) // TODO? //if( arch_info.inlib) // the connection's basetype is in the library
{
one_conn.baseConnId = arch_info.uid;
***************
*** 278,281 ****
--- 320,331 ----
}
+ void RefreshManager::addChangedLib( elem_struct& elem)
+ {
+ if( !elem.inanotherlib) return;
+
+ if( m_changedLibs.end() == std::find( m_changedLibs.begin(), m_changedLibs.end(), elem.id))
+ m_changedLibs.push_back( elem.id);
+ }
+
void RefreshManager::collectMixedConns( CoreObj& one_fco)
{
***************
*** 302,316 ****
elem_struct elem_conn;
getElemDetails( CComQIPtr<IMgaFCO>( owner), elem_conn);
! if( in_lib == VARIANT_TRUE && elem_conn.inlib) // which lib? it matters!
{
! if( elem_conn.uid.libId == Identifier::getLibRootOf( one_fco))
continue;
else
if( m_changedLibs.end() == std::find( m_changedLibs.begin(), m_changedLibs.end(), elem_conn.uid.libId))
m_changedLibs.push_back( elem_conn.uid.libId);
! }
/*if( in_lib == VARIANT_TRUE) // the connection also in the library
continue;*/
CComPtr<IMgaFCO> myself;
--- 352,373 ----
elem_struct elem_conn;
getElemDetails( CComQIPtr<IMgaFCO>( owner), elem_conn);
! /*if( in_lib == VARIANT_TRUE && elem_conn.inlib) // which lib? it matters!
{
! if( elem_conn.uid.libId == Identifier::getLibRootOf( one_fco)
! || elem_conn.uid.libId == Identifier::getTopLibRootOf( one_fco)
! )
continue;
else
if( m_changedLibs.end() == std::find( m_changedLibs.begin(), m_changedLibs.end(), elem_conn.uid.libId))
m_changedLibs.push_back( elem_conn.uid.libId);
! }*/
/*if( in_lib == VARIANT_TRUE) // the connection also in the library
continue;*/
+ if( elem_conn.inverysamelib)
+ continue;
+ //WAS//
+ //else if( elem_conn.inanotherlib)
+ // addChangedLib( elem_conn);
CComPtr<IMgaFCO> myself;
***************
*** 327,331 ****
if( one_conn.is_derived && one_conn.is_sec_derived)
{
! if( one_conn.baseConnId.libId != Identifier::getLibRootOf( one_fco)) // which lib? it matters!
continue;
}
--- 384,390 ----
if( one_conn.is_derived && one_conn.is_sec_derived)
{
! if( one_conn.baseConnId.libId != Identifier::getLibRootOf( one_fco)
! || one_conn.baseConnId.libId != Identifier::getTopLibRootOf( one_fco)
! ) // which lib? it matters!
continue;
}
***************
*** 495,502 ****
try {
CComPtr<IMgaFCO> new_conn;
! COMTHROW( pM->CreateSimpleConn( metarole, s, d, sref_chain, dref_chain, &new_conn));
! COMTHROW( new_conn->put_Name( current_i.connname));
! COMTHROW( new_conn->PutGuidDisp( current_i.guid));
loadSavedStuff( new_conn, current_i);
--- 554,564 ----
try {
CComPtr<IMgaFCO> new_conn;
! //COMTHROW( pM->CreateSimpleConn( metarole, s, d, sref_chain, dref_chain, &new_conn));
! COMTHROW( Creator::SimpleConn( pM, metarole, s, d, sref_chain, dref_chain, m_mgaproject, &new_conn));
! //COMTHROW( new_conn->put_Name( current_i.connname));
! COMTHROW( Worker::put_Name( m_mgaproject, new_conn, current_i.connname));
! //COMTHROW( new_conn->PutGuidDisp( current_i.guid));
! COMTHROW( Worker::PutGuidDisp( m_mgaproject, new_conn, current_i.guid));
loadSavedStuff( new_conn, current_i);
***************
*** 522,526 ****
msg.appendLink( new_conn);
#ifdef _DEBUG
! //CComBSTR ncid; new_conn->get_ID( &ncid); msg.AppendBSTR( ncid);if( current_i.is_derived && current_i.is_sec_derived) msg.Append( L" napofsec "); else msg.Append( L" reg ");
#endif
msg.Append( L" reconstructed in ");
--- 584,588 ----
msg.appendLink( new_conn);
#ifdef _DEBUG
! CComBSTR ncid; new_conn->get_ID( &ncid); msg.AppendBSTR( ncid);if( current_i.is_derived && current_i.is_sec_derived) msg.Append( L" napofsec "); else msg.Append( L" reg ");
#endif
msg.Append( L" reconstructed in ");
***************
*** 1136,1141 ****
CComPtr<IMgaFCO> new_conn;
try {
! COMTHROW( pM->CreateSimpleConn( i_conn.b_conn_role, s, d, sref_chain, dref_chain, &new_conn));
! COMTHROW( new_conn->put_Name( current_i.connname));
m_coreMatchMaker[ CoreObj(new_conn)] = CoreObj(i_conn.b_conn);
--- 1198,1205 ----
CComPtr<IMgaFCO> new_conn;
try {
! //COMTHROW( pM->CreateSimpleConn( i_conn.b_conn_role, s, d, sref_chain, dref_chain, &new_conn));
! COMTHROW( Creator::SimpleConn( pM, i_conn.b_conn_role, s, d, sref_chain, dref_chain, m_mgaproject, &new_conn));
! //COMTHROW( new_conn->put_Name( current_i.connname));
! COMTHROW( Worker::put_Name( m_mgaproject, new_conn, current_i.connname));
m_coreMatchMaker[ CoreObj(new_conn)] = CoreObj(i_conn.b_conn);
***************
*** 1155,1158 ****
--- 1219,1225 ----
msg.Append( L" reconstructed in ");
msg.appendLink( pM);
+ #ifdef _DEBUG
+ CComBSTR ncid, pmid; new_conn->get_ID( &ncid); msg.AppendBSTR( ncid); msg.Append( " "); pM->get_ID( &pmid); msg.AppendBSTR( pmid);
+ #endif
m_reporter.show( msg, false);
***************
*** 1312,1321 ****
m_reporter.show( ms2, false);
! COMTHROW( curr_i.par->CreateSimpleConn( curr_i.mrole,
curr_i.src, curr_i.dst,
! curr_i.srcRefs, curr_i.dstRefs, &resu));
! COMTHROW( resu->put_Name( curr_i.nm));
! COMTHROW( resu->PutGuidDisp( curr_i.guid));
MyCComBSTR msg( "Succesfully recreated (prev. deleted) ");
--- 1379,1393 ----
m_reporter.show( ms2, false);
! /*COMTHROW( curr_i.par->CreateSimpleConn( curr_i.mrole,
curr_i.src, curr_i.dst,
! curr_i.srcRefs, curr_i.dstRefs, &resu));*/
! COMTHROW( Creator::SimpleConn( curr_i.par, curr_i.mrole,
! curr_i.src, curr_i.dst,
! curr_i.srcRefs, curr_i.dstRefs, m_mgaproject, &resu));
! //COMTHROW( resu->put_Name( curr_i.nm));
! COMTHROW( Worker::put_Name( m_mgaproject, resu, curr_i.nm));
! //COMTHROW( resu->PutGuidDisp( curr_i.guid));
! COMTHROW( Worker::PutGuidDisp( m_mgaproject, resu, curr_i.guid));
MyCComBSTR msg( "Succesfully recreated (prev. deleted) ");
***************
*** 2269,2277 ****
COMTHROW( ObjForCore( m_newLib)->get_ID( &id));
! for( std::vector<BinGuid>::iterator it = m_changedLibs.begin()
; it != m_changedLibs.end()
; ++it)
{
! CoreObj libroot = SearchTool::findLibrary( root_cor, *it);
ASSERT( libroot);
if( libroot)
--- 2341,2361 ----
COMTHROW( ObjForCore( m_newLib)->get_ID( &id));
! CComBSTR idlist;
! Ozer::StorageMgr::getIncludedBy( m_oldLib, idlist);
! for( Ozer::DependentIterator it( idlist); !it.isDone(); it.next())
! {
! CoreObj libroot = SearchTool::findLibraryWithId( root_cor, it.getCurrentBstr());
! ASSERT( libroot);
! if( libroot)
! // this lib may have gotten new elements during refresh
! applyLibFlag( libroot);
! }
!
! /*for( std::vector<PROJ_ID>::iterator it = m_changedLibs.begin()
; it != m_changedLibs.end()
; ++it)
{
! //CoreObj libroot = SearchTool::findLibrary( root_cor, *it);
! CoreObj libroot = SearchTool::findLibraryWithId( root_cor, *it);
ASSERT( libroot);
if( libroot)
***************
*** 2283,2287 ****
//done elsewhere: //Ozer::addIncludes( libroot, id);
}
! }
}
--- 2367,2371 ----
//done elsewhere: //Ozer::addIncludes( libroot, id);
}
! }*/
}
***************
*** 2723,2727 ****
MIXED_TARGET2 val;
! if( tgt_elem.inlib) val = std::make_pair( tgt_elem.uid, CoreObj());
else val = std::make_pair( UniqueId() , tgt);
--- 2807,2812 ----
MIXED_TARGET2 val;
! //if( tgt_elem.inlib) val = std::make_pair( tgt_elem.uid, CoreObj());
! if( tgt_elem.inverysamelib) val = std::make_pair( tgt_elem.uid, CoreObj());
else val = std::make_pair( UniqueId() , tgt);
***************
*** 2814,2827 ****
getElemDetails( sub, elem_sub);
! if( elem_sub.inlib) // which lib? it matters!
{
! if( elem_sub.uid.libId == Identifier::getLibRootOf( one_fco))
continue;
else
if( m_changedLibs.end() == std::find( m_changedLibs.begin(), m_changedLibs.end(), elem_sub.uid.libId))
m_changedLibs.push_back( elem_sub.uid.libId);
! }
/*if( elem_sub.inlib) // if subtype also in library, do not care
continue;*/
// collect references, both primary and secondary deriveds
--- 2899,2916 ----
getElemDetails( sub, elem_sub);
! /*if( elem_sub.inlib) // which lib? it matters!
{
! if( elem_sub.uid.libId == Identifier::getLibRootOf( one_fco)
! || elem_sub.uid.libId == Identifier::getTopLibRootOf( one_fco)
! )
continue;
else
if( m_changedLibs.end() == std::find( m_changedLibs.begin(), m_changedLibs.end(), elem_sub.uid.libId))
m_changedLibs.push_back( elem_sub.uid.libId);
! }*/
/*if( elem_sub.inlib) // if subtype also in library, do not care
continue;*/
+ if( elem_sub.inverysamelib)
+ continue;
// collect references, both primary and secondary deriveds
***************
*** 2874,2877 ****
--- 2963,2974 ----
// add structure to the storage map
mapOfDeriveds[ elem_self.uid].push_back( sp);
+ #ifdef _DEBUG
+ //MyCComBSTR msg ("mapOfDeriveds ");
+ //CComBSTR oid, sid; ObjForCore( one_fco)->get_ID( &oid); sub->get_ID( &sid);
+ //msg.AppendBSTR( oid);msg.Append( L" base of "); msg.AppendBSTR( sid);
+ //msg.appendLink( one_fco); msg.appendLink( sub);
+ //m_reporter.show( msg);
+ #endif
+
}
else
***************
*** 2907,2920 ****
getElemDetails( ref, elem_ref);
! if( elem_ref.inlib) // which lib? it matters!
{
! if( elem_ref.uid.libId == Identifier::getLibRootOf( one_fco))
continue;
else
if( m_changedLibs.end() == std::find( m_changedLibs.begin(), m_changedLibs.end(), elem_ref.uid.libId))
m_changedLibs.push_back( elem_ref.uid.libId);
! }
/*if( elem_ref.inlib) // ref also in library?
continue;*/
// So far we know that:
--- 3004,3022 ----
getElemDetails( ref, elem_ref);
! /*if( elem_ref.inlib) // which lib? it matters!
{
! if( elem_ref.uid.libId == Identifier::getLibRootOf( one_fco)
! || elem_ref.uid.libId == Identifier::getTopLibRootOf( one_fco)
! )
continue;
else
if( m_changedLibs.end() == std::find( m_changedLibs.begin(), m_changedLibs.end(), elem_ref.uid.libId))
m_changedLibs.push_back( elem_ref.uid.libId);
! }*/
/*if( elem_ref.inlib) // ref also in library?
continue;*/
+ if( elem_ref.inverysamelib)
+ continue;
+
// So far we know that:
***************
*** 2992,3005 ****
getElemDetails( sub, elem_sub);
! if( elem_sub.inlib) // which lib? it matters!
{
! if( elem_sub.uid.libId == Identifier::getLibRootOf( one_fco))
continue; // subtype also in the same library
else
if( m_changedLibs.end() == std::find( m_changedLibs.begin(), m_changedLibs.end(), elem_sub.uid.libId))
m_changedLibs.push_back( elem_sub.uid.libId);
! }
/*if( elem_sub.inlib) // subtype also in library
continue;*/
// cut the relationship between derd and bs
--- 3094,3111 ----
getElemDetails( sub, elem_sub);
! /*if( elem_sub.inlib) // which lib? it matters!
{
! if( elem_sub.uid.libId == Identifier::getLibRootOf( one_fco)
! || elem_sub.uid.libId == Identifier::getTopLibRootOf( one_fco)
! )
continue; // subtype also in the same library
else
if( m_changedLibs.end() == std::find( m_changedLibs.begin(), m_changedLibs.end(), elem_sub.uid.libId))
m_changedLibs.push_back( elem_sub.uid.libId);
! }*/
/*if( elem_sub.inlib) // subtype also in library
continue;*/
+ if( elem_sub.inverysamelib)
+ continue;
// cut the relationship between derd and bs
***************
*** 3205,3207 ****
return k;
! }
\ No newline at end of file
--- 3311,3499 ----
return k;
! }
!
! /*static*/ const CComBSTR Creator::SrcName = "src"; // keep in sync with FCO::SrcName in MgaConnection.cpp
! /*static*/ const CComBSTR Creator::DstName = "dst"; // keep in sync with FCO::DstName
!
! /*static*/
! HRESULT Creator::SimpleConn( CComPtr<IMgaModel>& p_parent
! , CComPtr<IMgaMetaRole>& p_mrole
! , CComPtr<IMgaFCO>& p_src
! , CComPtr<IMgaFCO>& p_dst
! , CComPtr<IMgaFCOs>& p_srcRefs
! , CComPtr<IMgaFCOs>& p_dstRefs
! , CMgaProject* p_mgaProject
! , IMgaFCO** p_newConn
! )
! { // copied from HRESULT FCO::CreateSimpleConn( ...)
! CMgaProject* &mgaproject = p_mgaProject;
! COMTRY_IN_TRANSACTION { // COMTRY_IN_TRANSACTION needs a variable named mgaproject
! CComPtr<IMgaFCO> f;
! {
! booltempflag fl( p_mgaProject->checkofftemporary);
! //COMTHROW(CreateChildObject(metar, &f));
! COMTHROW( Creator::Child( p_mgaProject, CComPtr<IMgaFCO>( p_parent), p_mrole, &f));
! objtype_enum ot;
! COMTHROW( f->get_ObjType( &ot));
! if( ot != OBJTYPE_CONNECTION) COMTHROW( E_MGA_INVALID_ROLE);
! COMTHROW( Creator::put_NamedRole( p_mgaProject, f, SrcName, p_srcRefs, p_src));
! }
! COMTHROW( Creator::put_NamedRole( p_mgaProject, f, DstName, p_dstRefs, p_dst));
! *p_newConn = f.Detach();
! }
! COMCATCH_IN_TRANSACTION(;);
! }
!
! /*static*/
! HRESULT Creator::Child( CMgaProject* p_mgaProject, CComPtr<IMgaFCO>& p_parent, CComPtr<IMgaMetaRole>& p_metar, IMgaFCO **p_newobj)
! { // copied from HRESULT FCO::CreateChildObject(IMgaMetaRole *metar, IMgaFCO **newobj)
! CMgaProject* &mgaproject = p_mgaProject;
! COMTRY_IN_TRANSACTION { // COMTRY_IN_TRANSACTION needs a variable named mgaproject
! //CheckWrite();
! CHECK_INPTRPAR( p_metar);
! CHECK_OUTPTRPAR( p_newobj);
! //if((long)self[ATTRID_PERMISSIONS] & ~EXEMPT_FLAG) COMTHROW(E_MGA_NOT_CHANGEABLE);
! CoreObj nobj;
! CComPtr<IMgaMetaFCO> meta;
! metaref_type rr;
! COMTHROW( p_metar->get_MetaRef( &rr));
! COMTHROW( p_metar->get_Kind( &meta));
!
! CoreObj a_self( p_parent);
! FCO* parent( ObjForCore( a_self));
!
! COMTHROW( parent->ContainerCreateFCO( meta, nobj));
!
! nobj[ATTRID_ROLEMETA]=rr;
! FCO *nfco = ObjForCore(nobj);
! nfco->initialname();
!
! setcheck( p_mgaProject, nobj, CHK_NEW);
!
! int targetlevel = 0;
! CoreObj rootp;
!
! // a_self is not a member!
! GetRootOfDeriv( a_self, rootp, &targetlevel);
! if( targetlevel >= 0) ReDeriveNewObj( p_mgaProject, nobj, targetlevel+1);
! docheck( mgaproject);
!
! nfco->SelfMark(OBJEVENT_CREATED);
! parent->SelfMark(OBJEVENT_NEWCHILD);
! nfco->getinterface( p_newobj);
! }
! COMCATCH_IN_TRANSACTION(;);
! }
!
! /*static*/
! HRESULT Creator::put_NamedRole( CMgaProject* p_mgaProject, CComPtr<IMgaFCO>& p_conn, BSTR p_rolename, IMgaFCOs* p_refs, IMgaFCO* p_endfco)
! { // copied from FCO::put_NamedRole(...)
! CMgaProject* &mgaproject = p_mgaProject;
! COMTRY_IN_TRANSACTION { // COMTRY_IN_TRANSACTION needs a variable named mgaproject
! //CheckWrite();
! {
! booltempflag fl( p_mgaProject->checkofftemporary);
!
! CComPtr<IMgaConnPoints> p;
! CComQIPtr<IMgaConnection> a_conn( p_conn);
! COMTHROW( a_conn->get_ConnPoints(&p));
! MGACOLL_ITERATE(IMgaConnPoint, p) {
! CComBSTR rn;
! COMTHROW(MGACOLL_ITER->get_ConnRole(&rn));
! if(rn == p_rolename) {
! COMTHROW(MGACOLL_ITER->Remove());
! break;
! }
! } MGACOLL_ITERATE_END;
! }
! if( p_endfco) {
! CComPtr<IMgaConnPoint> tt;
! COMTHROW( Creator::AddConnPoint( p_mgaProject, p_conn, p_rolename, 1, p_endfco, p_refs, &tt));
! }
! } COMCATCH_IN_TRANSACTION(;)
! }
!
! /*static*/
! HRESULT Creator::AddConnPoint( CMgaProject* p_mgaProject, CComPtr<IMgaFCO>& p_conn, BSTR p_rolename, long p_maxinrole, IMgaFCO* p_target, IMgaFCOs* p_refs, IMgaConnPoint** pVal)
! { // copied from FCO::AddConnPoint(...)
! CMgaProject* &mgaproject = p_mgaProject;
! COMTRY_IN_TRANSACTION { // COMTRY_IN_TRANSACTION needs a variable named mgaproject
! //CheckWrite();
! long c = 0;
! if( p_refs) COMTHROW( p_refs->get_Count(&c));
! std::vector<CoreObj> peers(c+2);
! CHECK_INSTRPAR( p_rolename);
! CHECK_MYINPTRPAR( p_target);
! CHECK_OUTPTRPAR( pVal);
! int pos = 0;
! if( p_refs) {
! CHECK_MYINPTRSPAR( p_refs);
!
! MGACOLL_ITERATE(IMgaFCO, p_refs) {
! CoreObj l(MGACOLL_ITER);
! if(l.GetMetaID() != DTID_REFERENCE) COMTHROW(E_MGA_REFERENCE_EXPECTED);
! peers[pos++] = l;
! } MGACOLL_ITERATE_END;
! }
! peers[pos++] = CoreObj( p_target);
! peers[pos] = NULLCOREOBJ;
!
! CoreObj a_self( p_conn);
! FCO* this_conn( ObjForCore( a_self));
!
! AddConnPTask( p_maxinrole, p_rolename).DoWithDeriveds( a_self, &peers);
! CMgaConnPoint::GetConnPoint( this_conn, peers[pos], pVal);
! } COMCATCH_IN_TRANSACTION(;);
! }
!
! /*static*/
! HRESULT Worker::put_Name( CMgaProject* p_mgaProject, CComPtr<IMgaFCO>& p_elem, CComBSTR p_newVal)
! { // copied from FCO::put_Name
! CMgaProject* &mgaproject = p_mgaProject;
! COMTRY_IN_TRANSACTION { // COMTRY_IN_TRANSACTION needs a variable named mgaproject
! //CheckWrite();
! CHECK_INPAR( p_newVal);
! CoreObj a_self( p_elem);
! //if(self[ATTRID_PERMISSIONS] & LIBROOT_FLAG) COMTHROW(E_MGA_LIBOBJECT);
! if(CComBSTR(a_self[ATTRID_NAME]) != p_newVal) {
! put_NameTask(CComBSTR(a_self[ATTRID_NAME]), p_newVal).DoWithDeriveds(a_self);;
! }
! }
! COMCATCH_IN_TRANSACTION(;);
! }
!
! /*static*/
! HRESULT Worker::PutGuidDisp( CMgaProject* p_mgaProject, CComPtr<IMgaFCO>& p_elem, CComBSTR p_guidStr)
! { // copied from FCO::PutGuidDisp
! CMgaProject* &mgaproject = p_mgaProject;
! COMTRY_IN_TRANSACTION { // COMTRY_IN_TRANSACTION needs a variable named mgaproject
! //CheckWrite();
! CHECK_INSTRPAR( p_guidStr);
! //self[ATTRID_GUID1] = newVal;
! GUID t_guid;
! CopyTo( p_guidStr, t_guid);
!
! long v1 = t_guid.Data1; // Data1: 32 b, Data2, Data 3: 16 b, Data4: 64 bit
! long v2 = (t_guid.Data2 << 16) + t_guid.Data3;
! long v3 = (((((t_guid.Data4[0] << 8) + t_guid.Data4[1]) << 8) + t_guid.Data4[2]) << 8) + t_guid.Data4[3];
! long v4 = (((((t_guid.Data4[4] << 8) + t_guid.Data4[5]) << 8) + t_guid.Data4[6]) << 8) + t_guid.Data4[7];
!
! Worker::PutGuid( p_mgaProject, p_elem, v1, v2, v3, v4);
! } COMCATCH_IN_TRANSACTION(;)
! }
!
! HRESULT Worker::PutGuid( CMgaProject* p_mgaProject, CComPtr<IMgaFCO>& p_elem, long l1, long l2, long l3, long l4)
! { // copied from FCO::PutGuid
! CMgaProject* &mgaproject = p_mgaProject;
! COMTRY_IN_TRANSACTION { // COMTRY_IN_TRANSACTION needs a variable named mgaproject
! //CheckWrite();
! //ASSERT( self.IsFCO());
! //if( self.IsFCO()) {
! CoreObj a_self( p_elem);
! a_self[ATTRID_GUID1] = l1;
! a_self[ATTRID_GUID2] = l2;
! a_self[ATTRID_GUID3] = l3;
! a_self[ATTRID_GUID4] = l4;
! } COMCATCH_IN_TRANSACTION(;)
! }
!
Index: MgaLibOps.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Mga/MgaLibOps.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** MgaLibOps.h 25 Jan 2007 17:48:30 -0000 1.5
--- MgaLibOps.h 2 Feb 2007 21:00:18 -0000 1.6
***************
*** 18,21 ****
--- 18,22 ----
CoreObj created;
attrid_type attrid;
+ bool redirectable;
} resolve_entry;
***************
*** 41,45 ****
void resolve(const CoreObj &original, const CoreObj &created,
! attrid_type attrid)
{
if( LINKREF_ATTR(attrid) )
--- 42,46 ----
void resolve(const CoreObj &original, const CoreObj &created,
! attrid_type attrid, bool p_skipThis)
{
if( LINKREF_ATTR(attrid) )
***************
*** 61,64 ****
--- 62,84 ----
if( i != identity_map.end() )
{
+ if( p_skipThis)
+ {
+ #ifdef _DEBUG
+ //CComBSTR m;
+ //if( original.IsFCO())
+ //{
+ // m.Append( original[ATTRID_NAME]);m.Append( "=");
+ // m.Append( created[ATTRID_NAME]);m.Append( ".");
+ // m.Append( target[ATTRID_NAME]); m.Append( " found in lib: ");
+ // CoreObj n = findLibRoot( original);
+ // if( n)
+ // m.Append( n[ATTRID_NAME]); m.Append( ";");
+ //}
+ #endif
+
+ created[attrid] = i->second;// already created
+ return;
+ }
+
CoreObj iseccnpart;
***************
*** 67,81 ****
// i->second might be replaced by its counterpart
// in lib2copy
! if( i->second.IsFCO())
iseccnpart = findCounterpart( i->second);
else
! ASSERT(0);
//ASSERT( iseccnpart);//SHOULDN'T IT FAIL if counterpart not found?
}
! if( iseccnpart)
! created[attrid] = iseccnpart;
else
created[attrid] = i->second;// already created
}
else // resolve it later
--- 87,189 ----
// i->second might be replaced by its counterpart
// in lib2copy
! if( i->second.IsFCO() && i->second.GetMetaID() != DTID_CONNECTION)
iseccnpart = findCounterpart( i->second);
+ // attempts to postpone the decison about these:
else
! {
! CComBSTR m;
! if( i->second.IsFCO())
! {
! m.Append( original[ATTRID_NAME]);m.Append( "=");
! m.Append( created[ATTRID_NAME]);m.Append( ".");
! m.Append( target[ATTRID_NAME]); m.Append( ";");
! }
! else
! {
! CComBSTR m;
! m.Append( CoreObj(original).GetMgaObj()[ATTRID_NAME]);
! m.Append( ".");
! }
!
! resolve_entry entry;
! entry.target = target;
! entry.created = created;
! entry.attrid = attrid;
! entry.redirectable = true;
! resolve_entries.push_back(entry);
! return;
! }
! //else
! // ASSERT(0);
//ASSERT( iseccnpart);//SHOULDN'T IT FAIL if counterpart not found?
}
! if( m_isOptimizing && !iseccnpart)
! {
! int k(0);
! ++k;
! }
! if( iseccnpart)//m_isOptimizing) //iseccnpart
! {
! if( iseccnpart)
! {
! created[attrid] = iseccnpart;
! }
! else if( i->second) // iseccnpart = 0, i->second != 0
! {
! CComBSTR nm, id;
! CoreObj mp;
! if( i->second.IsFCO())
! {
! nm = i->second[ATTRID_NAME];
! ObjForCore( i->second)->get_ID( &id);
!
! }
! else if( mp = i->second.GetMgaObj())
! {
! nm = mp[ATTRID_NAME];
! ObjForCore( mp)->get_ID( &id);
! }
! else
! {
! nm = "Null";
! }
! CComBSTR msg( "Resolve error at ");
! msg.Append( nm);
! msg.Append( " with ");
! msg.Append( id);
! }
! }
else
+ {
created[attrid] = i->second;// already created
+ #ifdef _DEBUG
+ //CoreObj tgt = i->second;
+ //CComBSTR m;
+ //if( created.IsFCO())
+ //{
+ // ObjForCore( created)->get_ID( &m);
+ // m.Append( ".");
+ // m.Append( created[ATTRID_NAME]);
+ // if( tgt.IsFCO())
+ // m.Append( tgt[ATTRID_NAME]);
+ // else
+ // m.Append( tgt.GetMgaObj()[ATTRID_NAME]);
+ // m.Append( "/");
+ //}
+ //else
+ //{
+ // /*CoreObj& p = created.GetMgaObj();
+ // ObjForCore( p)->get_ID( &m);
+ // m.Append( "{");
+ // m.Append( p[ATTRID_NAME]);*/
+ // if( tgt.IsFCO())
+ // m.Append( tgt[ATTRID_NAME]);
+ // else
+ // m.Append( tgt.GetMgaObj()[ATTRID_NAME]);
+ // m.Append( "}");
+ //}
+ #endif
+ }
}
else // resolve it later
***************
*** 85,88 ****
--- 193,197 ----
entry.created = created;
entry.attrid = attrid;
+ entry.redirectable = !p_skipThis;
resolve_entries.push_back(entry);
}
***************
*** 102,105 ****
--- 211,216 ----
{
CoreObj& new_target = identity_map[i->target];
+
+ try {
ASSERT( new_target != NULL );
***************
*** 108,131 ****
{
// look for the element's peer in the peer library
! if( new_target.IsFCO())
iseccnpart = findCounterpart( new_target);
! else
! ASSERT(0);
! //ASSERT( iseccnpart); // SHOULDN'T IT FAIL IF COUNTERPART NOT FOUND?
}
! if( iseccnpart)
! (i->created)[i->attrid] = iseccnpart;
else
(i->created)[i->attrid] = new_target;
++i;
}
clear();
}
};
class Ozer //Optimizer
{
class StorageMgr // responsible for Storing and Retrieving the information
{
--- 219,489 ----
{
// look for the element's peer in the peer library
! if( new_target.IsFCO() && new_target.GetMetaID() != DTID_CONNECTION)
iseccnpart = findCounterpart( new_target);
! if( new_target.IsFCO() && new_target.GetMetaID() == DTID_CONNECTION)
! {
! iseccnpart = findCounterpart( new_target);
! }
}
! if( m_isOptimizing && i->redirectable)
! {
! if( iseccnpart)
! (i->created)[i->attrid] = iseccnpart;
! else
! (i->created)[i->attrid] = new_target;
!
! // diagnostics
! #ifdef _DEBUG
! //if( !iseccnpart && new_target) // iseccnpart = 0, new_target != 0
! //{
! // CComBSTR nm, id;
! // CoreObj mp;
! // if( new_target.IsFCO())
! // {
! // nm = new_target[ATTRID_NAME];
! // ObjForCore( new_target)->get_ID( &id);
! //
! // }
! // else if( mp = new_target.GetMgaObj())
! // {
! // nm = mp[ATTRID_NAME];
! // ObjForCore( mp)->get_ID( &id);
! // }
! // else
! // {
! // nm = "Null";
! // }
! // CComBSTR msg( "Resolution error at ");
! // msg.Append( nm);
! // msg.Append( " with ");
! // msg.Append( id);
! //}
! #endif
! }
else
(i->created)[i->attrid] = new_target;
+ } catch(...)
+ {
+ #ifdef _DEBUG
+ //CComBSTR nm, id;
+ //CoreObj mp;
+ //if( new_target.IsFCO())
+ //{
+ // nm = new_target[ATTRID_NAME];
+ // ObjForCore( new_target)->get_ID( &id);
+ //
+ //}
+ //else if( mp = new_target.GetMgaObj())
+ //{
+ // nm = mp[ATTRID_NAME];
+ // ObjForCore( mp)->get_ID( &id);
+ //}
+ //else
+ //{
+ // nm = "Null";
+ //}
+ //CComBSTR msg( "Resolution error at ");
+ //msg.Append( nm);
+ //msg.Append( " with ");
+ //msg.Append( id);
+ #endif
+ }
++i;
}
+
+ // deal with connections now
+ i = resolve_entries.begin();
+ while( i != resolve_entries.end() )
+ {
+ CoreObj& new_target = identity_map[i->target];
+ ASSERT( new_target != NULL );
+
+ CoreObj iseccnpart;
+ if( m_isOptimizing && i->redirectable)
+ {
+ try
+ {
+
+ //if( !new_target.IsFCO() && new_target.GetMgaObj().GetMetaID() != DTID_CONNECTION)
+ //{
+ // // this is questionable yet
+ // ASSERT(0);
+ // int mid = new_target.GetMetaID();
+ // int nid = i->created.GetMetaID();
+ // if( 511 == i->attrid)
+ // {
+ // CoreObj g = i->created;
+ // CoreObj x1 = g.GetMgaObj();
+ // CoreObj x2 = new_target.GetMgaObj();
+ // CComBSTR m, i1, i2;
+ // ObjForCore( x1)->get_ID( &i1);
+ // ObjForCore( x2)->get_ID( &i2);
+ // m.Append( x1[ATTRID_NAME]); m.Append( "{");m.Append( i1);m.Append( "}");
+ // m.Append( x2[ATTRID_NAME]); m.Append( "{");m.Append( i2);m.Append( "}");
+
+ // iseccnpart = findCounterpart( new_target);
+ // if( iseccnpart)
+ // {
+ // i->created[i->attrid] = iseccnpart;
+ // }
+ // else
+ // {
+ // i->created[i->attrid] = new_target;
+ // }
+ // }
+ //}
+ if( !new_target.IsFCO() && new_target.GetMgaObj().GetMetaID() == DTID_CONNECTION)
+ {
+ // needs to be dealt with:
+ // in case of DTID_CONNROLE: XREF and MASTEROBJ
+ // in case of DTID_CONNROLESEG: SEGREF
+ //
+ int mid = new_target.GetMetaID();
+ int nid = i->created.GetMetaID();
+ if( DTID_CONNROLE == nid) // 107
+ {
+ ASSERT( mid == nid);
+ if( ATTRID_MASTEROBJ == i->attrid) // 517
+ {
+ CoreObj g = i->created;
+ CoreObj derd_conn = g.GetMgaObj();
+ CoreObj base_con1 = new_target.GetMgaObj();
+ CoreObj base_con2 = findCounterpart( base_con1);
+ #ifdef _DEBUG
+ CComBSTR idofcon2, nmofcon2;
+ if( base_con2)
+ {
+ nmofcon2 = base_con2[ATTRID_NAME];
+ ObjForCore( base_con2)->get_ID( &idofcon2);
+ }
+
+ idofcon2.Append( ";");
+ idofcon2.AppendBSTR( nmofcon2);
+ idofcon2.Append( ".");
+ #endif
+ CoreObj role_cntpt;
+ if( base_con2)
+ findConnRoleCounterpart( new_target, base_con1, base_con2, role_cntpt);
+
+ if( role_cntpt)
+ {
+ //
+ (i->created)[i->attrid] = role_cntpt;
+ }
+ else
+ {
+ // what to do with unconnectible connections?
+ #ifdef _DEBUG
+ CComBSTR nm, id;
+ CoreObj mp;
+ if( new_target.IsFCO())
+ {
+ nm = new_target[ATTRID_NAME];
+ ObjForCore( new_target)->get_ID( &id);
+
+ }
+ else if( mp = new_target.GetMgaObj())
+ {
+ nm = mp[ATTRID_NAME];
+ ObjForCore( mp)->get_ID( &id);
+ }
+ else
+ {
+ nm = "Null";
+ }
+ CComBSTR msg( "RoleResolution error at ");
+ msg.Append( nm);
+ msg.Append( " with ");
+ msg.Append( id);
+ #endif
+ }
+ /*else // if we optimize then we don't look back!
+ (i->created)[i->attrid] = new_target;*/
+ }
+ }
+ //if( 108 == nid) // DTID_CONNROLESEG
+ //{
+ // ASSERT(0);
+ // if( 511 == i->attrid)
+ // {
+ // CComBSTR m;
+ // CoreObj ref = new_target[ATTRID_SEGREF];
+ // if( ref)
+ // {
+ // m = ref[ATTRID_NAME];
+ // CoreObj ref_tgt = ref[ATTRID_REFERENCE];
+ // m.Append( " targets ");
+ // if( ref_tgt)
+ // m.Append( ref_tgt[ATTRID_NAME]);
+ // CoreObj nr = findCounterpart( ref_tgt);
+ // if( nr)
+ // {
+ // }
+ // }
+ // }
+ //}
+ }
+
+ }
+ catch (...) {
+ CComBSTR nm, id;
+ CoreObj mp;
+ if( new_target.IsFCO())
+ {
+ nm = new_target[ATTRID_NAME];
+ ObjForCore( new_target)->get_ID( &id);
+
+ }
+ else if( mp = new_target.GetMgaObj())
+ {
+ nm = mp[ATTRID_NAME];
+ ObjForCore( mp)->get_ID( &id);
+ }
+ else
+ {
+ nm = "Null";
+ }
+ CComBSTR msg( "RoleResolution error at ");
+ msg.Append( nm);
+ msg.Append( " with ");
+ msg.Append( id);
+ }
+ }
+
+
+ ++i;
+ }
+
clear();
}
+
+ void findConnRoleCounterpart( const CoreObj& p_connRole1, const CoreObj& p_baseConn1, const CoreObj& p_baseConn2, CoreObj& p_connRoleResult)
+ {
+ if( !p_connRole1) return;
+ if( !p_baseConn1) return;
+ if( !p_baseConn2) return;
+
+ CComBSTR cr_rname = p_connRole1[ATTRID_NAME];
+ ITERATE_THROUGH( p_baseConn2[ ATTRID_CONNROLE + ATTRID_COLLECTION]) {
+ CComBSTR it_rname = ITER[ATTRID_NAME];
+ if( it_rname == cr_rname)
+ {
+ // found:
+ if( !p_connRoleResult)
+ p_connRoleResult = ITER;
+ else
+ ASSERT(0); // found twice?
+ }
+ }
+
+ }
};
class Ozer //Optimizer
{
+ public:
+
class StorageMgr // responsible for Storing and Retrieving the information
{
***************
*** 160,163 ****
--- 518,540 ----
public:
+ class DependentIterator // a dependent library iterator
+ {
+ public:
+ // based on p_incbyOrInc the included or the including libraries are given back
+ DependentIterator( const CComBSTR& p_list);
+ DependentIterator( const std::string& p_list);
+
+ // traversal methods
+ bool isDone();
+ void next();
+ CComBSTR getCurrentBstr();
+ std::string getCurrentStr();
+
+ protected:
+ unsigned int m_pos;
+ unsigned int m_nextPos;
+ std::string m_tokenizable;
+ };
+
static bool addIncludedBy( CoreObj& p_fldCore
, const CComBSTR& p_idToAddToReg);
***************
*** 185,188 ****
--- 562,567 ----
, const std::string& p_tokenizable
, bool p_incOrIncBy);
+
+ static bool isIncluded( CoreObj& p_fldCore);
};
More information about the GME-commit
mailing list