[Mobies-commit] [commit] r4165 - in UDM/trunk: Projects/Win32/VC9/src Projects/Win32/VC9/src/Udm Projects/Win32/VC9/src/Udm/PythonAPIGen bin src/Udm src/Udm/PythonAPIGen

endre at redhat1.isis.vanderbilt.edu endre at redhat1.isis.vanderbilt.edu
Wed Mar 13 12:16:48 CDT 2013


Author: endre
Date: Wed Mar 13 12:16:48 2013
New Revision: 4165

Log:
Python domain specific wrapper code generator and example code (in test_refports/RefPort.py)

Added:
   UDM/trunk/Projects/Win32/VC9/src/Udm/PythonAPIGen/
   UDM/trunk/Projects/Win32/VC9/src/Udm/PythonAPIGen/PythonAPIGen.vcproj
   UDM/trunk/bin/UdmPython.py
   UDM/trunk/bin/Uml.py
   UDM/trunk/src/Udm/PythonAPIGen/
   UDM/trunk/src/Udm/PythonAPIGen/PythonAPIGen.cpp
   UDM/trunk/src/Udm/PythonAPIGen/PythonAPIGen.h
Modified:
   UDM/trunk/Projects/Win32/VC9/src/Udm.sln
   UDM/trunk/Projects/Win32/VC9/src/Udm/Udm.vcproj
   UDM/trunk/src/Udm/Udm.cpp
   UDM/trunk/src/Udm/Udm.h

Modified: UDM/trunk/Projects/Win32/VC9/src/Udm.sln
==============================================================================
--- UDM/trunk/Projects/Win32/VC9/src/Udm.sln	Wed Feb 27 15:14:48 2013	(r4164)
+++ UDM/trunk/Projects/Win32/VC9/src/Udm.sln	Wed Mar 13 12:16:48 2013	(r4165)
@@ -105,6 +105,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MPCGen", "MPCGen\MPCGen.vcproj", "{7E5263AA-49FA-4EA3-89D8-427F40C5B0BC}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PythonAPIGen", "Udm\PythonAPIGen\PythonAPIGen.vcproj", "{F264EC86-7AE6-4A51-A35C-CB4947E57F28}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		BootUdmCompile Debug|Win32 = BootUdmCompile Debug|Win32
@@ -294,6 +296,16 @@
 		{7E5263AA-49FA-4EA3-89D8-427F40C5B0BC}.Release MinDependency|Win32.Build.0 = Release|Win32
 		{7E5263AA-49FA-4EA3-89D8-427F40C5B0BC}.Release|Win32.ActiveCfg = Release|Win32
 		{7E5263AA-49FA-4EA3-89D8-427F40C5B0BC}.Release|Win32.Build.0 = Release|Win32
+		{F264EC86-7AE6-4A51-A35C-CB4947E57F28}.BootUdmCompile Debug|Win32.ActiveCfg = Debug|Win32
+		{F264EC86-7AE6-4A51-A35C-CB4947E57F28}.BootUdmCompile Debug|Win32.Build.0 = Debug|Win32
+		{F264EC86-7AE6-4A51-A35C-CB4947E57F28}.BootUdmCompile Release|Win32.ActiveCfg = Release|Win32
+		{F264EC86-7AE6-4A51-A35C-CB4947E57F28}.BootUdmCompile Release|Win32.Build.0 = Release|Win32
+		{F264EC86-7AE6-4A51-A35C-CB4947E57F28}.Debug|Win32.ActiveCfg = Debug|Win32
+		{F264EC86-7AE6-4A51-A35C-CB4947E57F28}.Debug|Win32.Build.0 = Debug|Win32
+		{F264EC86-7AE6-4A51-A35C-CB4947E57F28}.Release MinDependency|Win32.ActiveCfg = Release|Win32
+		{F264EC86-7AE6-4A51-A35C-CB4947E57F28}.Release MinDependency|Win32.Build.0 = Release|Win32
+		{F264EC86-7AE6-4A51-A35C-CB4947E57F28}.Release|Win32.ActiveCfg = Release|Win32
+		{F264EC86-7AE6-4A51-A35C-CB4947E57F28}.Release|Win32.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

Added: UDM/trunk/Projects/Win32/VC9/src/Udm/PythonAPIGen/PythonAPIGen.vcproj
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ UDM/trunk/Projects/Win32/VC9/src/Udm/PythonAPIGen/PythonAPIGen.vcproj	Wed Mar 13 12:16:48 2013	(r4165)
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9,00"
+	Name="PythonAPIGen"
+	ProjectGUID="{F264EC86-7AE6-4A51-A35C-CB4947E57F28}"
+	RootNamespace="PythonAPIGen"
+	Keyword="Win32Proj"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="..\..\..\..\..\..\Build\Win32\VC9\Debug"
+			IntermediateDirectory="$(OutDir)\obj\src\Udm\$(ProjectName)"
+			ConfigurationType="4"
+			InheritedPropertySheets="..\..\Udm.vsprops"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\..\..\..\..\..\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				TreatWChar_tAsBuiltInType="true"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)\PythonAPIGenD.lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(UDM_PATH)&quot;\lib"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="..\..\..\..\..\..\Build\Win32\VC9\Release"
+			IntermediateDirectory="$(OutDir)\obj\src\Udm\$(ProjectName)"
+			ConfigurationType="4"
+			InheritedPropertySheets="..\..\Udm.vsprops"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="..\..\..\..\..\..\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+				RuntimeLibrary="2"
+				TreatWChar_tAsBuiltInType="true"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)\PythonAPIGen.lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(UDM_PATH)&quot;\lib"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\..\..\..\..\src\Udm\PythonAPIGen\PythonAPIGen.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\..\..\..\..\src\Udm\PythonAPIGen\PythonAPIGen.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+		</Filter>
+		<File
+			RelativePath="..\..\..\..\..\..\src\Udm\PythonAPIGen\ReadMe.txt"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

Modified: UDM/trunk/Projects/Win32/VC9/src/Udm/Udm.vcproj
==============================================================================
--- UDM/trunk/Projects/Win32/VC9/src/Udm/Udm.vcproj	Wed Feb 27 15:14:48 2013	(r4164)
+++ UDM/trunk/Projects/Win32/VC9/src/Udm/Udm.vcproj	Wed Mar 13 12:16:48 2013	(r4165)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="9.00"
+	Version="9,00"
 	Name="Udm"
 	ProjectGUID="{2B0484D0-D5BB-4238-BBC3-A37A20CDC493}"
 	RootNamespace="Udm"
