[Mobies-commit] [commit] r4003 - in UDM/trunk: Projects/Win32/VC10/tests/testGetAdjacentObjects Projects/Win32/VC9/tests/testGetAdjacentObjects include src/UdmBase src/UdmGme tests/testGetAdjacentObjects

endre at redhat1.isis.vanderbilt.edu endre at redhat1.isis.vanderbilt.edu
Thu Feb 16 05:16:25 CST 2012


Author: endre
Date: Thu Feb 16 05:16:25 2012
New Revision: 4003

Log:
Add Object::getSrcObject() and Object::getDstObject() to get the src/dst of an association class instance.

The functions are useful when the backend knows the source and destination of a connection, like the MGA backend.

Modified:
   UDM/trunk/Projects/Win32/VC10/tests/testGetAdjacentObjects/testGetAdjacentObjects.vcxproj
   UDM/trunk/Projects/Win32/VC9/tests/testGetAdjacentObjects/testGetAdjacentObjects.vcproj
   UDM/trunk/include/UdmBase.h
   UDM/trunk/include/UdmGme.h
   UDM/trunk/src/UdmBase/UdmBase.cpp
   UDM/trunk/src/UdmBase/UdmTomi.cpp
   UDM/trunk/src/UdmGme/UdmGme.cpp
   UDM/trunk/tests/testGetAdjacentObjects/Makefile.am
   UDM/trunk/tests/testGetAdjacentObjects/TestGetAdjacentObjects.cpp
   UDM/trunk/tests/testGetAdjacentObjects/TestGetAdjacentObjects.h

Modified: UDM/trunk/Projects/Win32/VC10/tests/testGetAdjacentObjects/testGetAdjacentObjects.vcxproj
==============================================================================
--- UDM/trunk/Projects/Win32/VC10/tests/testGetAdjacentObjects/testGetAdjacentObjects.vcxproj	Thu Feb  2 21:24:29 2012	(r4002)
+++ UDM/trunk/Projects/Win32/VC10/tests/testGetAdjacentObjects/testGetAdjacentObjects.vcxproj	Thu Feb 16 05:16:25 2012	(r4003)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug|Win32">
@@ -84,7 +84,7 @@
     </PreBuildEvent>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\..\..\..\..\include;$(OutDir)Gen\tests\testGetAdjacentObjects;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\..\..\..\include;$(OutDir)Gen\tests\testGetAdjacentObjects;$(OutDir)\Gen\samples;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>UDM_DYNAMIC_LINKING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -130,7 +130,7 @@
     </PreBuildEvent>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\..\..\..\..\include;$(OutDir)Gen\tests\testGetAdjacentObjects;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\..\..\..\include;$(OutDir)Gen\tests\testGetAdjacentObjects;$(OutDir)\Gen\samples;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>UDM_DYNAMIC_LINKING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -173,7 +173,7 @@
 </Command>
     </PreBuildEvent>
     <ClCompile>
-      <AdditionalIncludeDirectories>..\..\..\..\..\include;$(OutDir)Gen\tests\testGetAdjacentObjects;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\..\..\..\include;$(OutDir)Gen\tests\testGetAdjacentObjects;$(OutDir)\Gen\samples;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>UDM_DYNAMIC_LINKING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <PrecompiledHeader>
@@ -218,7 +218,7 @@
 </Command>
     </PreBuildEvent>
     <ClCompile>
-      <AdditionalIncludeDirectories>..\..\..\..\..\include;$(OutDir)Gen\tests\testGetAdjacentObjects;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\..\..\..\include;$(OutDir)Gen\tests\testGetAdjacentObjects;$(OutDir)\Gen\samples;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>UDM_DYNAMIC_LINKING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <PrecompiledHeader>
@@ -364,6 +364,11 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     </CustomBuild>
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\CreateLampDiagram\CreateLampDiagram.vcxproj">
+      <Project>{3fb0a5a6-8815-45a3-8d68-777c708410fb}</Project>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>

