[Mobies-commit] [commit] r4171 - in UDM/trunk: Projects/Win32/VC10/src/UdmDll Projects/Win32/VC9/src/UdmDll src/UdmBase src/UdmGme

ksmyth at redhat1.isis.vanderbilt.edu ksmyth at redhat1.isis.vanderbilt.edu
Wed Jun 19 15:14:30 CDT 2013


Author: ksmyth
Date: Wed Jun 19 15:14:30 2013
New Revision: 4171

Log:
UdmGme: Fix GetMetaRole for CreateChild (via CopyObjectHierarchy) for CrossNS Compositions: the namespace is in the IMgaMetaRole.Name. Fix GetMetaRole for a class that inherits from an abstract class with no other descendents. Fixes META-990

Modified:
   UDM/trunk/Projects/Win32/VC10/src/UdmDll/UdmDll.rc
   UDM/trunk/Projects/Win32/VC9/src/UdmDll/UdmDll.rc
   UDM/trunk/src/UdmBase/UmlExt.cpp
   UDM/trunk/src/UdmGme/UdmGme.cpp

Modified: UDM/trunk/Projects/Win32/VC10/src/UdmDll/UdmDll.rc
==============================================================================
--- UDM/trunk/Projects/Win32/VC10/src/UdmDll/UdmDll.rc	Wed Jun 19 15:13:16 2013	(r4170)
+++ UDM/trunk/Projects/Win32/VC10/src/UdmDll/UdmDll.rc	Wed Jun 19 15:14:30 2013	(r4171)
@@ -47,7 +47,7 @@
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 3,2,11,4
+ FILEVERSION 3,2,11,6
  PRODUCTVERSION 3,2,11
  FILEFLAGSMASK 0x17L
 #ifdef _DEBUG

Modified: UDM/trunk/Projects/Win32/VC9/src/UdmDll/UdmDll.rc
==============================================================================
--- UDM/trunk/Projects/Win32/VC9/src/UdmDll/UdmDll.rc	Wed Jun 19 15:13:16 2013	(r4170)
+++ UDM/trunk/Projects/Win32/VC9/src/UdmDll/UdmDll.rc	Wed Jun 19 15:14:30 2013	(r4171)
@@ -47,7 +47,7 @@
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 3,2,11,4
+ FILEVERSION 3,2,11,6
  PRODUCTVERSION 3,2,11
  FILEFLAGSMASK 0x17L
 #ifdef _DEBUG

Modified: UDM/trunk/src/UdmBase/UmlExt.cpp
==============================================================================
--- UDM/trunk/src/UdmBase/UmlExt.cpp	Wed Jun 19 15:13:16 2013	(r4170)
+++ UDM/trunk/src/UdmBase/UmlExt.cpp	Wed Jun 19 15:14:30 2013	(r4171)
@@ -732,15 +732,14 @@
 	{
 		int i = 0;
 		set<Class> descs = DescendantClasses(ccr.target());
-		set<Class>::iterator descs_i = descs.begin();
 
-		while (descs_i != descs.end())
+		for (set<Class>::iterator descs_i = descs.begin(); descs_i != descs.end(); descs_i++)
 		{
-			if (i > 1) return true;
-			if ((bool)(descs_i->isAbstract()) == false) i++;
-			descs_i++;
+			if ((bool)(descs_i->isAbstract()) == false || *descs_i == static_cast<Class>(ccr.target()))
+				i++;
+			if (i > 1)
+				return true;
 		}
-		if (i> 1) return true;
 
 		return false;
 	}

Modified: UDM/trunk/src/UdmGme/UdmGme.cpp
==============================================================================
--- UDM/trunk/src/UdmGme/UdmGme.cpp	Wed Jun 19 15:13:16 2013	(r4170)
+++ UDM/trunk/src/UdmGme/UdmGme.cpp	Wed Jun 19 15:14:30 2013	(r4171)
@@ -2227,23 +2227,34 @@
 			//string shr = Uml::MakeShortRoleName(ccr);
 			//string kn = kind.name();
 
-			if ( ((string)ccr.name()).compare(((::Uml::Class)ccr.target()).name()) == 0)
+			//auto dbg1 = (string)ccr.name();
+			//auto dbg2 = (string)((::Uml::Class)ccr.target()).name();
+			//auto dbg3 = PATHGET(kind);
+
+			string target = ((::Uml::Class)ccr.target()).name();
+			if (Uml::IsCrossNSComposition(ccr.parent()))
+			{
+				Uml::Namespace ns = static_cast<Uml::Class>(ccr.target()).parent_ns();
+				while (ns)
+				{
+					target = static_cast<std::string>(ns.name()) + "_" + target;
+					ns = ns.parent_ns();
+				}
+			}
+
+			if ( ((string)ccr.name()).compare(target) == 0)
 			{
 				//the rolename might be created with ccr.target().name()
 				//by the CPP code generator. Hence, the MGA rolename may be
 				//empty or may be Uml::MakeShortRoleName, no one can tell.
 				
 				//first we try without rolename appended, this happens more often
-				try 
-				{
-					mn = PATHGET(kind);
-					rr = mmodel->RoleByName[SmartBSTR(mn.c_str())];
-				}
-				catch(udm_exception& )
+				mn = PATHGET(kind);
+				mmodel->get_RoleByName(SmartBSTR(mn.c_str()), &rr);
+				if (rr == NULL)
 				{
 					mn = PATHGET(kind) + (string)ccr.name();
 					rr = mmodel->RoleByName[SmartBSTR(mn.c_str())];
-
 				}
 			}
 			else
@@ -2259,7 +2270,7 @@
 
 			
 			//MakeShortRolename is not good - when ccr has no name, and it points towards an abstract base class,
-			//the returned string will be the name of the abstract base class, but it should be 
+			//the returned string will be the name of the abstract base class, but it should be the inherited class
 
 			string roleWithNamespaces = ccr.name();
 			if (roleWithNamespaces.empty())
@@ -2269,28 +2280,14 @@
 			}
 			else
 			{
-				if (roleWithNamespaces.length() != 0)
+				Uml::Namespace ns = static_cast<Uml::Class>(ccr.target()).parent_ns();
+				while (ns)
 				{
-					Uml::Namespace ns = static_cast<Uml::Class>(ccr.target()).parent_ns();
-					while (ns)
-					{
-						roleWithNamespaces = static_cast<std::string>(ns.name()) + "::" + roleWithNamespaces;
-						ns = ns.parent_ns();
-					}
-				}
-
-				IMgaMetaRolesPtr rrs;
-				rrs = mmodel->Roles;
-				MGACOLL_ITERATE(IMgaMetaRole, rrs) 
-				{
-					if (roleWithNamespaces == static_cast<const char*>(MGACOLL_ITER->GetName())) {
-						rr = MGACOLL_ITER;
-						break;
-					}
+					roleWithNamespaces = static_cast<std::string>(ns.name()) + "::" + roleWithNamespaces;
+					ns = ns.parent_ns();
 				}
-				MGACOLL_ITERATE_END;
 
-				//rr = mmodel->RoleByName[SmartBSTR(rn.c_str())];
+				mmodel->get_RoleByName(_bstr_t(roleWithNamespaces.c_str()), &rr);
 			}
 			
 			//mn = Uml::MakeShortRoleName(ccr);
@@ -2298,8 +2295,10 @@
 
 		}
 
-		if(rr == NULL) 
+		if(rr == NULL)
+		{
 			throw udm_exception("Role not found in model: " + mn);
+		}
 
 		return rr;
 


More information about the Mobies-commit mailing list