@@ -75,7 +75,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="UmlD.lib File2CodeD.lib JavaAPIGenD.lib UdmXmiD.lib UdmBaseD.lib UdmDomD.lib UdmUtilD.lib xerces-c_2.lib Xalan-C_1D.lib zlibD.lib"
+				AdditionalDependencies="UmlD.lib File2CodeD.lib JavaAPIGenD.lib PythonAPIGenD.lib UdmXmiD.lib UdmBaseD.lib UdmDomD.lib UdmUtilD.lib xerces-c_2.lib Xalan-C_1D.lib zlibD.lib"
 				OutputFile="$(OutDir)\UdmD.exe"
 				LinkIncremental="1"
 				SuppressStartupBanner="true"
@@ -172,7 +172,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="Uml.lib File2Code.lib JavaAPIGen.lib UdmXmi.lib UdmBase.lib Xalan-C_1.lib UdmDom.lib UdmUtil.lib xerces-c_2.lib zlib.lib"
+				AdditionalDependencies="Uml.lib File2Code.lib JavaAPIGen.lib PythonAPIGen.lib UdmXmi.lib UdmBase.lib Xalan-C_1.lib UdmDom.lib UdmUtil.lib xerces-c_2.lib zlib.lib"
 				OutputFile="$(OutDir)\Udm.exe"
 				LinkIncremental="1"
 				SuppressStartupBanner="true"

Added: UDM/trunk/bin/UdmPython.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ UDM/trunk/bin/UdmPython.py	Wed Mar 13 12:16:48 2013	(r4165)
@@ -0,0 +1,20 @@
+
+
+class UdmPython:
+	def __init__(self, impl):
+		self.impl = impl
+		self.id = impl.id
+		self.name = impl.name
+	def is_lib_root(self):
+		return self.impl.is_lib_root
+	def is_lib_object(self):
+		return self.impl.is_lib_object
+	
+	def __eq__(self, other):
+		return self.impl == other.impl
+	'''	
+	def __str__(self):
+		return self.impl.type.name+"(id="+str(self.id)+", name="+self.name+")"
+	'''
+	
+	
\ No newline at end of file