Modified: UDM/trunk/Projects/Win32/VC9/tests/testGetAdjacentObjects/testGetAdjacentObjects.vcproj
==============================================================================
--- UDM/trunk/Projects/Win32/VC9/tests/testGetAdjacentObjects/testGetAdjacentObjects.vcproj	Thu Feb  2 21:24:29 2012	(r4002)
+++ UDM/trunk/Projects/Win32/VC9/tests/testGetAdjacentObjects/testGetAdjacentObjects.vcproj	Thu Feb 16 05:16:25 2012	(r4003)
@@ -47,7 +47,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\..\..\..\..\include;$(OutDir)\Gen\tests\testGetAdjacentObjects"
+				AdditionalIncludeDirectories="..\..\..\..\..\include;$(OutDir)\Gen\tests\testGetAdjacentObjects;$(OutDir)\Gen\samples"
 				PreprocessorDefinitions="UDM_DYNAMIC_LINKING"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -133,7 +133,7 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="..\..\..\..\..\include;$(OutDir)\Gen\tests\testGetAdjacentObjects"
+				AdditionalIncludeDirectories="..\..\..\..\..\include;$(OutDir)\Gen\tests\testGetAdjacentObjects;$(OutDir)\Gen\samples"
 				PreprocessorDefinitions="UDM_DYNAMIC_LINKING"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
@@ -197,11 +197,7 @@
 			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
 			>
 			<File
-				RelativePath="..\..\..\..\..\tests\testGetAdjacentObjects\main.cpp"
-				>
-			</File>
-			<File
-				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\tests\testGetAdjacentObjects\PackageA.cpp"
+				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\samples\LampDiagram.cpp"
 				>
 				<FileConfiguration
 					Name="Release|Win32"
@@ -213,7 +209,7 @@
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\..\..\..\Build\Win32\VC9\Release\Gen\tests\testGetAdjacentObjects\PackageA.cpp"
+				RelativePath="..\..\..\..\..\Build\Win32\VC9\Release\Gen\samples\LampDiagram.cpp"
 				>
 				<FileConfiguration
 					Name="Debug|Win32"
@@ -225,7 +221,11 @@
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\tests\testGetAdjacentObjects\PackageB.cpp"
+				RelativePath="..\..\..\..\..\tests\testGetAdjacentObjects\main.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\tests\testGetAdjacentObjects\PackageA.cpp"
 				>
 				<FileConfiguration
 					Name="Release|Win32"
@@ -237,6 +237,18 @@
 				</FileConfiguration>
 			</File>
 			<File
+				RelativePath="..\..\..\..\..\Build\Win32\VC9\Release\Gen\tests\testGetAdjacentObjects\PackageA.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
 				RelativePath="..\..\..\..\..\Build\Win32\VC9\Release\Gen\tests\testGetAdjacentObjects\PackageB.cpp"
 				>
 				<FileConfiguration
@@ -249,7 +261,7 @@
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.cpp"
+				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\tests\testGetAdjacentObjects\PackageB.cpp"
 				>
 				<FileConfiguration
 					Name="Release|Win32"
@@ -273,6 +285,18 @@
 				</FileConfiguration>
 			</File>
 			<File
+				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.cpp"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
 				RelativePath="..\..\..\..\..\tests\testGetAdjacentObjects\TestGetAdjacentObjects.cpp"
 				>
 			</File>
@@ -283,7 +307,7 @@
 			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
 			>
 			<File
-				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\tests\testGetAdjacentObjects\PackageA.h"
+				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\samples\LampDiagram.h"
 				>
 				<FileConfiguration
 					Name="Release|Win32"
@@ -293,6 +317,19 @@
 						Name="VCCustomBuildTool"
 					/>
 				</FileConfiguration>
+</File>
+
+			<File
+				RelativePath="..\..\..\..\..\Build\Win32\VC9\Release\Gen\samples\LampDiagram.h"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\..\..\..\Build\Win32\VC9\Release\Gen\tests\testGetAdjacentObjects\PackageA.h"
@@ -307,7 +344,7 @@
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\tests\testGetAdjacentObjects\PackageB.h"
+				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\tests\testGetAdjacentObjects\PackageA.h"
 				>
 				<FileConfiguration
 					Name="Release|Win32"
@@ -331,7 +368,7 @@
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.h"
+				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\tests\testGetAdjacentObjects\PackageB.h"
 				>
 				<FileConfiguration
 					Name="Release|Win32"
@@ -355,6 +392,18 @@
 				</FileConfiguration>
 			</File>
 			<File
+				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.h"
+				>
+				<FileConfiguration
+					Name="Release|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
 				RelativePath="..\..\..\..\..\tests\testGetAdjacentObjects\testGetAdjacentObjects.h"
 				>
 			</File>
