[Mobies-commit] [commit] r4069 - in UDM/trunk: src/UdmGme tests/test_refports
ksmyth at redhat1.isis.vanderbilt.edu
ksmyth at redhat1.isis.vanderbilt.edu
Thu Jul 5 16:41:52 CDT 2012
Author: ksmyth
Date: Thu Jul 5 16:41:52 2012
New Revision: 4069
Log:
More refports: check HRESULT instead of using an empty catch block for retrieving refport_parent. Warn about arbitrary refence being chosen when src_end()=port fails (i.e. connection is not adjacent to or a level up from port in containment hierarchy). connection.src_end() = Udm::null should not delete the connection. Fix ref.refport_parent_rev()=conn: was setting registry on ref instead of connection. Dont need RemoveHelperConnections, since helper connection registry is stored only in connections (and we have no way to navigate from unconnected refport parent to connection)
Modified:
UDM/trunk/src/UdmGme/UdmGme.cpp
UDM/trunk/tests/test_refports/RefPortsTest.cpp
Modified: UDM/trunk/src/UdmGme/UdmGme.cpp
==============================================================================
--- UDM/trunk/src/UdmGme/UdmGme.cpp Fri Jun 29 13:15:08 2012 (r4068)
+++ UDM/trunk/src/UdmGme/UdmGme.cpp Thu Jul 5 16:41:52 2012 (r4069)
@@ -479,7 +479,7 @@
{
if (fco->Status != OBJECT_EXISTS)
return;
- SmartBSTR co_ids = fco->RegistryValue[role_name.c_str()];
+ SmartBSTR co_ids = fco->RegistryValue[role_name.c_str()]; // FIXME: need to handle E_NOTFOUND or E_NAME_NOT_FOUND?
if (!(!co_ids))
{
RpHelperIDs ids = StringToList(string(co_ids));
@@ -564,15 +564,23 @@
IMgaFCOsPtr references;
SmartBSTR src_role_name = conn->RegistryValue["sRefParent"];
+ HRESULT (__stdcall IMgaSimpleConnection::*fn)(IMgaFCOs**);
if (!src_role_name) {
SmartBSTR dst_role_name = conn->RegistryValue["dRefParent"];
- try {
- references = role_name.compare(dst_role_name) == 0 ? conn->GetDstReferences() : conn->GetSrcReferences();
- } catch (udm_exception&) {}
+ fn = role_name.compare(dst_role_name) == 0 ? &IMgaSimpleConnection::get_DstReferences : &IMgaSimpleConnection::get_SrcReferences;
} else {
- try {
- references = role_name.compare(src_role_name) == 0 ? conn->GetSrcReferences() : conn->GetDstReferences();
- } catch (udm_exception&) {}
+ fn = role_name.compare(src_role_name) == 0 ? &IMgaSimpleConnection::get_SrcReferences : &IMgaSimpleConnection::get_DstReferences;
+ }
+ {
+ struct IMgaFCOs * _result = 0;
+ IMgaSimpleConnection& iconn = *(static_cast<IMgaSimpleConnection*>(conn));
+ HRESULT _hr = (iconn.*fn)(&_result);
+ if (_hr != E_MGA_NAME_NOT_FOUND)
+ {
+ if (FAILED(_hr))
+ _com_issue_errorex(_hr, conn, __uuidof(conn));
+ references = IMgaFCOsPtr(_result, false);
+ }
}
if (references != NULL && references->GetCount() > 0)
@@ -919,6 +927,7 @@
}
catch(udm_exception&)
{
+ // Warning: an arbitrary reference is chosen here
IMgaFCOsPtr references = FindReferencesToFCO(peer);
COMTHROW(IMgaSimpleConnectionPtr(self)->SetSrc(references, peer));
}
@@ -945,6 +954,7 @@
}
catch(udm_exception&)
{
+ // Warning: an arbitrary reference is chosen here
IMgaFCOsPtr references = FindReferencesToFCO(peer);
COMTHROW(IMgaSimpleConnectionPtr(self)->SetDst(references, peer));
}
@@ -964,15 +974,24 @@
}
MGACOLL_ITERATE_END;
*/
+ ASSERT(pvect.size() <= 1);
+ ASSERT(kvect.size() <= 1);
for(i = pvect.begin(); i != pvect.end(); i++)
{
IMgaSimpleConnectionPtr conn = static_cast<GmeObject *>(*i)->self;
//we need to check if there is an associated helper connection
- GmeObject go(conn, mydn);
- go.RemoveHelperConnections();
-
- conn->DestroyObject();
+ //GmeObject go(conn, mydn);
+ //go.RemoveHelperConnections();
+ // FIXME: remove refport_parent regnode?
+ if (reverse)
+ {
+ conn->SetDst(NULL, NULL);
+ }
+ else
+ {
+ conn->SetSrc(NULL, NULL);
+ }
}//for i pvect
for(i = kvect.begin(); i != kvect.end(); i++)
{
@@ -997,8 +1016,9 @@
}
catch (udm_exception&)
{
+ // Warning: an arbitrary reference is chosen here
IMgaFCOsPtr references = static_cast<GmeObject *>(*i)->FindReferencesToFCO(self);
- COMTHROW(conn->SetDst(references, self));
+ conn->SetDst(references, self);
}
}
}//if(reverse)
@@ -1024,8 +1044,9 @@
// cout <<"\t\t Source: " << (char *)(self->GetName())<<endl;
// cout <<"\t\t connection: " << (char*)(conn->GetName()) << endl;
+ // Warning: an arbitrary reference is chosen here
IMgaFCOsPtr references = static_cast<GmeObject *>(*i)->FindReferencesToFCO(self);
- COMTHROW(conn->SetSrc(references, self));
+ conn->SetSrc(references, self);
}
}
@@ -1034,11 +1055,13 @@
}//if(mode == Udm::CLASSFROMTARGET)
else
{
+ ASSERT(mode == Udm::TARGETFROMPEER);
if (nn->rp_helper )
{
- if (kvect.size() > 1 && self->GetObjType() != OBJTYPE_REFERENCE) throw udm_exception("In case of np_helper connection there should be maximum one connecting object!");
+ if (kvect.size() > 1 && self->GetObjType() != OBJTYPE_REFERENCE)
+ throw udm_exception("In case of np_helper connection there should be maximum one connecting object!");
::Uml::AssociationRole orole = ::Uml::theOther(meta);
string oname = orole.name();
@@ -1055,7 +1078,14 @@
if (RpHelperNotValidConn(self, connecting_object, rname, oname))
throw udm_exception("Connection to reference port already exists, delete it first before changing the reference!");
#endif
- RpHelperAddToRegistry(self, connecting_object, rname, isNavigable);
+ if (self->ObjType == OBJTYPE_CONNECTION)
+ {
+ RpHelperAddToRegistry(self, connecting_object, rname, isNavigable);
+ }
+ else
+ {
+ RpHelperAddToRegistry(connecting_object, self, oname, oIsNavigable);
+ }
}
}
if (pvect.size())
@@ -1063,7 +1093,14 @@
for (vector<ObjectImpl*>::const_iterator i = pvect.begin(); i != pvect.end(); i++)
{
IMgaFCOPtr connecting_object = static_cast<GmeObject *>(*i)->self;
- RpHelperRemoveFromRegistry(self, connecting_object, rname);
+ if (self->ObjType == OBJTYPE_CONNECTION)
+ {
+ RpHelperRemoveFromRegistry(self, connecting_object, rname);
+ }
+ else
+ {
+ RpHelperRemoveFromRegistry(connecting_object, self, oname);
+ }
}
};
}//if (nn->rp_helper)
@@ -1081,11 +1118,6 @@
{
if(peer == static_cast<GmeObject *>(*i)->self)
{
- //we need to check if there is an associated helper connection
- GmeObject * go = new GmeObject( conn, mydn);
- go->RemoveHelperConnections();
- delete go;
-
conn->DestroyObject();
break;
}
@@ -1977,42 +2009,6 @@
setParent(NULL, NULL);
};
- void GmeObject::RemoveHelperConnections()
- {
- //we have to check if this object has an rp_helper helper connection
- if (self)
- {//folders won;t have connections
- set< ::Uml::AssociationRole> all_roles;
- set< ::Uml::AssociationRole> ars = Uml::AncestorAssociationTargetRoles(m_type);//.associationRoles();
- set< ::Uml::AssociationRole>::iterator ars_i;
- for (ars_i = ars.begin(); ars_i != ars.end(); ars_i++)
- {
- if (ars_i->isNavigable()) all_roles.insert(*ars_i);
- ::Uml::AssociationRole orole = Uml::theOther(*ars_i);
- if (orole.isNavigable()) all_roles.insert(orole);
-
- };
-
- for (ars_i = all_roles.begin(); ars_i != all_roles.end(); ars_i++)
- {
- string oar_name = ars_i->name();
- ::Uml::Association assoc = ars_i->parent();
- assocmapitem *nn = ((GmeDataNetwork *)__getdn())->amap.find(assoc.uniqueId())->second;
- if (nn->ot == OBJTYPE_CONNECTION && nn->rp_helper)
- {
- IMgaFCOsPtr fcos = RpHelperFindPeerFCOsFromRegistry(self,
- oar_name, false,
- (GmeDataNetwork *)__getdn());
- MGACOLL_ITERATE(IMgaFCO, fcos)
- {
- RpHelperRemoveFromRegistry(MGACOLL_ITER, self, oar_name);
- }
- MGACOLL_ITERATE_END;
- };
- };
- };
- };
-
void GmeObject::setParent(ObjectImpl *a, const ::Uml::CompositionParentRole &role, const bool direct)
{
((GmeDataNetwork*)mydn)->CountWriteOps();
@@ -2024,8 +2020,6 @@
COMTHROW(objself->get_Status(&oStatus));
if (oStatus == OBJECT_EXISTS)
{
-
- RemoveHelperConnections();
COMTHROW(objself->DestroyObject());
}
Modified: UDM/trunk/tests/test_refports/RefPortsTest.cpp
==============================================================================
--- UDM/trunk/tests/test_refports/RefPortsTest.cpp Fri Jun 29 13:15:08 2012 (r4068)
+++ UDM/trunk/tests/test_refports/RefPortsTest.cpp Thu Jul 5 16:41:52 2012 (r4069)
@@ -58,19 +58,45 @@
BPar bpar2 = BPar::Create(root);
bpar2.name() = "bpar2";
+
+ ARef1::Create(root_refs).ref() = apar;
// create references
ARef1 aref1 = ARef1::Create(root_refs);
aref1.name() = "aref1";
+ ARef1::Create(root_refs).ref() = apar;
+
+ BRef::Create(root_refs).ref() = bpar;
+ BRef::Create(root_refs).ref() = bpar2;
+
BRef bref = BRef::Create(root_refs);
bref.name() = "bref";
+ BRef::Create(root_refs).ref() = bpar;
+ BRef::Create(root_refs).ref() = bpar2;
+
+ BRef::Create(root_refs2).ref() = bpar;
+ BRef::Create(root_refs2).ref() = bpar2;
+
BRef bref2 = BRef::Create(root_refs2);
bref2.name() = "bref2";
+ BRef::Create(root_refs2).ref() = bpar;
+ BRef::Create(root_refs2).ref() = bpar2;
+ BRef::Create(root_refs2).ref() = bref2;
+
+ BRef::Create(root_refs).ref() = bpar;
+ BRef::Create(root_refs).ref() = bpar2;
+ BRef::Create(root_refs).ref() = bref2;
+
+
BRef bref3 = BRef::Create(root_refs);
bref3.name() = "bref3";
+ BRef::Create(root_refs).ref() = bpar;
+ BRef::Create(root_refs).ref() = bpar2;
+ BRef::Create(root_refs).ref() = bref2;
+
aref1.ref() = apar;
bref.ref() = bpar;
bref2.ref() = bpar2;
@@ -97,14 +123,33 @@
CPPUNIT_ASSERT(ARef1::Cast(c.a_end__rp_container()) == aref1);
CPPUNIT_ASSERT(BRef::Cast(c.b_end__rp_container()) == bref);
+ c.a_end__rp_container() = ARef1::Cast(Udm::null);
+ c.b_end__rp_container() = BRef::Cast(Udm::null);
+
+ CPPUNIT_ASSERT(ARef1::Cast(c.a_end__rp_container()) == Udm::null);
+ CPPUNIT_ASSERT(BRef::Cast(c.b_end__rp_container()) == Udm::null);
+
+ c.a_end__rp_container() = aref1;
+ c.b_end__rp_container() = bref2;
+ c.b_end__rp_container() = bref;
+
+ CPPUNIT_ASSERT(ARef1::Cast(c.a_end__rp_container()) == aref1);
+ CPPUNIT_ASSERT(BRef::Cast(c.b_end__rp_container()) == bref);
+
// we allow aref and bref.__rp_container_rev().size() == 0 before a_ and b_end_end are set
// connect src and dst
c.a_end_end() = a;
c.b_end_end() = b;
-
+
+ std::set<C> conns;
ARef1 aref1_ = ARef1::Cast(c.a_end__rp_container());
- std::set<C> conns = aref1_.a_end__rp_container_rev();
+ conns = aref1_.a_end__rp_container_rev();
+ CPPUNIT_ASSERT_EQUAL((size_t)1, conns.size());
+ CPPUNIT_ASSERT_EQUAL(c, *conns.begin());
+
+ BRef bref1_ = BRef::Cast(c.b_end__rp_container());
+ conns = bref1_.b_end__rp_container_rev();
CPPUNIT_ASSERT_EQUAL((size_t)1, conns.size());
CPPUNIT_ASSERT_EQUAL(c, *conns.begin());
@@ -127,9 +172,17 @@
CPPUNIT_ASSERT(BRef::Cast(c.b_end__rp_container()) == bref3);
#endif
+ set<B> bs;
+ conns.clear();
+ a.b_end() = conns;
+
// connect to another refport using another refport container
- c.b_end__rp_container() = bref3;
+ // c.b_end__rp_container() = bref3;
+ conns.clear();
+ conns.insert(c);
+ bref3.b_end__rp_container_rev() = conns;
c.b_end_end() = b2;
+ CPPUNIT_ASSERT_EQUAL(BRef::Cast(c.b_end__rp_container()), bref3);
// show connecting chains
{
More information about the Mobies-commit
mailing list