Added: UDM/trunk/bin/Uml.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ UDM/trunk/bin/Uml.py	Wed Mar 13 12:16:48 2013	(r4165)
@@ -0,0 +1,647 @@
+"""Generated
+"""
+
+import sys
+import Uml
+from UdmPython import *
+
+class GenericRole(UdmPython):
+	"""Generated"""
+	#isNavigable = "isNavigable";
+
+	#name = "name";
+
+	@staticmethod
+	def cast(obj):
+		"""Object cast"""
+		return GenericRole(obj)
+	
+	def type(self):
+		"""returning the type of object (Uml.Class)"""
+		return Uml.Class.cast(self.meta)
+	
+	# Associations 
+
+class CompositionParentRole(UdmPython):
+	"""Generated"""
+	@staticmethod
+	def cast(obj):
+		"""Object cast"""
+		return CompositionParentRole(obj)
+	
+	def type(self):
+		"""returning the type of object (Uml.Class)"""
+		return Uml.Class.cast(self.meta)
+	
+	# Associations 
+
+	"""
+	 Association with role name <code>target</code>.
+	"""
+
+	def settarget(self, a): 
+		"""
+		Sets the other end of the association with role name <code>target</code>.
+		@param a The other end of the association
+		"""
+		pass
+
+	def target(self):
+		""" Returns the other end of the association with role name <code>target</code>.
+		@return The other end of the association
+		"""
+		return Class.cast(self.impl.target)
+	
+class CompositionChildRole(UdmPython):
+	"""Generated"""
+	#max = "max";
+
+	#min = "min";
+
+	@staticmethod
+	def cast(obj):
+		"""Object cast"""
+		return CompositionChildRole(obj)
+	
+	def type(self):
+		"""returning the type of object (Uml.Class)"""
+		return Uml.Class.cast(self.meta)
+	
+	# Associations 
+
+	"""
+	 Association with role name <code>target</code>.
+	"""
+
+	def settarget(self, a): 
+		"""
+		Sets the other end of the association with role name <code>target</code>.
+		@param a The other end of the association
+		"""
+		pass
+
+	def target(self):
+		""" Returns the other end of the association with role name <code>target</code>.
+		@return The other end of the association
+		"""
+		return Class.cast(self.impl.target)
+	
+class AssociationRole(UdmPython):
+	"""Generated"""
+	#max = "max";
+
+	#min = "min";
+
+	#isPrimary = "isPrimary";
+
+	@staticmethod
+	def cast(obj):
+		"""Object cast"""
+		return AssociationRole(obj)
+	
+	def type(self):
+		"""returning the type of object (Uml.Class)"""
+		return Uml.Class.cast(self.meta)
+	
+	# Associations 
+
+	"""
+	 Association with role name <code>target</code>.
+	"""
+
+	def settarget(self, a): 
+		"""
+		Sets the other end of the association with role name <code>target</code>.
+		@param a The other end of the association
+		"""
+		pass
+
+	def target(self):
+		""" Returns the other end of the association with role name <code>target</code>.
+		@return The other end of the association
+		"""
+		return Class.cast(self.impl.target)
+	
+class TaggedValue(UdmPython):
+	"""Generated"""
+	#value = "value";
+
+	#name = "name";
+
+	@staticmethod
+	def cast(obj):
+		"""Object cast"""
+		return TaggedValue(obj)
+	
+	def type(self):
+		"""returning the type of object (Uml.Class)"""
+		return Uml.Class.cast(self.meta)
+	
+	# Associations 
+
+class Class(UdmPython):
+	"""Generated"""
+	#isAbstract = "isAbstract";
+
+	#stereotype = "stereotype";
+
+	#name = "name";
+
+	#from = "from";
+
+	@staticmethod
+	def cast(obj):
+		"""Object cast"""
+		return Class(obj)
+	
+	def type(self):
+		"""returning the type of object (Uml.Class)"""
+		return Uml.Class.cast(self.meta)
+	
+	def getTaggedValueChildren(self):
+		"""
+		Returns all the children of type <code>TaggedValue<code> of this container. 
+		@return  The children in a lisst
+		"""
+		childs = self.impl.children(child_type=TaggedValue.meta)
+		list = []
+		for i in childs:
+			list.append(TaggedValue(i))
+		return list
+
+	def getConstraintChildren(self):
+		"""
+		Returns all the children of type <code>Constraint<code> of this container. 
+		@return  The children in a lisst
+		"""
+		childs = self.impl.children(child_type=Constraint.meta)
+		list = []
+		for i in childs:
+			list.append(Constraint(i))
+		return list
+
+	def getAttributeChildren(self):
+		"""
+		Returns all the children of type <code>Attribute<code> of this container. 
+		@return  The children in a lisst
+		"""
+		childs = self.impl.children(child_type=Attribute.meta)
+		list = []
+		for i in childs:
+			list.append(Attribute(i))
+		return list
+
+	def getConstraintDefinitionChildren(self):
+		"""
+		Returns all the children of type <code>ConstraintDefinition<code> of this container. 
+		@return  The children in a lisst
+		"""
+		childs = self.impl.children(child_type=ConstraintDefinition.meta)
+		list = []
+		for i in childs:
+			list.append(ConstraintDefinition(i))
+		return list
+
+	# Associations 
+
+	"""
+	 Association with role name <code>baseTypes</code>.
+	"""
+
+	def setbaseTypes(self, a): 
+		"""
+		Sets the other ends of the association with role name <code>baseTypes</code>.
+		@param a The other ends of the association
+		"""
+		pass
+
+	def baseTypes(self):
+		"""
+		Returns the other ends of the association with role name <code>baseTypes</code>.
+		@return The other ends of the association
+		""" 
+		list = []
+		for i in self.impl.baseTypes:
+			list.append(Class.cast(i))
+		return list
+	
+
+	"""
+	 Association with role name <code>subTypes</code>.
+	"""
+
+	def setsubTypes(self, a): 
+		"""
+		Sets the other ends of the association with role name <code>subTypes</code>.
+		@param a The other ends of the association
+		"""
+		pass
+
+	def subTypes(self):
+		"""
+		Returns the other ends of the association with role name <code>subTypes</code>.
+		@return The other ends of the association
+		""" 
+		list = []
+		for i in self.impl.subTypes:
+			list.append(Class.cast(i))
+		return list
+	
+
+	"""
+	 Association with role name <code>association</code>.
+	"""
+
+	def setassociation(self, a): 
+		"""
+		Sets the other end of the association with role name <code>association</code>.
+		@param a The other end of the association
+		"""
+		pass
+
+	def association(self):
+		""" Returns the other end of the association with role name <code>association</code>.
+		@return The other end of the association
+		"""
+		return Association.cast(self.impl.association)
+	
+	"""
+	 Association with role name <code>associationRoles</code>.
+	"""
+
+	def setassociationRoles(self, a): 
+		"""
+		Sets the other ends of the association with role name <code>associationRoles</code>.
+		@param a The other ends of the association
+		"""
+		pass
+
+	def associationRoles(self):
+		"""
+		Returns the other ends of the association with role name <code>associationRoles</code>.
+		@return The other ends of the association
+		""" 
+		list = []
+		for i in self.impl.associationRoles:
+			list.append(AssociationRole.cast(i))
+		return list
+	
+
+	"""
+	 Association with role name <code>parentRoles</code>.
+	"""
+
+	def setparentRoles(self, a): 
+		"""
+		Sets the other ends of the association with role name <code>parentRoles</code>.
+		@param a The other ends of the association
+		"""
+		pass
+
+	def parentRoles(self):
+		"""
+		Returns the other ends of the association with role name <code>parentRoles</code>.
+		@return The other ends of the association
+		""" 
+		list = []
+		for i in self.impl.parentRoles:
+			list.append(CompositionParentRole.cast(i))
+		return list
+	
+
+	"""
+	 Association with role name <code>childRoles</code>.
+	"""
+
+	def setchildRoles(self, a): 
+		"""
+		Sets the other ends of the association with role name <code>childRoles</code>.
+		@param a The other ends of the association
+		"""
+		pass
+
+	def childRoles(self):
+		"""
+		Returns the other ends of the association with role name <code>childRoles</code>.
+		@return The other ends of the association
+		""" 
+		list = []
+		for i in self.impl.childRoles:
+			list.append(CompositionChildRole.cast(i))
+		return list
+	
+
+class Constraint(UdmPython):
+	"""Generated"""
+	#description = "description";
+
+	#name = "name";
+
+	#expression = "expression";
+
+	@staticmethod
+	def cast(obj):
+		"""Object cast"""
+		return Constraint(obj)
+	
+	def type(self):
+		"""returning the type of object (Uml.Class)"""
+		return Uml.Class.cast(self.meta)
+	
+	# Associations 
+
+class Attribute(UdmPython):
+	"""Generated"""
+	#name = "name";
+
+	#type = "type";
+
+	#defvalue = "defvalue";
+
+	#min = "min";
+
+	#max = "max";
+
+	#visibility = "visibility";
+
+	#ordered = "ordered";
+
+	#nonpersistent = "nonpersistent";
+
+	#registry = "registry";
+
+	@staticmethod
+	def cast(obj):
+		"""Object cast"""
+		return Attribute(obj)
+	
+	def type(self):
+		"""returning the type of object (Uml.Class)"""
+		return Uml.Class.cast(self.meta)
+	
+	# Associations 
+
+class ConstraintDefinition(UdmPython):
+	"""Generated"""
+	#stereotype = "stereotype";
+
+	#name = "name";
+
+	#parameterList = "parameterList";
+
+	#expression = "expression";
+
+	#returnType = "returnType";
+
+	@staticmethod
+	def cast(obj):
+		"""Object cast"""
+		return ConstraintDefinition(obj)
+	
+	def type(self):
+		"""returning the type of object (Uml.Class)"""
+		return Uml.Class.cast(self.meta)
+	
+	# Associations 
+
+class Association(UdmPython):
+	"""Generated"""
+	#nonpersistent = "nonpersistent";
+
+	#name = "name";
+
+	@staticmethod
+	def cast(obj):
+		"""Object cast"""
+		return Association(obj)
+	
+	def type(self):
+		"""returning the type of object (Uml.Class)"""
+		return Uml.Class.cast(self.meta)
+	
+	def getAssociationRoleChildren(self):
+		"""
+		Returns all the children of type <code>AssociationRole<code> of this container. 
+		@return  The children in a lisst
+		"""
+		childs = self.impl.children(child_type=AssociationRole.meta)
+		list = []
+		for i in childs:
+			list.append(AssociationRole(i))
+		return list
+
+	def getTaggedValueChildren(self):
+		"""
+		Returns all the children of type <code>TaggedValue<code> of this container. 
+		@return  The children in a lisst
+		"""
+		childs = self.impl.children(child_type=TaggedValue.meta)
+		list = []
+		for i in childs:
+			list.append(TaggedValue(i))
+		return list
+
+	# Associations 
+
+	"""
+	 Association with role name <code>assocClass</code>.
+	"""
+
+	def setassocClass(self, a): 
+		"""
+		Sets the other end of the association with role name <code>assocClass</code>.
+		@param a The other end of the association
+		"""
+		pass
+
+	def assocClass(self):
+		""" Returns the other end of the association with role name <code>assocClass</code>.
+		@return The other end of the association
+		"""
+		return Class.cast(self.impl.assocClass)
+	
+class Namespace(UdmPython):
+	"""Generated"""
+	#name = "name";
+
+	@staticmethod
+	def cast(obj):
+		"""Object cast"""
+		return Namespace(obj)
+	
+	def type(self):
+		"""returning the type of object (Uml.Class)"""
+		return Uml.Class.cast(self.meta)
+	
+	def getClassChildren(self):
+		"""
+		Returns all the children of type <code>Class<code> of this container. 
+		@return  The children in a lisst
+		"""
+		childs = self.impl.children(child_type=Class.meta)
+		list = []
+		for i in childs:
+			list.append(Class(i))
+		return list
+
+	def getAssociationChildren(self):
+		"""
+		Returns all the children of type <code>Association<code> of this container. 
+		@return  The children in a lisst
+		"""
+		childs = self.impl.children(child_type=Association.meta)
+		list = []
+		for i in childs:
+			list.append(Association(i))
+		return list
+
+	def getNamespaceChildren(self):
+		"""
+		Returns all the children of type <code>Namespace<code> of this container. 
+		@return  The children in a lisst
+		"""
+		childs = self.impl.children(child_type=Namespace.meta)
+		list = []
+		for i in childs:
+			list.append(Namespace(i))
+		return list
+
+	def getCompositionChildren(self):
+		"""
+		Returns all the children of type <code>Composition<code> of this container. 
+		@return  The children in a lisst
+		"""
+		childs = self.impl.children(child_type=Composition.meta)
+		list = []
+		for i in childs:
+			list.append(Composition(i))
+		return list
+
+	# Associations 
+
+class Composition(UdmPython):
+	"""Generated"""
+	#nonpersistent = "nonpersistent";
+
+	#name = "name";
+
+	@staticmethod
+	def cast(obj):
+		"""Object cast"""
+		return Composition(obj)
+	
+	def type(self):
+		"""returning the type of object (Uml.Class)"""
+		return Uml.Class.cast(self.meta)
+	
+	def getCompositionParentRoleChild(self): 
+		"""
+		Return the child of type <code>CompositionParentRole<code> of this container. 
+		@return  The child
+		"""
+		childs = self.impl.children(child_type=CompositionParentRole.meta)
+		if len(childs) > 0:
+			return CompositionParentRole(childs[0])
+		else: 
+			return None
+	
+	def getCompositionChildRoleChild(self): 
+		"""
+		Return the child of type <code>CompositionChildRole<code> of this container. 
+		@return  The child
+		"""
+		childs = self.impl.children(child_type=CompositionChildRole.meta)
+		if len(childs) > 0:
+			return CompositionChildRole(childs[0])
+		else: 
+			return None
+	
+	# Associations 
+
+class Diagram(UdmPython):
+	"""Generated"""
+	#version = "version";
+
+	#name = "name";
+
+	@staticmethod
+	def cast(obj):
+		"""Object cast"""
+		return Diagram(obj)
+	
+	def type(self):
+		"""returning the type of object (Uml.Class)"""
+		return Uml.Class.cast(self.meta)
+	
+	def getClassChildren(self):
+		"""
+		Returns all the children of type <code>Class<code> of this container. 
+		@return  The children in a lisst
+		"""
+		childs = self.impl.children(child_type=Class.meta)
+		list = []
+		for i in childs:
+			list.append(Class(i))
+		return list
+
+	def getAssociationChildren(self):
+		"""
+		Returns all the children of type <code>Association<code> of this container. 
+		@return  The children in a lisst
+		"""
+		childs = self.impl.children(child_type=Association.meta)
+		list = []
+		for i in childs:
+			list.append(Association(i))
+		return list
+
+	def getNamespaceChildren(self):
+		"""
+		Returns all the children of type <code>Namespace<code> of this container. 
+		@return  The children in a lisst
+		"""
+		childs = self.impl.children(child_type=Namespace.meta)
+		list = []
+		for i in childs:
+			list.append(Namespace(i))
+		return list
+
+	def getCompositionChildren(self):
+		"""
+		Returns all the children of type <code>Composition<code> of this container. 
+		@return  The children in a lisst
+		"""
+		childs = self.impl.children(child_type=Composition.meta)
+		list = []
+		for i in childs:
+			list.append(Composition(i))
+		return list
+
+	# Associations 
+
+
+def init_meta(meta_map):
+	GenericRole.meta = meta_map.GenericRole
+	CompositionParentRole.meta = meta_map.CompositionParentRole
+	CompositionChildRole.meta = meta_map.CompositionChildRole
+	AssociationRole.meta = meta_map.AssociationRole
+	TaggedValue.meta = meta_map.TaggedValue
+	Class.meta = meta_map.Class
+	Constraint.meta = meta_map.Constraint
+	Attribute.meta = meta_map.Attribute
+	ConstraintDefinition.meta = meta_map.ConstraintDefinition
+	Association.meta = meta_map.Association
+	Namespace.meta = meta_map.Namespace
+	Composition.meta = meta_map.Composition
+	Diagram.meta = meta_map.Diagram
+
+
+def initialize(meta_map, uml_meta_map):
+	try:
+		module_initialized
+	except NameError:
+		init_meta(meta_map)
+		module_initialized = True
+		if sys.modules[__name__] != Uml:
+			Uml.initialize(uml_meta_map, uml_meta_map)
+