@@ -389,46 +438,46 @@
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\tests\testGetAdjacentObjects\testAssociationScenarios_udm.udm"
+				RelativePath="..\..\..\..\..\Build\Win32\VC9\Release\Gen\tests\testGetAdjacentObjects\testAssociationScenarios_udm.udm"
 				>
 				<FileConfiguration
 					Name="Debug|Win32"
+					ExcludedFromBuild="true"
 					>
 					<Tool
 						Name="VCCustomBuildTool"
-						Description="Generating UDM API files..."
-						CommandLine="&quot;$(OutDir)\udmD.exe&quot; -o &quot;$(OutDir)\Gen\tests\testGetAdjacentObjects&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
-						Outputs="$(OutDir)\Gen\tests\testGetAdjacentObjects\PackageA.cpp; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageA.h; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageA.xsd; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageB.cpp; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageB.h; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageB.xsd; $(OutDir)\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.cpp; $(OutDir)\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.h; $(OutDir)\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.xsd"
 					/>
 				</FileConfiguration>
 				<FileConfiguration
 					Name="Release|Win32"
-					ExcludedFromBuild="true"
 					>
 					<Tool
 						Name="VCCustomBuildTool"
+						Description="Generating UDM API files..."
+						CommandLine="&quot;$(OutDir)\udm.exe&quot; -o &quot;$(OutDir)\Gen\tests\testGetAdjacentObjects&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+						Outputs="$(OutDir)\Gen\tests\testGetAdjacentObjects\PackageA.cpp; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageA.h; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageA.xsd; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageB.cpp; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageB.h; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageB.xsd; $(OutDir)\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.cpp; $(OutDir)\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.h; $(OutDir)\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.xsd"
 					/>
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\..\..\..\Build\Win32\VC9\Release\Gen\tests\testGetAdjacentObjects\testAssociationScenarios_udm.udm"
+				RelativePath="..\..\..\..\..\Build\Win32\VC9\Debug\Gen\tests\testGetAdjacentObjects\testAssociationScenarios_udm.udm"
 				>
 				<FileConfiguration
 					Name="Debug|Win32"
-					ExcludedFromBuild="true"
 					>
 					<Tool
 						Name="VCCustomBuildTool"
+						Description="Generating UDM API files..."
+						CommandLine="&quot;$(OutDir)\udmD.exe&quot; -o &quot;$(OutDir)\Gen\tests\testGetAdjacentObjects&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+						Outputs="$(OutDir)\Gen\tests\testGetAdjacentObjects\PackageA.cpp; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageA.h; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageA.xsd; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageB.cpp; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageB.h; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageB.xsd; $(OutDir)\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.cpp; $(OutDir)\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.h; $(OutDir)\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.xsd"
 					/>
 				</FileConfiguration>
 				<FileConfiguration
 					Name="Release|Win32"
+					ExcludedFromBuild="true"
 					>
 					<Tool
 						Name="VCCustomBuildTool"
-						Description="Generating UDM API files..."
-						CommandLine="&quot;$(OutDir)\udm.exe&quot; -o &quot;$(OutDir)\Gen\tests\testGetAdjacentObjects&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
-						Outputs="$(OutDir)\Gen\tests\testGetAdjacentObjects\PackageA.cpp; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageA.h; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageA.xsd; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageB.cpp; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageB.h; $(OutDir)\Gen\tests\testGetAdjacentObjects\PackageB.xsd; $(OutDir)\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.cpp; $(OutDir)\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.h; $(OutDir)\Gen\tests\testGetAdjacentObjects\testAssociationScenarios.xsd"
 					/>
 				</FileConfiguration>
 			</File>

Modified: UDM/trunk/include/UdmBase.h
==============================================================================
--- UDM/trunk/include/UdmBase.h	Thu Feb  2 21:24:29 2012	(r4002)
+++ UDM/trunk/include/UdmBase.h	Thu Feb 16 05:16:25 2012	(r4003)
@@ -275,6 +275,13 @@
 // etc.
 	} attstatus_enum;
 
+	// Only the MGA backend knows the direction
+	struct AssociationRoleInfo
+	{
+		bool has_direction;
+		bool is_src;
+	};
+
 
 	class DataNetwork;
 	class UdmProject;
@@ -2905,7 +2912,6 @@
 			AssociationInfo(const ::Uml::Class & ref) : clsAssociation(ref){};
 		};
 
