[GME-commit] GMESRC/GME/XmlBackEnd CoreXmlFile.cpp, 1.19,
1.20 CoreXmlFile.h, 1.6, 1.7
gme-commit at list.isis.vanderbilt.edu
gme-commit at list.isis.vanderbilt.edu
Thu Jun 21 14:09:45 CDT 2007
Update of /project/gme-repository/GMESRC/GME/XmlBackEnd
In directory escher:/tmp/cvs-serv12579
Modified Files:
CoreXmlFile.cpp CoreXmlFile.h
Log Message:
Options introduced:
-AlwaysFullLock
-OnDeleteFullLock
Thorough locking done when delete happens, especially when a model is deleted.
Furthermore, when a port is deleted: its grandparent (where the port is visible) is also locked.
Role metarefs are also stored, which have Parts found to be ports.
CVS User: Zoltan Molnar, ISIS (zolmol)
Index: CoreXmlFile.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/XmlBackEnd/CoreXmlFile.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** CoreXmlFile.cpp 20 Jun 2007 23:04:06 -0000 1.19
--- CoreXmlFile.cpp 21 Jun 2007 19:09:43 -0000 1.20
***************
*** 732,735 ****
--- 732,758 ----
}
+ bool CCoreXmlFile::objIsPort( XmlObject * obj)
+ {
+ if( !obj) return false;
+ // only m, a, r, s can be ports
+ if( obj->m_metaid != DTID_MODEL && obj->m_metaid != DTID_ATOM && obj->m_metaid != DTID_REFERENCE && obj->m_metaid != DTID_SET) return false;
+
+ std::string nm = "0000";
+ AttribMapIter it = obj->m_attributes.find( ATTRID_ROLEMETA ); // the metarole would help us better
+ if( it == obj->m_attributes.end())
+ it = obj->m_attributes.find( ATTRID_META ); // otherwise use just meta
+ if( it != obj->m_attributes.end())
+ {
+ if( it->second->getType() == VALTYPE_LONG)
+ it->second->toString( nm);
+ }
+ if( nm != "0000")
+ {
+ return m_userOpts.m_paradigmInfo.isPort( nm);
+ }
+
+ return true;
+ }
+
void CCoreXmlFile::decidePointerOperationTrivials()
{
***************
*** 881,886 ****
// if refs or ports met -> turns m_trivial to FALSE
m_modifiedObjects.insert( m_openedObject );
!
// handle special case: if this is the containment parent and this object is an inner
// we have to check out the parent too
--- 904,968 ----
// if refs or ports met -> turns m_trivial to FALSE
+ metaobjidpair_type idpair;CopyTo(p, idpair);
+ if( m_metaAttributeId == ATTRID_PARENT && idpair.metaid == 0 && idpair.objid == 0) // VARIANT p is 0 => removal
+ {
+ // delete handled separately in cases of models and non-model fcos
+ // if a, r, s, c is deleted the parent model is checked out
+ // among these a, r, s can be ports
+ // models are tricky because upon deleting a model its parent
+ // does not get checked out
+ // in addition a model also can be a port
+ metaid_type &mt = m_openedObject->m_metaid;
+ XmlObject * grand_parent = 0; // will be used only if it is determined to be a port
+ if( mt == DTID_MODEL)
+ {
+ ASSERT( getContainer( m_openedObject) == m_openedObject);
+ // simply get its father:
+ AttribMapIter it3 = m_openedObject->m_attributes.find( ATTRID_PARENT );
+ ASSERT( it3 != m_openedObject->m_attributes.end() );
+ XmlObject * cont = ((XmlAttrPointer*)(it3->second))->m_parent;
+
+ // put its father into the mod obj list to prevent connections to it, while it is deleted
+ m_modifiedObjects.insert( cont );
+
+ // find its grandfather:
+ if( cont)
+ {
+ it3 = cont->m_attributes.find( ATTRID_PARENT );
+ if( it3 != cont->m_attributes.end()) // not in rootfolder
+ {
+ grand_parent = ((XmlAttrPointer*)(it3->second))->m_parent;
+ }
+ }
+ }
+
+ bool might_be_a_port = mt == DTID_MODEL || mt == DTID_ATOM || mt == DTID_REFERENCE || mt == DTID_SET; // m, a, r, s, but no connection
+ if( might_be_a_port)
+ {
+ // is it a port:
+ bool isport = objIsPort( m_openedObject);
+ if( isport || m_userOpts.m_onDeleteAlwaysFullLock)
+ {
+ // in this case a full-lock could be demanded
+ m_fullLockNeeded = true; m_trivialChanges = false;
+ // in case of a, r, s the parent is considered for sure
+ // in case of models we have inserted by hand the parent
+ // the full lock will ensure that refs to these models are also locked
+ // but:
+ // furthermore those containers need to be locked (grandparents and referenceparents)
+ // where this port can be seen:
+ // in case a port is seen in a model, that will be the port's grandparent
+ // in case a port is seen in a reference, that will be the reference's parent
+ // these latter ones should be provided by the m_fullLockNeeded flag's true value
+ // becaue references can't be checked out by themselves, only by their container
+ // models only
+ if( grand_parent)
+ m_modifiedObjects.insert( grand_parent );
+ }
+ }
+ }
+
m_modifiedObjects.insert( m_openedObject );
!
// handle special case: if this is the containment parent and this object is an inner
// we have to check out the parent too
***************
*** 891,919 ****
XmlObject * cont = getContainer(m_openedObject);
m_modifiedObjects.insert( cont );
-
- metaid_type &mt = m_openedObject->m_metaid;
- bool is_fco = mt == DTID_MODEL || mt == DTID_ATOM || mt == DTID_REFERENCE || mt == DTID_SET; // m, a, r, s, but no connection
- if( cont && is_fco && m_metaAttributeId == ATTRID_PARENT)
- {
- metaobjidpair_type idpair;CopyTo(p, idpair);
- if( idpair.metaid == 0 && idpair.objid == 0) // VARIANT p is 0 => removal
- {
- // TODO: optimization based on if 'm_openedObject' is or isn't port of cont
- // lock granparent (gcont) to prevent a case that a connection would be drawn
- // in gcont to m_openedObject as cont's port
- AttribMapIter it3 = cont->m_attributes.find( ATTRID_PARENT );
- ASSERT( it3 != cont->m_attributes.end() );
- if( it3 != cont->m_attributes.end() )
- {
- XmlObject * gcont = ((XmlAttrPointer*)(it3->second))->m_parent;
- #ifdef _DEBUG
- std::string nm, tp;
- if( gcont) getContainerName( gcont, nm, tp);
- sendMsg( std::string( "Deletion case: added grandparent to the locked set: \"") + nm + std::string("\""), MSG_INFO);
- #endif
- m_modifiedObjects.insert( gcont );
- }
- }
- }
}
--- 973,976 ----
***************
*** 1214,1217 ****
--- 1271,1275 ----
#endif
m_trivialChanges = true;
+ m_fullLockNeeded = false;
return S_OK;
}
***************
*** 1243,1246 ****
--- 1301,1305 ----
#endif
m_trivialChanges = true;
+ m_fullLockNeeded = false;
m_createdObjects.clear();
m_deletedObjects.clear();
***************
*** 1315,1318 ****
--- 1374,1378 ----
#endif
m_trivialChanges = true;
+ m_fullLockNeeded = false;
CloseObject();
m_inTransaction = false;
***************
*** 1893,1897 ****
// lehet hogy a containert megiscsak tarolni kene??? ezt at kell gondolni!!!
containers.insert( container );
! for(AttribMapIter it=container->m_attributes.begin(); false && it!=container->m_attributes.end(); ++it)
{
attrid_type at = it->first;
--- 1953,1957 ----
// lehet hogy a containert megiscsak tarolni kene??? ezt at kell gondolni!!!
containers.insert( container );
! for(AttribMapIter it=container->m_attributes.begin(); (m_userOpts.m_alwaysFullLock || m_fullLockNeeded) && it!=container->m_attributes.end(); ++it)
{
attrid_type at = it->first;
***************
*** 1900,1904 ****
// go through the collections only if non-trivial changes happened
! if( it->second->getType() == VALTYPE_COLLECTION && !this->m_trivialChanges)
{
XmlAttrCollection * coll = (XmlAttrCollection*)it->second;
--- 1960,1964 ----
// go through the collections only if non-trivial changes happened
! if( it->second->getType() == VALTYPE_COLLECTION)// && !this->m_trivialChanges)
{
XmlAttrCollection * coll = (XmlAttrCollection*)it->second;
***************
*** 2000,2003 ****
--- 2060,2065 ----
#ifdef _DEBUG
+ if( m_fullLockNeeded)
+ sendMsg( std::string( "Full lock done because of deletion operation"), MSG_INFO);
if( m_trivialChanges)
sendMsg( std::string( "Trivial changes applied only!!!"), MSG_INFO);
***************
*** 3783,3786 ****
--- 3845,3850 ----
, m_defCheckInOnSave( false)
, m_defCheckOutOnAction( false)
+ , m_alwaysFullLock( false)
+ , m_onDeleteAlwaysFullLock( false)
, m_useParadigmFile( false)
, m_nameParadigmFile()
***************
*** 3792,3795 ****
--- 3856,3861 ----
m_defCheckInOnSave = false;
m_defCheckOutOnAction = false;
+ m_alwaysFullLock = false;
+ m_onDeleteAlwaysFullLock= false;
m_useParadigmFile = false;
m_nameParadigmFile = "";
***************
*** 3822,3825 ****
--- 3888,3899 ----
m_nameParadigmFile = line.substr( std::string( "ParadigmFileName=").length());
}
+ else if( 0 == line.find( "AlwaysFullLock=true"))
+ {
+ m_alwaysFullLock = true;
+ }
+ else if( 0 == line.find( "OnDeleteAlwaysFullLock=true"))
+ {
+ m_onDeleteAlwaysFullLock = true;
+ }
}
options.close();
***************
*** 3833,3840 ****
parent->sendMsg( std::string( "DefCheckInOnSave=" ) + (m_defCheckInOnSave?"true":"false"), MSG_INFO );
parent->sendMsg( std::string( "DefCheckOutOnAction=" ) + (m_defCheckOutOnAction?"true":"false"), MSG_INFO );
parent->sendMsg( std::string( "UseParadigmFile=") + (m_useParadigmFile?"true":"false"), MSG_INFO);
if( m_useParadigmFile)
parent->sendMsg( std::string( "ParadigmFileName=") + m_nameParadigmFile, MSG_INFO);
! if( !m_paradigmInfo.isLoaded())
parent->sendMsg( "Paragidm could not be parsed.", MSG_WARNING);
}
--- 3907,3916 ----
parent->sendMsg( std::string( "DefCheckInOnSave=" ) + (m_defCheckInOnSave?"true":"false"), MSG_INFO );
parent->sendMsg( std::string( "DefCheckOutOnAction=" ) + (m_defCheckOutOnAction?"true":"false"), MSG_INFO );
+ parent->sendMsg( std::string( "AlwaysFullLock=" ) + (m_alwaysFullLock?"true":"false"), MSG_INFO);
+ parent->sendMsg( std::string( "OnDeleteAlwaysFullLock=")+ (m_onDeleteAlwaysFullLock?"true":"false"), MSG_INFO);
parent->sendMsg( std::string( "UseParadigmFile=") + (m_useParadigmFile?"true":"false"), MSG_INFO);
if( m_useParadigmFile)
parent->sendMsg( std::string( "ParadigmFileName=") + m_nameParadigmFile, MSG_INFO);
! if( m_useParadigmFile && !m_paradigmInfo.isLoaded())
parent->sendMsg( "Paragidm could not be parsed.", MSG_WARNING);
}
***************
*** 3989,3993 ****
std::string fname = p_filename.substr( 0, p_filename.rfind( '\\') + 1);
std::ofstream dtdf;
! dtdf.open( (fname + "edf.dtd").c_str(), std::ios::out | std::ios::binary);
if( !dtdf.is_open()) return false;
--- 4065,4069 ----
std::string fname = p_filename.substr( 0, p_filename.rfind( '\\') + 1);
std::ofstream dtdf;
! dtdf.open( (fname + "edf.dtd").c_str(), std::ios::out | std::ios::binary);
if( !dtdf.is_open()) return false;
***************
*** 4032,4035 ****
--- 4108,4112 ----
// kind names in an .xmp file are found as third level elements (toplevel = <paradigm>, second = <rootfolder>)
+ std::map< std::string, bool> rolenames_of_ports;
bool mod_hasports = false;
char * mod_metaref = XMLString::transcode( el->getAttribute(XMLString::transcode("metaref")));
***************
*** 4050,4053 ****
--- 4127,4131 ----
// finally a part:
char * part_metaref = XMLString::transcode( gr_el->getAttribute(XMLString::transcode("metaref")));
+ char * role_2_part = XMLString::transcode( gr_el->getAttribute(XMLString::transcode("role")));
char * is_linked = XMLString::transcode( gr_el->getAttribute(XMLString::transcode("linked")));
long part_longref = atoi( part_metaref);
***************
*** 4056,4062 ****
--- 4134,4159 ----
{
mod_hasports = true;
+ rolenames_of_ports[ std::string( role_2_part)] = true;
if( part_longref != 0)
m_isPort[ part_longref] = true;
}
+ }
+ }
+
+ // we have to collect all the role metarefs for those parts which are ports
+ DOMNodeList * rolechildren = el->getElementsByTagName( XMLString::transcode( "role"));
+ for( int j=0; mod_hasports && j < (int) rolechildren->getLength(); ++j )
+ {
+ DOMNode * ch_node = rolechildren->item(j);
+ DOMElement* ch_el = (DOMElement*) ch_node;
+ char * role_metaref = XMLString::transcode( ch_el->getAttribute(XMLString::transcode("metaref")));
+ char * role_name = XMLString::transcode( ch_el->getAttribute(XMLString::transcode("name")));
+ // if there was a port for this rolename
+ if( rolenames_of_ports.find( std::string( role_name)) != rolenames_of_ports.end())
+ {
+ // put its metaref too into the m_isPort map
+ long role_longref = atoi( role_metaref);
+ if( role_longref != 0)
+ m_isPort[ role_longref ] = true;
}
}
Index: CoreXmlFile.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/XmlBackEnd/CoreXmlFile.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** CoreXmlFile.h 15 Jun 2007 17:02:54 -0000 1.6
--- CoreXmlFile.h 21 Jun 2007 19:09:43 -0000 1.7
***************
*** 310,313 ****
--- 310,315 ----
bool m_defCheckInOnSave;
bool m_defCheckOutOnAction;
+ bool m_alwaysFullLock;
+ bool m_onDeleteAlwaysFullLock;
bool m_useParadigmFile;
std::string m_nameParadigmFile;
***************
*** 543,546 ****
--- 545,550 ----
bool fcoInFolder ( XmlObject * obj);
+ bool objIsPort ( XmlObject * obj);
+
public:
// this can be used by other classes too
***************
*** 595,598 ****
--- 599,604 ----
XmlObject * m_root;
bool m_trivialChanges;
+ bool m_fullLockNeeded;
+
#ifdef _DEBUG
More information about the GME-commit
mailing list