Added: UDM/trunk/src/Udm/PythonAPIGen/PythonAPIGen.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ UDM/trunk/src/Udm/PythonAPIGen/PythonAPIGen.cpp	Wed Mar 13 12:16:48 2013	(r4165)
@@ -0,0 +1,471 @@
+#include "PythonAPIGen.h"
+
+
+void GeneratePythonClass(const ::Uml::Class &cl, const string & pckg_hierarcy, const string& diagName);
+
+//! Constructor.
+/*!
+  Creates and initializes the Python API generation.
+*/
+PythonAPIGen::PythonAPIGen( const ::Uml::Diagram &diagram
+                       , const map<string, string>& ns_map
+                       , const string& inputfile )
+:   m_diagram( diagram ), m_ns_map( ns_map ), m_inputfile( inputfile )
+{
+}
+
+//! Destructor.
+/*!
+  .
+*/
+PythonAPIGen::~PythonAPIGen ( void )
+{
+}
+//================================================
+
+//! Entry point of Python API generation.
+/*!
+  .
+*/
+void PythonAPIGen::generate()
+{
+  
+  // Generate the Python version of the input UDM XML file
+  //Utils::XML2Python( string( m_diagram.name() ) + "_udm_xml", m_inputfile, m_meta_dir );
+
+ 
+   open();
+	
+	
+
+  /*CREATE MODUL DESCRIPTION*/
+  
+  m_output << "\"\"\"Generated" << endl;
+  //...................................
+  m_output << "\"\"\"" << endl << endl;
+
+  /*CREATE IMPORT*/
+  m_output << "import sys" << endl;
+  m_output << "import Uml" << endl;
+  m_output << "from UdmPython import *" << endl << endl;
+
+
+  /*GENERATE PYTHON CLASSES*/
+  set< ::Uml::Class> uml_classes = m_diagram.classes();
+  for( set< ::Uml::Class>::iterator uc_i = uml_classes.begin(); uc_i != uml_classes.end(); uc_i++ )
+  {
+
+	  ::Uml::Class currCls = *uc_i;
+	  generateClass(currCls);  
+	  
+  }
+
+  /*INITIALIZE THE META STATIC VARIABLES*/
+  
+  m_output << endl;
+  m_output << "def init_meta(meta_map):" << endl;
+  
+  for( set< ::Uml::Class>::iterator uc_i = uml_classes.begin(); uc_i != uml_classes.end(); uc_i++ )
+  {
+	  ::Uml::Class currCls = *uc_i;
+	   set<Uml::Class> bases = currCls .baseTypes();
+	  m_output << "\t" << currCls.name() << ".meta = meta_map." << currCls.name() << endl;
+  }
+
+  m_output << endl << endl;
+
+  /*INITIALIZE THE META STATIC VARIABLE*/
+
+  m_output << "def initialize(meta_map, uml_meta_map):" << endl;
+  m_output << "\t" << "try:" << endl;
+  m_output << "\t\t" << "module_initialized" << endl;
+  m_output << "\t" << "except NameError:" << endl;
+  m_output << "\t\t" << "init_meta(meta_map)" << endl;
+  m_output << "\t\t" << "module_initialized = True" << endl;
+  m_output << "\t\t" << "if sys.modules[__name__] != Uml:" << endl;
+  m_output << "\t\t\t" << "Uml.initialize(uml_meta_map, uml_meta_map)" << endl;
+  m_output << endl;
+	
+
+  
+  // close the file
+  m_output.close();
+
+}
+
+void PythonAPIGen::open()
+{
+	//opening ofstream
+	string fname = string(m_diagram.name());
+	fname+=+".py";
+	m_output.open(fname.c_str());
+
+	if ( !m_output.good() )
+		throw udm_exception( "Error opening for write "+fname );
+}
+
+void PythonAPIGen::generateClass(::Uml::Class &cls)
+{
+	m_output << "class " << cls.name() << "(UdmPython):" << endl;
+	m_output << "\t\"\"\"Generated\"\"\"" << endl;
+
+	generateAttributes(cls);
+	
+	//cast method
+	m_output << "\t at staticmethod" << endl;
+	m_output << "\tdef cast(obj):"<< endl;
+	m_output << "\t\t\"\"\"Object cast\"\"\"" << endl;
+	m_output << "\t\treturn " << cls.name() << "(obj)" << endl;
+	m_output << "\t" << endl;
+
+	//type method
+	m_output << "\tdef type(self):"<< endl;
+	m_output << "\t\t\"\"\"returning the type of object (Uml.Class)\"\"\"" << endl;
+	m_output << "\t\treturn " << "Uml.Class.cast(self.meta)" << endl;
+	m_output << "\t" << endl;
+
+	generateChildrenAccess(cls);
+	generateAssociations(cls);
+}
+
+void PythonAPIGen::generateAttributes(::Uml::Class &cls)
+{
+	
+	set < ::Uml::Attribute> atts = cls.attributes();
+	for ( set< ::Uml::Attribute>::iterator atts_i = atts.begin(); atts_i != atts.end(); atts_i++ )
+	{
+		string att_name = atts_i->name();
+
+		// name of the attribute
+		m_output << "\t#" << att_name << " = \"" << att_name << "\";" << endl;
+		m_output << endl;
+	}
+}
+
+void PythonAPIGen::generateChildrenAccess(::Uml::Class &cls)
+{
+  //childrens ---------------------------------------------------
+  set<Uml::Class> allContainedClasses;
+
+  // set of contained classes
+  set< ::Uml::Class> conts = Uml::ContainedClasses( cls );
+  for ( set< ::Uml::Class>::iterator c_i = conts.begin(); c_i != conts.end(); c_i++ )
+  {
+	// the descendants of the contained class
+	set < ::Uml::Class> conts_der = Uml::DescendantClasses( *c_i );
+	std::copy(conts_der.begin(), conts_der.end(), std::inserter(allContainedClasses, allContainedClasses.begin()));
+  }
+
+  {
+	for ( set< ::Uml::Class>::iterator c_d_i = allContainedClasses.begin(); c_d_i != allContainedClasses.end(); c_d_i++ )
+	{
+	  if ( c_d_i->isAbstract() )
+		continue; 
+
+	  ::Uml::Composition comp = Uml::matchChildToParent( *c_d_i, cls );
+	  string c_i_name = (*c_d_i).name();
+	  string pkg_name = "";
+
+	  // without child role
+	  if ( comp )
+	  {
+		::Uml::CompositionChildRole ccr = comp.childRole();
+		string ccr_name = ccr.name();
+
+		if ( (ccr.max() == -1) || (ccr.max() > 1) )
+		{
+		  m_output << "\tdef " << "get" << c_i_name << "Children(self):" << endl;
+		  m_output << "\t\t\"\"\"" << endl;
+		  m_output << "\t\tReturns all the children of type <code>" << c_i_name << "<code> of this container. " << endl;
+		  m_output << "\t\t at return  The children in a lisst" << endl;
+		  m_output << "\t\t\"\"\"" << endl;
+
+		  m_output << "\t\tchilds = self.impl.children(child_type=" << c_i_name << ".meta)" << endl;
+		  m_output << "\t\tlist = []" << endl;
+		  m_output << "\t\t" << "for i in childs:" << endl;
+		  m_output << "\t\t\t" << "list.append(" << c_i_name << "(i))" << endl;
+		  m_output << "\t\treturn list" << endl;
+		  m_output << endl;
+		  
+		}
+		else
+		{
+		  m_output << "\tdef " << "get" << c_i_name << "Child(self): " << endl;
+		  m_output << "\t\t\"\"\"" << endl;
+		  m_output << "\t\tReturn the child of type <code>" << c_i_name << "<code> of this container. " << endl;
+		  m_output << "\t\t at return  The child" << endl;
+		  m_output << "\t\t\"\"\"" << endl;
+		  m_output << "\t\tchilds = self.impl.children(child_type=" << c_i_name << ".meta)" << endl;
+		  m_output << "\t\t" << "if len(childs) > 0:" << endl;
+		  m_output << "\t\t\t" << "return " << c_i_name << "(childs[0])" << endl;
+		  m_output << "\t\t" << "else: " << endl;
+		  m_output << "\t\t\t" << "return None" << endl;
+		  m_output << "\t" << endl;
+		
+		  /*
+		  if ( strcmp(ccr_name.c_str(), "") == 0 )
+		  {
+			m_output << "\t\t'''UdmPseudoObjectContainer container = getChildren(null, " ;
+			m_output << pkg_name << c_i_name << ".META_TYPE, " << pkg_name << c_i_name << ".META_TYPE_NS); " << endl;
+		  }
+		  else
+		  {
+			m_output << "\t\tUdmPseudoObjectContainer container = getChildren(\"" << ccr_name << "\",";
+			m_output << pkg_name << c_i_name << ".META_TYPE, " << pkg_name << c_i_name << ".META_TYPE_NS); " << endl;
+		  }
+		  */
+		  
+		  //m_output << "\t\tif (container.getLength() > 0)" << endl << endl;
+		  //m_output << "\t\t\treturn (" << pkg_name << c_i_name << ")" << pkg_name << "Utils.wrapWithSubclass(container.getAt(0), metaDiagram);" << endl;
+		  //m_output << "\t\treturn null;'''" << endl << endl;
+		  //m_output << "\t" << endl << endl;
+		}
+	  }
+	  // with child role
+	  else
+	  {
+		//generate a common getter function for these types of children
+		/*
+		m_output << "\t'''" << endl;
+		m_output << "\t * Returns all the children of type <code>" << c_i_name << "<code> of this container. " << endl;
+		m_output << "\t * @return  The children in a list" << endl;
+		m_output << "\t ''' " << endl;
+		
+		m_output << "\tdef " << "get" << c_i_name << "Children(self):" << endl;
+		m_output << "\t" << endl;
+		m_output << "\t\t'''UdmPseudoObjectContainer container = getChildren(null," ;
+		m_output << pkg_name << c_i_name << ".META_TYPE, " << pkg_name << c_i_name << ".META_TYPE_NS);" << endl;
+		m_output << "\t\t" << pkg_name << c_i_name << "[] array = new " << pkg_name << c_i_name << "[container.getLength()];" << endl;
+		m_output << "\t\tfor (int i = 0; i < container.getLength(); i++) " << endl;
+		m_output << "\t\t{" << endl;
+		m_output << "\t\t\tarray[i] = (" << pkg_name << c_i_name << ")" << pkg_name << "Utils.wrapWithSubclass(container.getAt(i), metaDiagram);" << endl;
+		m_output << "\t\t}" << endl;
+		m_output << "\t\treturn array;'''" << endl;
+		m_output << "\t" << endl;
+		*/
+		//end of common getter function generation
+
+		set < ::Uml::CompositionChildRole> ccrs = ::Uml::CompositionPeerChildRoles( cls );
+		for ( set< ::Uml::CompositionChildRole>::iterator ccrs_i = ccrs.begin(); ccrs_i != ccrs.end(); ccrs_i++ )
+		{
+		  ::Uml::Class parent = Uml::theOther(*ccrs_i).target();
+		  ::Uml::Class child = ccrs_i->target();
+		  string child_name = string(child.name());
+		  
+		  ::Uml::Composition comp = Uml::matchChildToParent( child, parent );
+
+		  if ( !comp )
+		  {
+			//will reach here only if more than one composition is possible
+
+			//string child role name
+			string ccr_name = ccrs_i->name();
+			m_output << "\t'''" << endl;
+			m_output << "\t *  Composition role name <code>" << ccr_name << "</code>." << endl;
+			m_output << "\t '''" << endl;
+			
+			m_output << endl << endl;
+
+			//getRoleName
+			if ( (ccrs_i->max() == -1) || (ccrs_i->max() > 1) )
+			{
+			  m_output << "\t'''" << endl;
+			  m_output << "\t * Returns the children <code>" << child_name << "<code> of this container. " << endl;
+			  m_output << "\t * which have role <code>" << ccr_name << "<code>." << endl;
+			  m_output << "\t * @return  The children in an array" << endl;
+			  m_output << "\t ''' " << endl;
+			  
+			  m_output << "\tdef " << "get" << ccr_name << "Children(self):" << endl;
+			  
+			  m_output << "\t" << endl;
+			  m_output << "\t\t'''UdmPseudoObjectContainer container = getChildren(";
+			  
+			  m_output << "\t\t" << pkg_name << child_name << "[] array = new " << pkg_name << child_name << "[container.getLength()];" << endl;
+			  m_output << "\t\tfor (int i = 0; i < container.getLength(); i++) " << endl;
+			  m_output << "\t\t{" << endl;
+			  m_output << "\t\t\tarray[i] = (" << pkg_name << child_name << ")" << pkg_name << "Utils.wrapWithSubclass(container.getAt(i), metaDiagram);" << endl;
+			  m_output << "\t\t}" << endl;
+			  m_output << "\t\treturn array;'''" << endl;
+			  m_output << "\t" << endl;
+			}
+			else
+			{
+			  /*
+			  m_output << "\t'''" << endl;
+			  m_output << "\t * Returns the child <code>" << child_name << "<code> of this container. " << endl;
+			  m_output << "\t * which has role <code>" << ccr_name << "<code>." << endl;
+			  m_output << "\t * @return  The children in a list" << endl;
+			  m_output << "\t ''' " << endl;
+			  
+			  m_output << "\tdef " << " get" << ccr_name << "Child(self):" << endl;
+			  m_output << "\t" << endl;
+			  m_output << "\t\t'''UdmPseudoObjectContainer container = getChildren(" ;
+			  //m_output << Utils::getCCRString(*ccrs_i) << "," << pkg_name << child_name << ".META_TYPE, " << pkg_name << child_name << ".META_TYPE_NS);" << endl;
+			  m_output << "\t\tif (container.getLength() > 0)" << endl << endl;
+			  m_output << "\t\t\t return (" << pkg_name << child_name << ")" << pkg_name << "Utils.wrapWithSubclass(container.getAt(0), metaDiagram);" << endl;
+			  m_output << "\t\treturn null;'''" << endl << endl;
+			  m_output << "\t" << endl;
+			  */
+			}
+		  } 
+		} 
+	  }
+	}
+  }
+  //childrens end ----------------------------------------------------------------
+}
+
+void PythonAPIGen::generateAssociations(::Uml::Class &cls)
+{
+
+  m_output << "\t# Associations " << endl << endl;
+
+  // association classes
+  ::Uml::Association ass = Uml::GetAncestorAssociation( cls );
+
+  if ( ass )
+  {
+	// set of association roles
+	set < ::Uml::AssociationRole> ass_roles = ass.roles();
+	for( set< ::Uml::AssociationRole>::iterator a_r_i = ass_roles.begin(); a_r_i != ass_roles.end(); a_r_i++ )
+	{
+	  ::Uml::Class target_cl = a_r_i->target();
+
+	  string tname = target_cl.name();
+	  string ar_name = a_r_i->name();
+
+	  string pkg_name = "";//Utils::getPackageSignature(target_cl, m_ns_path, m_package_name);
+
+	  m_output << "\t\"\"\"" << endl;
+	  m_output << "\t Association with role name <code>" << ar_name << "</code>." << endl;
+	  m_output << "\t\"\"\"" << endl;
+
+	  // setter for the association
+	  
+	  //tname 
+	  m_output << "\tdef set" << ar_name << "(self, a):" << endl;
+	  m_output << "\t\t\"\"\"" << endl;
+	  m_output << "\t\tSets the end of the association with role name <code>" << ar_name << "</code>." << endl;
+	  m_output << "\t\t at param a The end of the association'''" << endl;
+	  m_output << "\t\t\"\"\"" << endl;
+	  
+	  //m_output << "\t\t#UdmPseudoObjectContainer container = new UdmPseudoObjectContainer(1);" << endl;
+	  //m_output << "\t\t#container.setAt(0, (UdmPseudoObject)a);" << endl;
+	  //m_output << "\t\t#setAssociation(\"" << ar_name << "\", container, UdmHelper.TARGET_FROM_CLASS);" << endl;
+	  m_output << "\t\tpass" << endl;
+
+	  
+	  // getter for the association
+	  m_output << "\tdef " << "get" << ar_name << "(self):" << endl;
+	  m_output << "\t\t\"\"\"" << endl;
+	  m_output << "\t\tReturns the end of the association with role name <code>" << ar_name << "</code>." << endl;
+	  m_output << "\t\t at return The end of the association" << endl;
+	  m_output << "\t\t\"\"\"" << endl;
+	  m_output << "\t\treturn " << tname << ".cast(self.impl.ar_name)" << endl;
+	  //m_ioutput << "\tpublic " << pkg_name << tname << " get" << ar_name << "() throws UdmException;" << endl;
+	  //m_output << "\t\tUdmPseudoObjectContainer container = getAssociation(\"" << ar_name << "\", UdmHelper.TARGET_FROM_CLASS);" << endl;
+	  //m_output << "\t\tif (container.getLength() > 0)" << endl << endl;
+	  //m_output << "\t\t\treturn (" << pkg_name << tname << ") " << pkg_name << "Utils.wrapWithSubclass(container.getAt(0), metaDiagram);" << endl;
+	  //m_output << "\t\treturn null;" << endl << endl;
+	  //m_output << "\t}" << endl;
+	  m_output << "\t" << endl;
+	} 
+  }
+
+	// associations
+  // set of associations
+  set < ::Uml::AssociationRole> assroles = cls.associationRoles();
+
+  if ( assroles.size() )
+	{
+	for( set< ::Uml::AssociationRole>::iterator ar_i = assroles.begin(); ar_i != assroles.end(); ar_i++ )
+	{
+	  string asr_name = ar_i->name();
+	  string to_asr_name = (string)Uml::theOther(*ar_i).name();
+
+	  ::Uml::Class to_class = (::Uml::Class)((Uml::theOther(*ar_i)).target());
+	  string helper_mode = "TARGET_FROM_PEER";
+	  ::Uml::Association ass = ar_i->parent();
+	  ::Uml::Class ass_class = ass.assocClass();
+
+	  if ( ass_class )
+	  {
+		  to_class = ass_class;
+		  helper_mode = "CLASS_FROM_TARGET";
+	  }
+
+	  string tname = to_class.name();
+
+	  m_output << "\t\"\"\"" << endl;
+	  m_output << "\t Association with role name <code>" << to_asr_name << "</code>." << endl;
+	  m_output << "\t\"\"\"" << endl;
+	  m_output << endl;
+
+	  // the canonical form of the to_class
+	  string pckg_signature = "";//Utils::getPackageSignature(to_class, m_ns_path, m_package_name);
+
+	  if ( (Uml::theOther(*ar_i).max() == 0) || (Uml::theOther(*ar_i).max() == 1) )
+	  {
+		//single cardinality
+		//method signature
+		m_output << "\tdef " << "set" << to_asr_name << "(self," << " a): " << endl;//<< tname 
+		
+		//doc comment
+		m_output << "\t\t\"\"\"" << endl;
+		m_output << "\t\tSets the other end of the association with role name <code>" << to_asr_name << "</code>." << endl;
+		m_output << "\t\t at param a The other end of the association" << endl;
+		m_output << "\t\t\"\"\"" << endl;
+
+		
+		//m_output << "\t\t'''setAssociation(\"" << to_asr_name << "\", a, UdmHelper." << helper_mode << ");" << endl;
+		m_output << "\t\tpass" << endl;
+		m_output << endl;
+		
+		m_output << "\tdef " << to_asr_name << "(self):" << endl;
+
+		m_output << "\t\t\"\"\" Returns the other end of the association with role name <code>" << to_asr_name << "</code>." << endl;
+		m_output << "\t\t at return The other end of the association" << endl;
+		m_output << "\t\t\"\"\"" << endl;
+		//m_ioutput << "\tpublic " << pckg_signature << tname << " get" << to_asr_name << "() throws UdmException;" << endl;
+		m_output << "\t\treturn " << tname << ".cast(self.impl." << to_asr_name << ")" << endl;
+		/*
+		if (isInterfaceNeeded(to_class)) {
+			m_output << "\t\treturn (result == null) ? null : (" << pckg_signature << tname << ")Utils.wrapWithSubclass(new UdmPseudoObject(result, getDiagram()), getDiagram());" << endl;
+		} else {
+			m_output << "\t\treturn (result == null) ? null : new " << pckg_signature << tname << "(result, getDiagram());" << endl;
+		}
+		*/
+		m_output << "\t" << endl;
+		
+	  }
+	  else
+	  {
+		
+		m_output << "\tdef set" << to_asr_name << "(self," << " a): " << endl; //tname []<<
+		m_output << "\t\t\"\"\"" << endl;
+		m_output << "\t\tSets the other ends of the association with role name <code>" << to_asr_name << "</code>." << endl;
+		m_output << "\t\t at param a The other ends of the association" << endl;
+		m_output << "\t\t\"\"\"" << endl;
+		
+		//m_output << "\t\t#setAssociation(\"" << to_asr_name << "\", new UdmPseudoObjectContainer(a), UdmHelper." << helper_mode << ");" << endl;
+		m_output << "\t\tpass" << endl;
+		m_output << endl;
+
+		
+		m_output << "\tdef " << to_asr_name << "(self):" << endl;
+		m_output << "\t\t\"\"\"" << endl;
+		m_output << "\t\tReturns the other ends of the association with role name <code>" << to_asr_name << "</code>." << endl;
+		m_output << "\t\t at return The other ends of the association" << endl;
+		m_output << "\t\t\"\"\" " << endl;
+		//m_ioutput << "\tpublic " << pckg_signature << tname << "[] get" << to_asr_name << "() throws UdmException;" << endl;
+		m_output << "\t\t" << "list = []" << endl;
+		m_output << "\t\t" << "for i in self.impl." << to_asr_name << ":" << endl;
+		m_output << "\t\t\t" << "list.append(" << tname << ".cast(i))" << endl;			 
+		m_output << "\t\t" << "return list" << endl;
+		m_output << "\t" << endl;
+		m_output << endl;
+	  }
+	} 
+  }
+  
+}