-
 		// UDM TOMI Paradigm Independent Interface
 		struct CompositionInfo
 		{	
@@ -3015,6 +3021,12 @@
 		// UDM TOMI Paradigm Independent Interface
 		// Gets the two peers from an object of association class type
 		pair<Object,Object> GetPeersFromAssociationClassObject();
+		// UDM TOMI Paradigm Independent Interface
+		// For an association class instance, returns the source and, respectively, the
+		// destination, if the source role or destination role can be established (MGA backend).
+		// The Null object is returned if the roles cannot be established.
+		Object getSrcObject();
+		Object getDstObject();
 		// Functions for creating Udm entities
 		// UDM TOMI Paradigm Independent Interface
 		// Creates an object of clsType
@@ -3292,6 +3304,8 @@
 
 	virtual UDM_DLL set<Object> GetAllInstancesOf(const ::Uml::Class& meta);
 
+	virtual UDM_DLL struct AssociationRoleInfo GetAssociationRoleInfo(const ::Uml::AssociationRole &role) const;
+
 	friend void ::Uml::Initialize();
 };
 

Modified: UDM/trunk/include/UdmGme.h
==============================================================================
--- UDM/trunk/include/UdmGme.h	Thu Feb  2 21:24:29 2012	(r4002)
+++ UDM/trunk/include/UdmGme.h	Thu Feb 16 05:16:25 2012	(r4003)
@@ -146,6 +146,8 @@
 			return new GmeDataNetwork(meta, project);
 		}
 
+		UDM_DLL struct Udm::AssociationRoleInfo GetAssociationRoleInfo(const ::Uml::AssociationRole &role) const;
+
 	private:
 		int writeOps;
 		bool hasOpened;

Modified: UDM/trunk/src/UdmBase/UdmBase.cpp
==============================================================================
--- UDM/trunk/src/UdmBase/UdmBase.cpp	Thu Feb  2 21:24:29 2012	(r4002)
+++ UDM/trunk/src/UdmBase/UdmBase.cpp	Thu Feb 16 05:16:25 2012	(r4003)
@@ -380,6 +380,14 @@
 		throw udm_exception("Unsupported method");
 	}
 
+	UDM_DLL struct AssociationRoleInfo DataNetwork::GetAssociationRoleInfo(const ::Uml::AssociationRole &role) const
+	{
+		struct AssociationRoleInfo ret;
+		ret.has_direction = ret.is_src = false;
+
+		return ret;
+	}
+
 
 	//	--- attribute setters/getters for multiple value (array) type attributes
 

Modified: UDM/trunk/src/UdmBase/UdmTomi.cpp
==============================================================================
--- UDM/trunk/src/UdmBase/UdmTomi.cpp	Thu Feb  2 21:24:29 2012	(r4002)
+++ UDM/trunk/src/UdmBase/UdmTomi.cpp	Thu Feb 16 05:16:25 2012	(r4003)
@@ -1266,6 +1266,97 @@
 };
 
 
+// UDM TOMI Paradigm Independent Interface
+// For an association class instance, returns the source and, respectively, the
+// destination, if the source role or destination role can be established (MGA backedn)
+UDM_DLL	Object Object::getSrcObject()
+{
+	Object ret;
+
+	set< ::Uml::Class> ancestorClasses = ::Uml::AncestorClasses(type());
+	for (set< ::Uml::Class>::iterator p_currClass = ancestorClasses.begin();
+				p_currClass != ancestorClasses.end(); p_currClass++)
+	{
+		::Uml::Association assoc = p_currClass->association();
+		if (assoc) 
+		{
+			set< ::Uml::AssociationRole> peerRoles = assoc.roles();
+			::Uml::AssociationRole role = *peerRoles.begin();
+			
+			struct AssociationRoleInfo roleInfo = __impl()->__getdn()->GetAssociationRoleInfo(role);
+			if (roleInfo.has_direction) {
+				vector<ObjectImpl*> srcPeers = roleInfo.is_src
+					? impl->getAssociation(role, Udm::TARGETFROMCLASS)
+					: impl->getAssociation(::Uml::theOther(role), Udm::TARGETFROMCLASS);
+				ret = *srcPeers.begin();
+			}
+
+			//through the inheritence hierarchy, only one association class can exist
+			continue;
+		}
+	}
+	if ( ret == &Udm::_null )
+	{
+		//try cross package
+		if (__impl()->__getdn()->GetProject())
+		{
+			UdmProject * pr = __impl()->__getdn()->GetProject();
+			Object src_o = pr->GetPlaceHolder(*this, false);
+			if (src_o)
+			{
+				Object ret_o = src_o.getSrcObject();
+				ret = pr->GetRealObject(ret_o);
+			}
+		};
+	}
+
+	return ret;
+}
+
+UDM_DLL	Object Object::getDstObject()
+{
+	Object ret;
+
+	set< ::Uml::Class> ancestorClasses = ::Uml::AncestorClasses(type());
+	for (set< ::Uml::Class>::iterator p_currClass = ancestorClasses.begin();
+				p_currClass != ancestorClasses.end(); p_currClass++)
+	{
+		::Uml::Association assoc = p_currClass->association();
+		if (assoc) 
+		{
+			set< ::Uml::AssociationRole> peerRoles = assoc.roles();
+			::Uml::AssociationRole role = *peerRoles.begin();
+			
+			struct AssociationRoleInfo roleInfo = __impl()->__getdn()->GetAssociationRoleInfo(role);
+			if (roleInfo.has_direction) {
+				vector<ObjectImpl*> dstPeers = !roleInfo.is_src
+					? impl->getAssociation(role, Udm::TARGETFROMCLASS)
+					: impl->getAssociation(::Uml::theOther(role), Udm::TARGETFROMCLASS);
+				ret = *dstPeers.begin();
+			}
+
+			//through the inheritence hierarchy, only one association class can exist
+			continue;
+		}
+	}
+	if ( ret == &Udm::_null )
+	{
+		//try cross package
+		if (__impl()->__getdn()->GetProject())
+		{
+			UdmProject * pr = __impl()->__getdn()->GetProject();
+			Object src_o = pr->GetPlaceHolder(*this, false);
+			if (src_o)
+			{
+				Object ret_o = src_o.getDstObject();
+				ret = pr->GetRealObject(ret_o);
+			}
+		};
+	}
+
+	return ret;
+}
+
 
 // Functions for creating Udm entities
 

Modified: UDM/trunk/src/UdmGme/UdmGme.cpp
==============================================================================
--- UDM/trunk/src/UdmGme/UdmGme.cpp	Thu Feb  2 21:24:29 2012	(r4002)
+++ UDM/trunk/src/UdmGme/UdmGme.cpp	Thu Feb 16 05:16:25 2012	(r4003)
@@ -3683,6 +3683,19 @@
 		amap.clear();
 	}
 
+	UDM_DLL struct Udm::AssociationRoleInfo GmeDataNetwork::GetAssociationRoleInfo(const ::Uml::AssociationRole &role) const
+	{
+		struct Udm::AssociationRoleInfo ret;
+
+		::Uml::Association assoc = role.parent();
+		assocmapitem *nn = amap.find(assoc.uniqueId())->second;
+
+		ret.has_direction = true;
+		ret.is_src = nn->primary == role;
+
+		return ret;
+	}
+
 		void CheckVersion(IMgaProject *p) {
 		// IGMEVersionInfo and IMgaVersionInfo have the same GUID and vtable definition, so this works across versions
 #ifdef GME_VS10

Modified: UDM/trunk/tests/testGetAdjacentObjects/Makefile.am
==============================================================================
--- UDM/trunk/tests/testGetAdjacentObjects/Makefile.am	Thu Feb  2 21:24:29 2012	(r4002)
+++ UDM/trunk/tests/testGetAdjacentObjects/Makefile.am	Thu Feb 16 05:16:25 2012	(r4003)
@@ -9,7 +9,8 @@
 				  PackageB.cpp PackageB.h PackageB.xsd \
 				  testAssociationScenarios.cpp \
 				  testAssociationScenarios.h \
-				  testAssociationScenarios.xsd
+				  testAssociationScenarios.xsd \
+				  LampDiagram.cpp LampDiagram.h LampDiagram.xsd
 TestGetAdjacentObjects_SOURCES	= main.cpp TestGetAdjacentObjects.cpp \
 				  TestGetAdjacentObjects.h
 nodist_TestGetAdjacentObjects_SOURCES	= $(BUILT_SOURCES)
@@ -18,10 +19,11 @@
 CLEANFILES		= $(BUILT_SOURCES) sources-stamp testmodel.udm
 
 
-sources-stamp: testAssociationScenarios_udm.udm ../../bin/Udm Makefile
+sources-stamp: testAssociationScenarios_udm.udm ../../samples/LampDiagram_udm.xml ../../bin/Udm Makefile
 	@rm -f sources-temp
 	@touch sources-temp
-	../../bin/Udm $< -d ../../etc -T
+	../../bin/Udm testAssociationScenarios_udm.udm -d ../../etc -T
+	../../bin/Udm ../../samples/LampDiagram_udm.xml -d ../../etc -T
 	@mv -f sources-temp $@
 
 $(BUILT_SOURCES): sources-stamp

Modified: UDM/trunk/tests/testGetAdjacentObjects/TestGetAdjacentObjects.cpp
==============================================================================
--- UDM/trunk/tests/testGetAdjacentObjects/TestGetAdjacentObjects.cpp	Thu Feb  2 21:24:29 2012	(r4002)
+++ UDM/trunk/tests/testGetAdjacentObjects/TestGetAdjacentObjects.cpp	Thu Feb 16 05:16:25 2012	(r4003)
@@ -424,6 +424,42 @@
 	CPPUNIT_ASSERT( res4b == comp4b);
 }
 