Added: UDM/trunk/src/Udm/PythonAPIGen/PythonAPIGen.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ UDM/trunk/src/Udm/PythonAPIGen/PythonAPIGen.h	Wed Mar 13 12:16:48 2013	(r4165)
@@ -0,0 +1,46 @@
+#ifndef PythonAPIGen_H
+#define PythonAPIGen_H
+
+#include <Uml.h>
+#include <UmlExt.h>
+#include <fstream>
+
+using namespace std;
+
+class PythonAPIGen
+{
+  public:
+    //! Constructor.
+    PythonAPIGen( const ::Uml::Diagram &diagram
+      , const map<string, string>& ns_map
+      , const string& inputfile );
+
+    //! Destructor.
+    ~PythonAPIGen( void );
+    
+    //! Entry point of Python API generation.
+    void  generate( );
+
+  private:  
+    void open();
+	void generateClass(::Uml::Class &cls);
+	void generateAttributes(::Uml::Class &cls);
+	void generateChildrenAccess(::Uml::Class &cls);
+	void generateAssociations(::Uml::Class &cls);
+
+  private:
+    //! The UDM UML diagram.
+    const ::Uml::Diagram & m_diagram;
+
+    //! Namespace directory.
+    const map<string, string>& m_ns_map;
+
+    //! The input UDM XML file.
+    const string & m_inputfile;
+
+    ofstream m_output;
+
+
+
+};
+#endif //PythonAPIGen_H

Modified: UDM/trunk/src/Udm/Udm.cpp
==============================================================================
--- UDM/trunk/src/Udm/Udm.cpp	Wed Feb 27 15:14:48 2013	(r4164)
+++ UDM/trunk/src/Udm/Udm.cpp	Wed Mar 13 12:16:48 2013	(r4165)
@@ -19,6 +19,7 @@
 #include <fstream>
 
 #include "./JavaAPIGen/JavaAPIGen.h"
+#include "./PythonAPIGen/PythonAPIGen.h"
 
 #ifdef _WIN32
 #if defined(_M_AMD64)
@@ -114,6 +115,12 @@
 					opts.mode = UdmOpts::JAVA;
 					continue;
 				}
+				//Python API generation
+				else if (c == 'p')
+				{
+					opts.mode = UdmOpts::PYTHON;
+					continue;
+				}
 				else if (c == 's')
 				{
 					opts.mode = UdmOpts::C_SHARP;
@@ -438,6 +445,13 @@
 			return 0;
 		}
 
+		if (opts.mode == UdmOpts::PYTHON)
+		{
+			PythonAPIGen gen(diagram, opts.ns_map, inputfile);
+			gen.generate();
+			return 0;
+		}
+
 		if (opts.mode == UdmOpts::C_SHARP) {
 			ofstream ff;
 			ff.open( (opts.out_dir + fname + ".cs").c_str());

Modified: UDM/trunk/src/Udm/Udm.h
==============================================================================
--- UDM/trunk/src/Udm/Udm.h	Wed Feb 27 15:14:48 2013	(r4164)
+++ UDM/trunk/src/Udm/Udm.h	Wed Mar 13 12:16:48 2013	(r4165)
@@ -28,7 +28,8 @@
 		CXX_DEFAULT,		// C++
 		CXX_GENERIC,		// C++ with support for generic programming
 		C_SHARP,
-		JAVA
+		JAVA,
+		PYTHON
 	} mode;
 
 	enum MetaInitType {


More information about the Mobies-commit mailing list