+void testLampGetSrcDstObject(const string &dst, bool has_direction_support)
+{
+	Udm::SmartDataNetwork nw(LampDiagram::diagram);
+	nw.CreateNew(dst, "LampDiagram", LampDiagram::RootFolder::meta, Udm::CHANGES_LOST_DEFAULT);
+
+	LampDiagram::RootFolder rf = LampDiagram::RootFolder::Cast(nw.GetRootObject());
+	LampDiagram::Lamp lamp = LampDiagram::Lamp::Create(rf);
+
+	LampDiagram::ControlLink cl = LampDiagram::ControlLink::Create(lamp);
+	LampDiagram::Bulb bulb = LampDiagram::Bulb::Create(lamp);
+	LampDiagram::Switch mswitch = LampDiagram::Switch::Create(lamp, LampDiagram::Lamp::meta_MainSwitch);
+	
+	cl.src_end() = bulb;
+	cl.dst_end() = mswitch;
+
+	if (has_direction_support) {
+		CPPUNIT_ASSERT( cl.getSrcObject() == bulb );
+		CPPUNIT_ASSERT( cl.getDstObject() == mswitch );
+	} else {
+		CPPUNIT_ASSERT( cl.getSrcObject() == &Udm::_null );
+		CPPUNIT_ASSERT( cl.getDstObject() == &Udm::_null );
+	}
+
+	nw.CloseNoUpdate();
+}
+
+void UdmTests::TestGetAdjacentObjects::testGetSrcDstObject()
+{
+
+#ifdef _WIN32
+	testLampGetSrcDstObject("lamptest.mga", true);
+#endif
+
+	testLampGetSrcDstObject("lamptest.mem", false);
+}
+
 void UdmTests::TestGetAdjacentObjects::test()
 {
 	try {
@@ -435,6 +471,7 @@
 		testAssocsFrom_clA1();
 		testAssocsFrom_clA2Base();
 		testAssocsFrom_clA2();
+		testGetSrcDstObject();
 	} catch (const udm_exception& e) {
 		std::cout << e.what() << std::endl;
 		CPPUNIT_FAIL("Udm exception");

Modified: UDM/trunk/tests/testGetAdjacentObjects/TestGetAdjacentObjects.h
==============================================================================
--- UDM/trunk/tests/testGetAdjacentObjects/TestGetAdjacentObjects.h	Thu Feb  2 21:24:29 2012	(r4002)
+++ UDM/trunk/tests/testGetAdjacentObjects/TestGetAdjacentObjects.h	Thu Feb 16 05:16:25 2012	(r4003)
@@ -6,9 +6,13 @@
 #include "testAssociationScenarios.h"
 #include "PackageA.h"
 #include "PackageB.h"
+#include "LampDiagram.h"
 
 using namespace std;
 
+#ifdef _WIN32
+UDM_USE_MGA
+#endif
 UDM_USE_DOM
 
 namespace UdmTests
@@ -34,6 +38,8 @@
 		void testAssocsFrom_clA1();
 		void testAssocsFrom_clA2Base();
 		void testAssocsFrom_clA2();
+		//
+		void testGetSrcDstObject();
 
 	private:
 		Udm::UdmProject _pr;


More information about the Mobies-commit mailing list