]> SALOME platform Git repositories - tools/yacsgen.git/commitdiff
Salome HOME
Merge from V5_1_5_BR branch 12/11/2010
authorvsr <vsr@opencascade.com>
Fri, 12 Nov 2010 15:20:11 +0000 (15:20 +0000)
committervsr <vsr@opencascade.com>
Fri, 12 Nov 2010 15:20:11 +0000 (15:20 +0000)
26 files changed:
Examples/ast2/coupling.xml
Examples/ast2/myaster/src/op0189.f
Examples/cpp1/coupling.xml
Examples/cppgui1/components.py
Examples/cppgui1/cppcomposGUI.cxx
Examples/cppgui1/cppcomposGUI.h
Examples/cppgui1/myinterface.idl [new file with mode: 0644]
Examples/fort1/coupling.xml
Examples/pygui1/components.py
Examples/pygui1/myinterface.idl [new file with mode: 0644]
Examples/pygui1/pycomposGUI.py
Examples/pygui1/using.rst
Examples/pyth1/coupling.xml
module_generator/__init__.py
module_generator/astcompo.py
module_generator/aster_tmpl.py
module_generator/cata_tmpl.py
module_generator/cpp_tmpl.py
module_generator/cppcompo.py
module_generator/fcompo.py
module_generator/gener.py
module_generator/gui_tmpl.py
module_generator/pycompo.py
module_generator/pyth_tmpl.py
module_generator/yacstypes.py
setup.py

index 3625fc7800a90f274976ad8898bd45aa5bf696b9..0a541cbef7d598caf00d401364d7621e7dfbd4b9 100644 (file)
-<proc>
-
-<container name="A">
-</container>
-
-<container name="B">
-</container>
-
-<datanode name="datain">
-  <parameter name="f1" type="double">
-    <value><double>23</double> </value>
-  </parameter>
-</datanode>
-
-<service name="node1" >
-  <component>caster</component>
-  <method>s1</method>
-  <load container="A"/>
-  <inport name="jdc" type="file"/>
-  <inport name="a" type="double"/>
-  <inport name="b" type="int"/>
-  <inport name="c" type="string"/>
-  <outport name="fort:8" type="file"/>
-  <outport name="d" type="double"/>
-  <instream name="aa" type="CALCIUM_double"/>
-  <instream name="ab" type="CALCIUM_double"/>
-  <instream name="ac" type="CALCIUM_integer"/>
-  <instream name="ad" type="CALCIUM_real"/>
-  <instream name="ae" type="CALCIUM_string"/>
-  <instream name="af" type="CALCIUM_complex"/>
-  <instream name="ag" type="CALCIUM_logical"/>
-  <outstream name="ba" type="CALCIUM_double"/>
-  <outstream name="bb" type="CALCIUM_double"/>
-</service>
-
-<service name="node2" >
-  <component>cfort</component>
-  <method>s1</method>
-  <load container="B"/>
-  <inport name="a" type="double"/>
-  <inport name="b" type="int"/>
-  <inport name="c" type="string"/>
-  <outport name="d" type="double"/>
-  <outport name="e" type="int"/>
-  <outport name="f" type="string"/>
-  <instream name="a" type="CALCIUM_double"/>
-  <instream name="b" type="CALCIUM_double"/>
-  <outstream name="ba" type="CALCIUM_double"/>
-  <outstream name="bb" type="CALCIUM_double"/>
-  <outstream name="bc" type="CALCIUM_integer"/>
-  <outstream name="bd" type="CALCIUM_real"/>
-  <outstream name="be" type="CALCIUM_string"/>
-  <outstream name="bf" type="CALCIUM_complex"/>
-  <outstream name="bg" type="CALCIUM_logical"/>
-</service>
-
-<inline name="node98" >
-  <script>
-    <code>print "dans python node:",p1</code>
-  </script>
-  <inport name="p1" type="double"/>
-</inline>
-
-<outnode name="dataout" >
-  <parameter name="f1" type="file" ref="monfichier"/>
-</outnode>
-
-<!--datalinks -->
-<stream>
-<fromnode>node1</fromnode><fromport>ba</fromport>
-<tonode>node2</tonode><toport>a</toport>
-</stream>
-<stream>
-<fromnode>node1</fromnode><fromport>bb</fromport>
-<tonode>node2</tonode><toport>b</toport>
-</stream>
-<stream>
-<fromnode>node2</fromnode><fromport>ba</fromport>
-<tonode>node1</tonode><toport>aa</toport>
-</stream>
-<stream>
-<fromnode>node2</fromnode><fromport>bb</fromport>
-<tonode>node1</tonode><toport>ab</toport>
-</stream>
-<stream>
-<fromnode>node2</fromnode><fromport>bc</fromport>
-<tonode>node1</tonode><toport>ac</toport>
-</stream>
-<stream>
-<fromnode>node2</fromnode><fromport>bd</fromport>
-<tonode>node1</tonode><toport>ad</toport>
-</stream>
-<stream>
-<fromnode>node2</fromnode><fromport>be</fromport>
-<tonode>node1</tonode><toport>ae</toport>
-</stream>
-<stream>
-<fromnode>node2</fromnode><fromport>bf</fromport>
-<tonode>node1</tonode><toport>af</toport>
-</stream>
-<stream>
-<fromnode>node2</fromnode><fromport>bg</fromport>
-<tonode>node1</tonode><toport>ag</toport>
-</stream>
-
-<datalink>
-   <fromnode>node1</fromnode><fromport>fort:8</fromport>
-   <tonode>dataout</tonode> <toport>f1</toport>
-</datalink>
-<datalink>
-   <fromnode>node1</fromnode><fromport>d</fromport>
-   <tonode>node98</tonode> <toport>p1</toport>
-</datalink>
-<datalink>
-   <fromnode>datain</fromnode><fromport>f1</fromport>
-   <tonode>node2</tonode> <toport>a</toport>
-</datalink>
-
-<parameter>
-  <tonode>node1</tonode> <toport>a</toport>
-  <value><double>23</double> </value>
-</parameter>
-<parameter>
-  <tonode>node1</tonode> <toport>b</toport>
-  <value><int>23</int> </value>
-</parameter>
-<parameter>
-  <tonode>node1</tonode> <toport>c</toport>
-  <value><string>hello</string> </value>
-</parameter>
-
-<parameter>
-  <tonode>node2</tonode> <toport>b</toport>
-  <value><int>23</int> </value>
-</parameter>
-<parameter>
-  <tonode>node2</tonode> <toport>c</toport>
-  <value><string>hello</string> </value>
-</parameter>
-
-<parameter>
-  <tonode>node1</tonode> <toport>jdc</toport>
-  <value><objref>f.comm</objref></value>
-</parameter>
-
+<?xml version='1.0' encoding='iso-8859-1' ?>
+<proc name="proc">
+   <property name="DefaultStudyID" value="1"/>
+   <objref name="CALCIUM_complex" id="IDL:Ports/Calcium_Ports/Calcium_Complex_Port:1.0"/>
+   <objref name="CALCIUM_double" id="IDL:Ports/Calcium_Ports/Calcium_Double_Port:1.0"/>
+   <objref name="CALCIUM_integer" id="IDL:Ports/Calcium_Ports/Calcium_Integer_Port:1.0"/>
+   <objref name="CALCIUM_logical" id="IDL:Ports/Calcium_Ports/Calcium_Logical_Port:1.0"/>
+   <objref name="CALCIUM_real" id="IDL:Ports/Calcium_Ports/Calcium_Real_Port:1.0"/>
+   <objref name="CALCIUM_string" id="IDL:Ports/Calcium_Ports/Calcium_String_Port:1.0"/>
+   <type name="string" kind="string"/>
+   <struct name="Engines/dataref">
+      <member name="ref" type="string"/>
+   </struct>
+   <type name="bool" kind="bool"/>
+   <sequence name="boolvec" content="bool"/>
+   <type name="double" kind="double"/>
+   <sequence name="dblevec" content="double"/>
+   <objref name="file" id="file"/>
+   <type name="int" kind="int"/>
+   <sequence name="intvec" content="int"/>
+   <objref name="pyobj" id="python:obj:1.0"/>
+   <sequence name="stringvec" content="string"/>
+   <container name="A">
+   </container>
+   <container name="B">
+   </container>
+   <container name="DefaultContainer">
+      <property name="container_name" value="FactoryServer"/>
+      <property name="name" value="localhost"/>
+   </container>
+   <datanode name="datain">
+      <parameter name="f1" type="double">
+         <value><double>23</double></value>
+      </parameter>
+   </datanode>
+   <service name="node1">
+      <component>caster</component>
+      <load container="A"/>
+      <method>s1</method>
+      <inport name="jdc" type="file"/>
+      <inport name="a" type="double"/>
+      <inport name="b" type="int"/>
+      <inport name="c" type="string"/>
+      <instream name="aa" type="CALCIUM_double"/>
+      <instream name="ab" type="CALCIUM_double"/>
+      <instream name="ac" type="CALCIUM_integer"/>
+      <instream name="ad" type="CALCIUM_real"/>
+      <instream name="ae" type="CALCIUM_string"/>
+      <instream name="af" type="CALCIUM_complex"/>
+      <instream name="ag" type="CALCIUM_logical"/>
+      <outport name="fort:8" type="file"/>
+      <outport name="d" type="double"/>
+      <outstream name="ba" type="CALCIUM_double"/>
+      <outstream name="bb" type="CALCIUM_double"/>
+   </service>
+   <service name="node2">
+      <component>cfort</component>
+      <load container="B"/>
+      <method>s1</method>
+      <inport name="a" type="double"/>
+      <inport name="b" type="int"/>
+      <inport name="c" type="string"/>
+      <instream name="a" type="CALCIUM_double"/>
+      <instream name="b" type="CALCIUM_double"/>
+      <outport name="d" type="double"/>
+      <outport name="e" type="int"/>
+      <outport name="f" type="string"/>
+      <outstream name="ba" type="CALCIUM_double"/>
+      <outstream name="bb" type="CALCIUM_double"/>
+      <outstream name="bc" type="CALCIUM_integer"/>
+      <outstream name="bd" type="CALCIUM_real"/>
+      <outstream name="be" type="CALCIUM_string"/>
+      <outstream name="bf" type="CALCIUM_complex"/>
+      <outstream name="bg" type="CALCIUM_logical"/>
+   </service>
+   <inline name="node98">
+      <script><code><![CDATA[print "dans python node:",p1]]></code></script>
+      <inport name="p1" type="double"/>
+   </inline>
+   <outnode name="dataout">
+      <parameter name="f1" type="file"/>
+   </outnode>
+   <control> <fromnode>datain</fromnode> <tonode>node2</tonode> </control>
+   <control> <fromnode>node1</fromnode> <tonode>node98</tonode> </control>
+   <control> <fromnode>node1</fromnode> <tonode>dataout</tonode> </control>
+   <datalink control="false">
+      <fromnode>datain</fromnode> <fromport>f1</fromport>
+      <tonode>node2</tonode> <toport>a</toport>
+   </datalink>
+   <datalink control="false">
+      <fromnode>node1</fromnode> <fromport>fort:8</fromport>
+      <tonode>dataout</tonode> <toport>f1</toport>
+   </datalink>
+   <datalink control="false">
+      <fromnode>node1</fromnode> <fromport>d</fromport>
+      <tonode>node98</tonode> <toport>p1</toport>
+   </datalink>
+   <stream>
+      <fromnode>node1</fromnode> <fromport>ba</fromport>
+      <tonode>node2</tonode> <toport>a</toport>
+   </stream>
+   <stream>
+      <fromnode>node1</fromnode> <fromport>bb</fromport>
+      <tonode>node2</tonode> <toport>b</toport>
+   </stream>
+   <stream>
+      <fromnode>node2</fromnode> <fromport>ba</fromport>
+      <tonode>node1</tonode> <toport>aa</toport>
+   </stream>
+   <stream>
+      <fromnode>node2</fromnode> <fromport>bb</fromport>
+      <tonode>node1</tonode> <toport>ab</toport>
+   </stream>
+   <stream>
+      <fromnode>node2</fromnode> <fromport>bc</fromport>
+      <tonode>node1</tonode> <toport>ac</toport>
+   </stream>
+   <stream>
+      <fromnode>node2</fromnode> <fromport>bd</fromport>
+      <tonode>node1</tonode> <toport>ad</toport>
+   </stream>
+   <stream>
+      <fromnode>node2</fromnode> <fromport>be</fromport>
+      <tonode>node1</tonode> <toport>ae</toport>
+   </stream>
+   <stream>
+      <fromnode>node2</fromnode> <fromport>bf</fromport>
+      <tonode>node1</tonode> <toport>af</toport>
+   </stream>
+   <stream>
+      <fromnode>node2</fromnode> <fromport>bg</fromport>
+      <tonode>node1</tonode> <toport>ag</toport>
+   </stream>
+   <parameter>
+      <tonode>node1</tonode><toport>jdc</toport>
+      <value><objref>f.comm</objref></value>
+   </parameter>
+   <parameter>
+      <tonode>node1</tonode><toport>a</toport>
+      <value><double>23</double></value>
+   </parameter>
+   <parameter>
+      <tonode>node1</tonode><toport>b</toport>
+      <value><int>23</int></value>
+   </parameter>
+   <parameter>
+      <tonode>node1</tonode><toport>c</toport>
+      <value><string>hello</string></value>
+   </parameter>
+   <parameter>
+      <tonode>node2</tonode><toport>b</toport>
+      <value><int>23</int></value>
+   </parameter>
+   <parameter>
+      <tonode>node2</tonode><toport>c</toport>
+      <value><string>hello</string></value>
+   </parameter>
+   <presentation name="datain" x="1.75" y="168.25" width="158" height="63" expanded="1" expx="1.75" expy="168.25" expWidth="158" expHeight="63" shownState="0"/>
+   <presentation name="node1" x="389.75" y="33.25" width="158" height="333" expanded="1" expx="389.75" expy="33.25" expWidth="158" expHeight="333" shownState="0"/>
+   <presentation name="node2" x="195.75" y="46.75" width="158" height="306" expanded="1" expx="195.75" expy="46.75" expWidth="158" expHeight="306" shownState="0"/>
+   <presentation name="node98" x="583.75" y="208.25" width="158" height="63" expanded="1" expx="583.75" expy="208.25" expWidth="158" expHeight="63" shownState="0"/>
+   <presentation name="dataout" x="583.75" y="128.25" width="158" height="63" expanded="1" expx="583.75" expy="128.25" expWidth="158" expHeight="63" shownState="0"/>
+   <presentation name="__ROOT__" x="0" y="0" width="745.75" height="370.25" expanded="1" expx="0" expy="0" expWidth="745.75" expHeight="370.25" shownState="0"/>
 </proc>
-
index 9c669bd1d6823dc6957e5b0c4df06ddd7bce68ee..79bc96fb084624ac468ee725ed2e3b800f4bce08 100644 (file)
@@ -62,9 +62,9 @@ C
       COMMON/YACS/IFL
       include 'calcium.hf'
       real*8 tt,tp,t0,t1,ss,zz
-      real yr
+      real*4 yr
       CHARACTER*8 tch(2)
-      real tcp(2)
+      real*4 tcp(2)
       integer*4 tlo(3)
 
       write(6,*) '--> OP196 '
index 07b3a2671d3dbcbe8b81aa4a120c2208c62d6a3c..bf6dbfc769e84b11267a6c2cf02c08952d04e152 100644 (file)
@@ -1,63 +1,73 @@
-
-<proc>
-
-<!-- types -->
-
-
-<container name="A">
-</container>
-
-<container name="B">
-</container>
-
-<service name="node1" >
-  <component>compo1</component>
-  <method>s1</method>
-  <load container="A"/>
-  <inport name="a" type="double"/>
-  <inport name="b" type="double"/>
-  <outport name="c" type="double"/>
-  <instream name="aa" type="CALCIUM_double"/>
-  <outstream name="ba" type="CALCIUM_double"/>
-</service>
-
-<service name="node2" >
-  <component>compo1</component>
-  <method>s1</method>
-  <load container="B"/>
-  <inport name="a" type="double"/>
-  <inport name="b" type="double"/>
-  <outport name="c" type="double"/>
-  <instream name="aa" type="CALCIUM_double"/>
-  <outstream name="ba" type="CALCIUM_double"/>
-</service>
-
-<!--datalinks -->
-<stream>
-  <fromnode>node1</fromnode><fromport>ba</fromport>
-  <tonode>node2</tonode><toport>aa</toport>
-</stream>
-<stream>
-  <fromnode>node2</fromnode><fromport>ba</fromport>
-  <tonode>node1</tonode><toport>aa</toport>
-</stream>
-
-<parameter>
-  <tonode>node1</tonode> <toport>a</toport>
-  <value><double>23</double> </value>
-</parameter>
-<parameter>
-  <tonode>node1</tonode> <toport>b</toport>
-  <value><double>53</double> </value>
-</parameter>
-<parameter>
-  <tonode>node2</tonode> <toport>a</toport>
-  <value><double>63</double> </value>
-</parameter>
-<parameter>
-  <tonode>node2</tonode> <toport>b</toport>
-  <value><double>73</double> </value>
-</parameter>
-
+<?xml version='1.0' encoding='iso-8859-1' ?>
+<proc name="proc">
+   <property name="DefaultStudyID" value="1"/>
+   <objref name="CALCIUM_double" id="IDL:Ports/Calcium_Ports/Calcium_Double_Port:1.0"/>
+   <type name="string" kind="string"/>
+   <struct name="Engines/dataref">
+      <member name="ref" type="string"/>
+   </struct>
+   <type name="bool" kind="bool"/>
+   <sequence name="boolvec" content="bool"/>
+   <type name="double" kind="double"/>
+   <sequence name="dblevec" content="double"/>
+   <objref name="file" id="file"/>
+   <type name="int" kind="int"/>
+   <sequence name="intvec" content="int"/>
+   <objref name="pyobj" id="python:obj:1.0"/>
+   <sequence name="stringvec" content="string"/>
+   <container name="A">
+   </container>
+   <container name="B">
+   </container>
+   <container name="DefaultContainer">
+      <property name="container_name" value="FactoryServer"/>
+      <property name="name" value="localhost"/>
+   </container>
+   <service name="node1">
+      <component>compo1</component>
+      <load container="A"/>
+      <method>s1</method>
+      <inport name="a" type="double"/>
+      <inport name="b" type="double"/>
+      <instream name="aa" type="CALCIUM_double"/>
+      <outport name="c" type="double"/>
+      <outstream name="ba" type="CALCIUM_double"/>
+   </service>
+   <service name="node2">
+      <component>compo1</component>
+      <load container="B"/>
+      <method>s1</method>
+      <inport name="a" type="double"/>
+      <inport name="b" type="double"/>
+      <instream name="aa" type="CALCIUM_double"/>
+      <outport name="c" type="double"/>
+      <outstream name="ba" type="CALCIUM_double"/>
+   </service>
+   <stream>
+      <fromnode>node1</fromnode> <fromport>ba</fromport>
+      <tonode>node2</tonode> <toport>aa</toport>
+   </stream>
+   <stream>
+      <fromnode>node2</fromnode> <fromport>ba</fromport>
+      <tonode>node1</tonode> <toport>aa</toport>
+   </stream>
+   <parameter>
+      <tonode>node1</tonode><toport>a</toport>
+      <value><double>23</double></value>
+   </parameter>
+   <parameter>
+      <tonode>node1</tonode><toport>b</toport>
+      <value><double>53</double></value>
+   </parameter>
+   <parameter>
+      <tonode>node2</tonode><toport>a</toport>
+      <value><double>63</double></value>
+   </parameter>
+   <parameter>
+      <tonode>node2</tonode><toport>b</toport>
+      <value><double>73</double></value>
+   </parameter>
+   <presentation name="node1" x="1.75" y="33.25" width="158" height="117" expanded="1" expx="1.75" expy="33.25" expWidth="158" expHeight="117" shownState="0"/>
+   <presentation name="node2" x="195.75" y="33.25" width="158" height="117" expanded="1" expx="195.75" expy="33.25" expWidth="158" expHeight="117" shownState="0"/>
+   <presentation name="__ROOT__" x="0" y="0" width="357.75" height="154.25" expanded="1" expx="0" expy="0" expWidth="357.75" expHeight="154.25" shownState="0"/>
 </proc>
-
index 43cd3266ebd6b68661e4323f0fee1257ac177fe3..0fc17eacde4764821cfb1c03f110273cca0d282f 100644 (file)
 execfile("../context.py")
 
 import os
-from module_generator import Generator,Module,Service,CPPComponent
+from module_generator import *
+
+idldefs="""
+#include "myinterface.idl"
+"""
+
+compodefs=r"""
+
+
+class A: public virtual POA_Idl_A
+{
+public:
+  void createObject(::SALOMEDS::Study_ptr theStudy, const char* name){};
+
+  // Driver interface
+  virtual SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile){return 0;};
+  virtual SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile){return 0;};
+  virtual bool Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile){return 0;};
+  virtual bool LoadASCII(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile){return 0;};
+  virtual void Close(SALOMEDS::SComponent_ptr IORSComponent){};
+  virtual char* ComponentDataType(){return "cppcompos";};
+  virtual char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, const char* IORString, CORBA::Boolean isMultiFile, CORBA::Boolean isASCII){return 0;};
+  virtual char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, const char* aLocalPersistentID, CORBA::Boolean isMultiFile,
+                                       CORBA::Boolean isASCII){return 0;};
+  virtual bool  CanPublishInStudy(CORBA::Object_ptr theIOR){return 0;};
+  virtual SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,SALOMEDS::SObject_ptr theSObject,CORBA::Object_ptr theObject,
+                                               const char* theName){return 0;};
+  virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject){return 0;};
+  virtual SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID){return 0;};
+  virtual CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID){return 0;};
+  virtual SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, CORBA::Long theObjectID, SALOMEDS::SObject_ptr theObject){return 0;};
+};
+
+"""
+
+compomethods=r"""
+
+  Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
+                               CORBA::Boolean isPublished,
+                               CORBA::Boolean& isValidScript)
+  {
+    std::cerr << "je suis dans le dump:" << __LINE__ << std::endl;
+    SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
+    if(CORBA::is_nil(aStudy))
+      return new Engines::TMPFile(0);
+
+    SALOMEDS::SObject_var aSO = aStudy->FindComponent("cppcompos");
+    if(CORBA::is_nil(aSO))
+       return new Engines::TMPFile(0);
+
+    std::string Script = "import cppcompos_ORB\n";
+    Script += "import salome\n";
+    Script += "compo = salome.lcc.FindOrLoadComponent('FactoryServer','cppcompos')\n";
+    Script += "def RebuildData(theStudy):\n";
+    Script += "  compo.SetCurrentStudy(theStudy)\n";
+    const char* aScript=Script.c_str();
+
+    char* aBuffer = new char[strlen(aScript)+1];
+    strcpy(aBuffer, aScript);
+    CORBA::Octet* anOctetBuf =  (CORBA::Octet*)aBuffer;
+    int aBufferSize = strlen(aBuffer)+1;
+    Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1);
+    isValidScript = true;
+    return aStreamFile._retn();
+  }
+
+
+"""
 
 body="""
 std::cerr << "a: " << a << std::endl;
@@ -29,18 +96,24 @@ std::cerr << "b: " << b << std::endl;
 c=a+b;
 std::cerr << "c: " << c << std::endl;
 """
-c1=CPPComponent("compo1",services=[
+c1=CPPComponent("cppcompos",services=[
           Service("s1",inport=[("a","double"),("b","double")],
                        outport=[("c","double")],
                        defs="//def1",body=body,
                  ),
           ],
          includes="-I/usr/include",
+         idls=["*.idl"],
+         interfacedefs=idldefs,
+         inheritedinterface="Idl_A",
+         compodefs=compodefs,
+         inheritedclass="A",
+         addedmethods=compomethods,
          )
 
 modul=Module("cppcompos",components=[c1],prefix="./install",
              doc=["*.rst",],
-             gui=["cppcomposGUI.cxx","cppcomposGUI.h","Makefile.am","demo.ui","*.png"],
+             gui=["cppcomposGUI.cxx","cppcomposGUI.h","demo.ui","*.png"],
             )
 
 g=Generator(modul,context)
index 0c2bfcb64e2161eabcf49b4d2ee1bde3999e87a6..47df890b7aa968118f8bbe2dbb0be21e7651d048 100644 (file)
@@ -2,7 +2,14 @@
 #include <SUIT_MessageBox.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_Desktop.h>
+#include <SUIT_Study.h>
 #include <SalomeApp_Application.h>
+#include <SALOME_LifeCycleCORBA.hxx>
+
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(cppcompos)
+#include CORBA_CLIENT_HEADER(SALOMEDS)
+#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
 
 // QT Includes
 #include <QInputDialog>
@@ -23,12 +30,17 @@ cppcomposGUI::cppcomposGUI() :
 {
 }
 
+static cppcompos_ORB::cppcompos_var engine;
+
 // Module's initialization
 void cppcomposGUI::initialize( CAM_Application* app )
 {
 
   SalomeApp_Module::initialize( app );
 
+  Engines::Component_var comp = dynamic_cast<SalomeApp_Application*>(app)->lcc()->FindOrLoad_Component( "FactoryServer","cppcompos" );
+  engine = cppcompos_ORB::cppcompos::_narrow(comp);
+
   QWidget* aParent = application()->desktop();
   SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
 
@@ -48,6 +60,14 @@ void cppcomposGUI::initialize( CAM_Application* app )
   createTool( 902, aToolId );
 }
 
+// Get compatible dockable windows.
+void cppcomposGUI::windows( QMap<int, int>& theMap ) const
+{
+  theMap.clear();
+  theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
+  theMap.insert( SalomeApp_Application::WT_PyConsole,     Qt::BottomDockWidgetArea );
+}
+
 // Module's engine IOR
 QString cppcomposGUI::engineIOR() const
 {
@@ -62,6 +82,25 @@ bool cppcomposGUI::activateModule( SUIT_Study* theStudy )
   setMenuShown( true );
   setToolShown( true );
 
+  SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
+  CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
+  SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
+  SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(theStudy->id());
+
+  SALOMEDS::SComponent_var aFather = aDSStudy->FindComponent("cppcompos");
+  if (aFather->_is_nil())
+    {
+      SALOMEDS::StudyBuilder_var aStudyBuilder = aDSStudy->NewBuilder();
+      aFather = aStudyBuilder->NewComponent("cppcompos");
+      SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributeName");
+      SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+      aName->SetValue("cppcompos");
+      aName->Destroy();
+      aStudyBuilder->DefineComponentInstance(aFather, engine);
+    }
+  CORBA::Boolean valid;
+  engine->DumpPython(aDSStudy,1,valid);
+
   return bOk;
 }
 
@@ -83,6 +122,9 @@ void cppcomposGUI::OnGetBanner()
 
   if ( ok && !myName.isEmpty()) 
   {
+    ::CORBA::Double c;
+    engine->s1(1.,2.,c);
+    std::cerr << c << std::endl;
     QString banner = "Hello " + myName;
     SUIT_MessageBox::information( getApp()->desktop(), "info", banner, "OK" );
   }
index a9f5abc75aafef51ea5074f7e55371946deeea9d..e722eb63d82d36aa420fb44fb38e13d47b04c752 100644 (file)
@@ -12,6 +12,7 @@ public:
   cppcomposGUI();
   void    initialize( CAM_Application* );
   QString engineIOR() const;
+  virtual void  windows( QMap<int, int>& theMap ) const;
 
 public slots:
   bool    deactivateModule( SUIT_Study* );
diff --git a/Examples/cppgui1/myinterface.idl b/Examples/cppgui1/myinterface.idl
new file mode 100644 (file)
index 0000000..16207a9
--- /dev/null
@@ -0,0 +1,8 @@
+#include "SALOMEDS.idl"
+#include "SALOME_Exception.idl"
+
+interface Idl_A : SALOMEDS::Driver
+{
+  void createObject(in SALOMEDS::Study theStudy, in string name) raises (SALOME::SALOME_Exception);
+};
+
index c3d4ef8a0486ec5dbd0b9641f51a99eec5bbd3ac..8c0e5519690818213f85507dbc4e37aa3dac2b49 100644 (file)
@@ -1,59 +1,67 @@
-
-<proc>
-
-<!-- types -->
-
-
-<container name="A">
-</container>
-
-<container name="B">
-</container>
-
-<service name="node1" >
-  <component>fcode1</component>
-  <method>serv1</method>
-  <load container="A"/>
-  <inport name="a" type="double"/>
-  <inport name="b" type="double"/>
-  <outport name="c" type="double"/>
-  <outstream name="PARAM" type="CALCIUM_double"/>
-</service>
-
-<service name="node2" >
-  <component>fcode2</component>
-  <method>serv1</method>
-  <load container="B"/>
-  <inport name="a" type="double"/>
-  <inport name="b" type="double"/>
-  <outport name="c" type="double"/>
-  <instream name="PARAM" type="CALCIUM_double"/>
-</service>
-
-
-<!--datalinks -->
-<stream>
-  <fromnode>node1</fromnode><fromport>PARAM</fromport>
-  <tonode>node2</tonode><toport>PARAM</toport>
-</stream>
-
-<parameter>
-  <tonode>node1</tonode> <toport>a</toport>
-  <value><double>23</double> </value>
-</parameter>
-<parameter>
-  <tonode>node1</tonode> <toport>b</toport>
-  <value><double>53</double> </value>
-</parameter>
-<parameter>
-  <tonode>node2</tonode> <toport>a</toport>
-  <value><double>63</double> </value>
-</parameter>
-<parameter>
-  <tonode>node2</tonode> <toport>b</toport>
-  <value><double>73</double> </value>
-</parameter>
-
-
+<?xml version='1.0' encoding='iso-8859-1' ?>
+<proc name="proc">
+   <property name="DefaultStudyID" value="1"/>
+   <objref name="CALCIUM_double" id="IDL:Ports/Calcium_Ports/Calcium_Double_Port:1.0"/>
+   <type name="string" kind="string"/>
+   <struct name="Engines/dataref">
+      <member name="ref" type="string"/>
+   </struct>
+   <type name="bool" kind="bool"/>
+   <sequence name="boolvec" content="bool"/>
+   <type name="double" kind="double"/>
+   <sequence name="dblevec" content="double"/>
+   <objref name="file" id="file"/>
+   <type name="int" kind="int"/>
+   <sequence name="intvec" content="int"/>
+   <objref name="pyobj" id="python:obj:1.0"/>
+   <sequence name="stringvec" content="string"/>
+   <container name="A">
+   </container>
+   <container name="B">
+   </container>
+   <container name="DefaultContainer">
+      <property name="container_name" value="FactoryServer"/>
+      <property name="name" value="localhost"/>
+   </container>
+   <service name="node1">
+      <component>fcode1</component>
+      <load container="A"/>
+      <method>serv1</method>
+      <inport name="a" type="double"/>
+      <inport name="b" type="double"/>
+      <outport name="c" type="double"/>
+      <outstream name="PARAM" type="CALCIUM_double"/>
+   </service>
+   <service name="node2">
+      <component>fcode2</component>
+      <load container="B"/>
+      <method>serv1</method>
+      <inport name="a" type="double"/>
+      <inport name="b" type="double"/>
+      <instream name="PARAM" type="CALCIUM_double"/>
+      <outport name="c" type="double"/>
+   </service>
+   <stream>
+      <fromnode>node1</fromnode> <fromport>PARAM</fromport>
+      <tonode>node2</tonode> <toport>PARAM</toport>
+   </stream>
+   <parameter>
+      <tonode>node1</tonode><toport>a</toport>
+      <value><double>23</double></value>
+   </parameter>
+   <parameter>
+      <tonode>node1</tonode><toport>b</toport>
+      <value><double>53</double></value>
+   </parameter>
+   <parameter>
+      <tonode>node2</tonode><toport>a</toport>
+      <value><double>63</double></value>
+   </parameter>
+   <parameter>
+      <tonode>node2</tonode><toport>b</toport>
+      <value><double>73</double></value>
+   </parameter>
+   <presentation name="node1" x="1.75" y="46.75" width="158" height="90" expanded="1" expx="1.75" expy="46.75" expWidth="158" expHeight="90" shownState="0"/>
+   <presentation name="node2" x="195.75" y="33.25" width="158" height="117" expanded="1" expx="195.75" expy="33.25" expWidth="158" expHeight="117" shownState="0"/>
+   <presentation name="__ROOT__" x="0" y="0" width="357.75" height="154.25" expanded="1" expx="0" expy="0" expWidth="357.75" expHeight="154.25" shownState="0"/>
 </proc>
-
index f10274bc13d2b9ff45d6c18c0c6a678cd5c50688..1ca7ac3e63585086b3bdf01e979a6cee5217476b 100644 (file)
@@ -22,7 +22,7 @@ import os
 #import context from ..
 execfile("../context.py")
 
-from module_generator import Generator,Module,Service,PYComponent
+from module_generator import *
 
 defs="""
 """
@@ -31,16 +31,79 @@ body="""
       c=a+b
       d=a-b
 """
-c1=PYComponent("compo2",services=[
+
+idldefs="""
+#include "myinterface.idl"
+"""
+
+compodefs=r"""
+import SALOME_DriverPy
+import traceback
+
+class A(SALOME_DriverPy.SALOME_DriverPy_i):
+    def __init__(self):
+      SALOME_DriverPy.SALOME_DriverPy_i.__init__(self,"pycompos")
+      return
+
+    def createObject( self, study, name ):
+      "Create object.  "
+      try:
+        print study,name
+        builder = study.NewBuilder()
+        father = study.FindComponent( "pycompos" )
+        if father is None:
+            father = builder.NewComponent( "pycompos" )
+            attr = builder.FindOrCreateAttribute( father, "AttributeName" )
+            attr.SetValue( "pycompos" )
+
+        object  = builder.NewObject( father )
+        attr    = builder.FindOrCreateAttribute( object, "AttributeName" )
+        attr.SetValue( name )
+      except:
+        traceback.print_exc()
+
+    def DumpPython( self, study, isPublished ):
+       abuffer = []
+       abuffer.append( "def RebuildData( theStudy ):" )
+       names = []
+       father = study.FindComponent( "pycompos" )
+       if father:
+           iter = study.NewChildIterator( father )
+           while iter.More():
+               name = iter.Value().GetName()
+               if name: names.append( name )
+               iter.Next()
+               pass
+           pass
+       if names:
+           abuffer += [ "  from salome import lcc" ]
+           abuffer += [ "  import pycompos_ORB" ]
+           abuffer += [ "  " ]
+           abuffer += [ "  compo = lcc.FindOrLoadComponent( 'FactoryServerPy', 'pycompos' )" ]
+           abuffer += [ "  " ]
+           abuffer += [ "  compo.createObject( theStudy, '%s' )" % name for name in names ]
+           pass
+       abuffer += [ "  " ]
+
+       return ("\n".join( abuffer ), 1)
+
+"""
+
+c1=PYComponent("pycompos",services=[
           Service("s1",inport=[("a","double"),("b","double")],
                        outport=[("c","double"),("d","double")],
                        defs=defs,body=body,
                  ),
          ],
+              idls=["*.idl"],
+              interfacedefs=idldefs,
+              inheritedinterface="Idl_A",
+              compodefs=compodefs,
+              inheritedclass="A",
          )
 
 modul=Module("pycompos",components=[c1],prefix="./install",
-              doc=["*.rst",],
+              doc=["*.rst","*.png"],
               gui=["pycomposGUI.py","demo.ui","*.png"],
             )
 
diff --git a/Examples/pygui1/myinterface.idl b/Examples/pygui1/myinterface.idl
new file mode 100644 (file)
index 0000000..16207a9
--- /dev/null
@@ -0,0 +1,8 @@
+#include "SALOMEDS.idl"
+#include "SALOME_Exception.idl"
+
+interface Idl_A : SALOMEDS::Driver
+{
+  void createObject(in SALOMEDS::Study theStudy, in string name) raises (SALOME::SALOME_Exception);
+};
+
index 933665f8ad835e8b08eeb1696921c017c522675e..f57dd52dcd1488ada4ebe34519aa370faba1d4fc 100644 (file)
@@ -5,10 +5,34 @@ from PyQt4.QtGui import *
 from PyQt4.QtWebKit import *
 from PyQt4 import QtCore, QtGui, uic
 
+import salome
+import pycompos_ORB
+
 # Get SALOME PyQt interface
 import SalomePyQt
 sgPyQt = SalomePyQt.SalomePyQt()
 
+# Get SALOME Swig interface
+import libSALOME_Swig
+sg = libSALOME_Swig.SALOMEGUI_Swig()
+
+# object counter
+__objectid__ = 0
+
+###
+# get active study ID
+###
+def _getStudyId():
+    return sgPyQt.getStudyId()
+
+###
+# get active study
+###
+def _getStudy():
+    studyId = _getStudyId()
+    study = salome.myStudyManager.GetStudyByID( studyId )
+    return study
+
 # called when module is initialized
 # return map of popup windows to be used by the module
 def windows():
@@ -36,12 +60,38 @@ def activate():
   a = sgPyQt.createAction( 942, "Hello2", "Hello2", "Show hello2 dialog box" ,"exec.png")
   sgPyQt.createMenu( a, mid )
   sgPyQt.createTool( a, tid )
+  a = sgPyQt.createAction( 943, "Create object", "Create object", "Create object","exec.png" )
+  sgPyQt.createMenu( a, mid )
+  sgPyQt.createTool( a, tid )
+
   return True
 
 # called when module is deactivated
 def deactivate():
   pass
 
+_engine=None
+def getEngine():
+  global _engine
+  if not _engine:
+    _engine= salome.lcc.FindOrLoadComponent( "FactoryServerPy", "pycompos" )
+  return _engine
+
+###
+# Create new object
+###
+def CreateObject():
+    global __objectid__
+    default_name = str( sgPyQt.stringSetting( "pycompos", "def_obj_name", "Object" ).trimmed() )
+    # generate object name
+    __objectid__  = __objectid__ + 1
+    name = "%s_%d" % ( default_name, __objectid__ )
+    if not name: return
+    getEngine().createObject( _getStudy(), name )
+    print getEngine().s1(4,5)
+    print getEngine().ComponentDataType()
+    sg.updateObjBrowser( True )
+
 class DemoImpl(QtGui.QDialog):
     def __init__(self, *args):
         super(DemoImpl, self).__init__(*args)
@@ -69,5 +119,7 @@ def OnGUIEvent( commandID ):
     widget = DemoImpl(sgPyQt.getDesktop())
     widget.show()
 
+  elif commandID==943:
+    CreateObject()
 
 
index f28347df83071e7fc79f20c2a6af0d02a8a717f7..8321bf36909890ac2611f7be51353a9054148a59 100644 (file)
@@ -15,3 +15,6 @@ The Object Browser is in a tab, with tree_view
 
 Other
 ----------
+.. image:: exec.png
+  :align: center
+
index cd9b441f25faba3b1b9c6b1a16a63ebaec9e3295..7c95f9484aa479f5f7aa927bd2aaf31bd826b453 100644 (file)
@@ -1,65 +1,75 @@
-
-<proc>
-
-<!-- types -->
-
-
-<container name="A">
-</container>
-
-<container name="B">
-</container>
-
-<service name="node1" >
-  <component>compo2</component>
-  <method>s1</method>
-  <load container="A"/>
-  <inport name="a" type="double"/>
-  <inport name="b" type="double"/>
-  <outport name="c" type="double"/>
-  <outport name="d" type="double"/>
-  <instream name="aa" type="CALCIUM_double"/>
-  <outstream name="ba" type="CALCIUM_double"/>
-</service>
-
-<service name="node2" >
-  <component>compo2</component>
-  <method>s1</method>
-  <load container="B"/>
-  <inport name="a" type="double"/>
-  <inport name="b" type="double"/>
-  <outport name="c" type="double"/>
-  <outport name="d" type="double"/>
-  <instream name="aa" type="CALCIUM_double"/>
-  <outstream name="ba" type="CALCIUM_double"/>
-</service>
-
-<!--datalinks -->
-<stream>
-  <fromnode>node1</fromnode><fromport>ba</fromport>
-  <tonode>node2</tonode><toport>aa</toport>
-</stream>
-<stream>
-  <fromnode>node2</fromnode><fromport>ba</fromport>
-  <tonode>node1</tonode><toport>aa</toport>
-</stream>
-
-<parameter>
-  <tonode>node1</tonode> <toport>a</toport>
-  <value><double>23</double> </value>
-</parameter>
-<parameter>
-  <tonode>node1</tonode> <toport>b</toport>
-  <value><double>53</double> </value>
-</parameter>
-<parameter>
-  <tonode>node2</tonode> <toport>a</toport>
-  <value><double>63</double> </value>
-</parameter>
-<parameter>
-  <tonode>node2</tonode> <toport>b</toport>
-  <value><double>73</double> </value>
-</parameter>
-
+<?xml version='1.0' encoding='iso-8859-1' ?>
+<proc name="proc">
+   <property name="DefaultStudyID" value="1"/>
+   <objref name="CALCIUM_double" id="IDL:Ports/Calcium_Ports/Calcium_Double_Port:1.0"/>
+   <type name="string" kind="string"/>
+   <struct name="Engines/dataref">
+      <member name="ref" type="string"/>
+   </struct>
+   <type name="bool" kind="bool"/>
+   <sequence name="boolvec" content="bool"/>
+   <type name="double" kind="double"/>
+   <sequence name="dblevec" content="double"/>
+   <objref name="file" id="file"/>
+   <type name="int" kind="int"/>
+   <sequence name="intvec" content="int"/>
+   <objref name="pyobj" id="python:obj:1.0"/>
+   <sequence name="stringvec" content="string"/>
+   <container name="A">
+   </container>
+   <container name="B">
+   </container>
+   <container name="DefaultContainer">
+      <property name="container_name" value="FactoryServer"/>
+      <property name="name" value="localhost"/>
+   </container>
+   <service name="node1">
+      <component>compo2</component>
+      <load container="A"/>
+      <method>s1</method>
+      <inport name="a" type="double"/>
+      <inport name="b" type="double"/>
+      <instream name="aa" type="CALCIUM_double"/>
+      <outport name="c" type="double"/>
+      <outport name="d" type="double"/>
+      <outstream name="ba" type="CALCIUM_double"/>
+   </service>
+   <service name="node2">
+      <component>compo2</component>
+      <load container="B"/>
+      <method>s1</method>
+      <inport name="a" type="double"/>
+      <inport name="b" type="double"/>
+      <instream name="aa" type="CALCIUM_double"/>
+      <outport name="c" type="double"/>
+      <outport name="d" type="double"/>
+      <outstream name="ba" type="CALCIUM_double"/>
+   </service>
+   <stream>
+      <fromnode>node1</fromnode> <fromport>ba</fromport>
+      <tonode>node2</tonode> <toport>aa</toport>
+   </stream>
+   <stream>
+      <fromnode>node2</fromnode> <fromport>ba</fromport>
+      <tonode>node1</tonode> <toport>aa</toport>
+   </stream>
+   <parameter>
+      <tonode>node1</tonode><toport>a</toport>
+      <value><double>23</double></value>
+   </parameter>
+   <parameter>
+      <tonode>node1</tonode><toport>b</toport>
+      <value><double>53</double></value>
+   </parameter>
+   <parameter>
+      <tonode>node2</tonode><toport>a</toport>
+      <value><double>63</double></value>
+   </parameter>
+   <parameter>
+      <tonode>node2</tonode><toport>b</toport>
+      <value><double>73</double></value>
+   </parameter>
+   <presentation name="node1" x="1.75" y="33.25" width="158" height="117" expanded="1" expx="1.75" expy="33.25" expWidth="158" expHeight="117" shownState="0"/>
+   <presentation name="node2" x="195.75" y="33.25" width="158" height="117" expanded="1" expx="195.75" expy="33.25" expWidth="158" expHeight="117" shownState="0"/>
+   <presentation name="__ROOT__" x="0" y="0" width="357.75" height="154.25" expanded="1" expx="0" expy="0" expWidth="357.75" expHeight="154.25" shownState="0"/>
 </proc>
-
index dcfbd5312020e263a8f7cf00ed1c2138c1cb0f38..e79531f531025971906ee273ff571b311a721613 100644 (file)
@@ -18,9 +18,9 @@
 #
 
 """
-  Package to generate SALOME modules with components
-  implemented in C++, Fortran or Python
-  that can use datastream ports
+The python module module_generator defines classes which can be used to define a SALOME module, its components and
+generates a SALOME source module, its installation and a SALOME application including this module and
+other preexisting SALOME modules like GEOM, SMESH or others.
 """
 from gener import Module, Service, Generator
 from fcompo import F77Component
index 879501b4fa7348f611824d1bfed092f666dec2da..cb99fcf4045e923cfb0719cfc289e848cb0d227f 100644 (file)
@@ -36,6 +36,30 @@ from aster_tmpl import comm, make_etude, cexe, exeaster
 from aster_tmpl import container, component
 
 class ASTERComponent(Component):
+  """
+   A :class:`ASTERComponent` instance represents an ASTER SALOME component (special component for Code_Aster that is a mix of
+   Fortran and Python code) with services given as a list of :class:`Service` instances with the parameter *services*.
+
+   :param name: gives the name of the component.
+   :type name: str
+   :param services: the list of services (:class:`Service`) of the component.
+   :param kind: If it is given and has the value "exe", the component will be built as a standalone
+      component (executable or shell script). The default is to build the component as a dynamic library.
+   :param libs: gives all the libraries options to add when linking the generated component (-L...).
+   :param rlibs: gives all the runtime libraries options to add when linking the generated component (-R...).
+   :param exe_path: is only used when kind is "exe" and gives the path to the standalone component.
+   :param aster_dir: gives the Code_Aster installation directory.
+   :param python_path: If it is given (as a list of paths), all the paths are added to the python path (sys.path).
+   :param argv: is a list of strings that gives the command line parameters for Code_Aster. This parameter is only useful when
+      kind is "lib".
+
+   For example, the following call defines a Code_Aster component named "mycompo" with one service s1 (it must have been defined before).
+   This standalone component takes some command line arguments::
+
+      >>> c1 = module_generator.ASTERComponent('mycompo', services=[s1,], kind="exe",
+                                                          exe_path="launch.sh",
+                                                          argv=["-memjeveux","4"])
+  """
   def __init__(self, name, services=None, libs="", rlibs="", aster_dir="", 
                      python_path=None, argv=None, kind="lib", exe_path=None):
     """initialise component attributes"""
index 392259001fac5a87f7b454cc930196441774074d..80c255af0ea870ddbc580d7f32e52f032c2b34a4 100644 (file)
@@ -24,7 +24,7 @@ except:
 
 asterCompo="""
 import sys,traceback,os
-import ${module}__POA
+import ${module}_ORB__POA
 import calcium
 import dsccalcium
 import SALOME
@@ -48,11 +48,11 @@ except:
 ${servicesdef}
 #ENDDEF
 
-class ${component}(${module}__POA.${component},dsccalcium.PyDSCComponent,SUPERV):
+class ${component}(${module}_ORB__POA.${component},dsccalcium.PyDSCComponent,SUPERV):
   '''
      To be identified as a SALOME component this Python class
      must have the same name as the component, inherit omniorb
-     class ${module}__POA.${component} and DSC class dsccalcium.PyDSCComponent
+     class ${module}_ORB__POA.${component} and DSC class dsccalcium.PyDSCComponent
      that implements DSC API.
   '''
   def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ):
@@ -78,7 +78,7 @@ asterCompo=Template(asterCompo)
 asterCEXECompo="""
 import sys,traceback,os
 import string
-import ${module}__POA
+import ${module}_ORB__POA
 import calcium
 import dsccalcium
 import SALOME
@@ -97,11 +97,11 @@ ${servicesdef}
 class ExecutionError(Exception):
   '''General exception during execution'''
 
-class ${component}(${module}__POA.${component},dsccalcium.PyDSCComponent,SUPERV):
+class ${component}(${module}_ORB__POA.${component},dsccalcium.PyDSCComponent,SUPERV):
   '''
      To be identified as a SALOME component this Python class
      must have the same name as the component, inherit omniorb
-     class ${module}__POA.${component} and DSC class dsccalcium.PyDSCComponent
+     class ${module}_ORB__POA.${component} and DSC class dsccalcium.PyDSCComponent
      that implements DSC API.
   '''
   def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ):
index 1c4c7a1370e89f5f99424afceca7cfc29ecf3db5..c8feeffcd57b9a30256c1911798b402687e5d88d 100644 (file)
@@ -36,7 +36,7 @@ idl="""
 
 ${idldefs}
 
-module ${module}
+module ${module}_ORB
 {
 typedef sequence<string> stringvec;
 typedef sequence<double> dblevec;
@@ -51,7 +51,7 @@ ${interfaces}
 idl=Template(idl)
 
 interface="""
-  interface ${component}:Engines::Superv_Component
+  interface ${component}:${inheritedinterface} Engines::Superv_Component
   {
 ${services}
   };
@@ -96,22 +96,21 @@ xml_service = Template(xml_service)
 idlMakefile="""
 include $$(top_srcdir)/adm_local/make_common_starter.am
 
-BUILT_SOURCES = ${module}SK.cc ${PACO_BUILT_SOURCES}
-IDL_FILES=${module}.idl
+BUILT_SOURCES = ${module}SK.cc ${PACO_BUILT_SOURCES} ${other_sks}
+IDL_FILES=${module}.idl ${other_idls}
 
-lib_LTLIBRARIES = lib${module}.la
+lib_LTLIBRARIES = libSalomeIDL${module}.la
 salomeidl_DATA = $$(IDL_FILES) ${PACO_salomeidl_DATA}
-salomepython_DATA = ${module}_idl.py ${PACO_salomepython_DATA}
-lib${module}_la_SOURCES      =
-nodist_lib${module}_la_SOURCES = ${module}SK.cc
+libSalomeIDL${module}_la_SOURCES      =
+nodist_libSalomeIDL${module}_la_SOURCES = ${module}SK.cc ${other_sks}
 nodist_salomeinclude_HEADERS= ${module}.hh ${PACO_SALOMEINCLUDE_HEADERS}
-lib${module}_la_CXXFLAGS     = -I.  $$(SALOME_INCLUDES)
-lib${module}_la_LIBADD     = $$(SALOME_IDL_LIBS)
+libSalomeIDL${module}_la_CXXFLAGS     = -I.  $$(SALOME_INCLUDES)
+libSalomeIDL${module}_la_LIBADD     = $$(SALOME_IDL_LIBS)
 ##########################################################
 %SK.cc %.hh : %.idl
-\t$$(OMNIORB_IDL) -bcxx $$(IDLCXXFLAGS) $$(OMNIORB_IDLCXXFLAGS) $$(IDL_INCLUDES) $$<
+\t$$(OMNIORB_IDL) -bcxx $$(OMNIORB_IDLCXXFLAGS) $$(IDL_INCLUDES) $$<
 %_idl.py : %.idl
-\t$$(OMNIORB_IDL) -bpython $$(IDL_INCLUDES) ${PACO_INCLUDES} $$<
+\t$$(OMNIORB_IDL) $$(OMNIORB_IDLPYFLAGS) $$(IDL_INCLUDES) ${PACO_INCLUDES} $$<
 %PaCO.hxx %PaCO.cxx : %.idl %.xml
 \t$$(OMNIORB_IDL) -I@KERNEL_ROOT_DIR@/idl/salome -p@PACOPATH@/lib/python -bpaco -Wb$$(top_srcdir)/idl/$$*.xml,$$(srcdir):@PACOPATH@/idl:@KERNEL_ROOT_DIR@/idl/salome $$(top_srcdir)/idl/$$*.idl
 
@@ -119,16 +118,15 @@ CLEANFILES = *.hh *SK.cc *.py *.hxx *.cxx
 
 EXTRA_DIST = $$(IDL_FILES)
 
-clean-local:
-\trm -rf ${module} ${module}__POA
-
-install-data-local:
-\t$${mkinstalldirs} $$(DESTDIR)$$(salomepythondir)
-\tcp -R ${module} ${module}__POA $$(DESTDIR)$$(salomepythondir)
+install-data-local: $$(IDL_FILES)
+\t$$(INSTALL) -d  $$(DESTDIR)$$(salomepythondir)
+\tls $$^ | while read file; do \\
+\t$$(OMNIORB_IDL) $$(OMNIORB_IDLPYFLAGS) $$(IDL_INCLUDES) -C$$(DESTDIR)$$(salomepythondir) $$$$file ; \\
+\tdone
 
 uninstall-local:
-\trm -rf $$(DESTDIR)$$(salomepythondir)/${module}
-\trm -rf $$(DESTDIR)$$(salomepythondir)/${module}__POA
+\trm -rf $$(DESTDIR)$$(salomepythondir)/*
+
 """
 idlMakefile=Template(idlMakefile)
 
index 4979bfadd53884bb932802996a9392109d82dfbe..eadcce2095625444684adf1577bcce5f5dfb0838 100644 (file)
@@ -235,7 +235,7 @@ extern "C"
         Engines::Container_var container = Engines::Container::_narrow(obj);
         ${component}_i * myEngine = new ${component}_i(orb, poa, container, instanceName.c_str(), "${component}");
         pman->activate();
-        obj=myEngine->_this();
+        obj=myEngine->POA_${module}_ORB::${component}::_this();
         Engines::Component_var component = Engines::Component::_narrow(obj);
         string component_registerName = containerName + "/" + instanceName;
         salomens->Register(component,component_registerName.c_str());
@@ -276,9 +276,8 @@ hxxCompo="""
 ${compodefs}
 //ENDDEF
 
-class ${component}_i: ${inheritedclass}
-  public virtual POA_${module}::${component},
-  public virtual Superv_Component_i
+class ${component}_i: public virtual POA_${module}_ORB::${component},
+                      ${inheritedclass} public virtual Superv_Component_i
 {
   public:
     ${component}_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa,
@@ -402,7 +401,7 @@ lib${component}Engine_la_SOURCES      = ${component}.cxx ${sources}
 nodist_lib${component}Engine_la_SOURCES =
 lib${component}Engine_la_CXXFLAGS = -I$$(top_builddir)/idl  $$(SALOME_INCLUDES) ${includes}
 lib${component}Engine_la_FFLAGS = $$(SALOME_INCLUDES) -fexceptions ${includes}
-lib${component}Engine_la_LIBADD   = ${libs} -L$$(top_builddir)/idl -l${module} $${SALOME_LIBS} $$(FLIBS)
+lib${component}Engine_la_LIBADD   = ${libs} -L$$(top_builddir)/idl -lSalomeIDL${module} $${SALOME_LIBS} $$(FLIBS)
 lib${component}Engine_la_LDFLAGS = ${rlibs}
 """
 compoMakefile=Template(compoMakefile)
@@ -412,7 +411,7 @@ lib${component}Exelib_la_SOURCES      = ${component}.cxx
 nodist_lib${component}Exelib_la_SOURCES =
 lib${component}Exelib_la_CXXFLAGS = -I$$(top_builddir)/idl  $$(SALOME_INCLUDES) ${includes}
 lib${component}Exelib_la_FFLAGS = $$(SALOME_INCLUDES) -fexceptions ${includes}
-lib${component}Exelib_la_LIBADD   = ${libs} -L$$(top_builddir)/idl -l${module} $${SALOME_LIBS} $$(FLIBS)
+lib${component}Exelib_la_LIBADD   = ${libs} -L$$(top_builddir)/idl -lSalomeIDL${module} $${SALOME_LIBS} $$(FLIBS)
 lib${component}Exelib_la_LDFLAGS = ${rlibs}
 """
 compoEXEMakefile=Template(compoEXEMakefile)
index 8c0819c9f69718b451e997a0a451a6df6548edc7..3fef424f8334275b7395df5ebe362c24dd6cadb1 100644 (file)
@@ -28,14 +28,47 @@ from cpp_tmpl import exeCPP, compoEXEMakefile, compoMakefile
 from yacstypes import corba_rtn_type
 
 class CPPComponent(Component):
-  def __init__(self, name, services=None, libs="", rlibs="", includes="",
-                     kind="lib", exe_path=None, sources=None, inheritedclass="",
-                     compodefs=""):
+  """
+   A :class:`CPPComponent` instance represents a C++ SALOME component with services given as a list of :class:`Service`
+   instances with the parameter *services*.
+
+   :param name: gives the name of the component.
+   :type name: str
+   :param services: the list of services (:class:`Service`) of the component.
+   :param kind: If it is given and has the value "exe", the component will be built as a standalone
+      component (executable or shell script). The default is to build the component as a dynamic library.
+   :param libs: gives all the libraries options to add when linking the generated component (-L...).
+   :param rlibs: gives all the runtime libraries options to add when linking the generated component (-R...).
+   :param includes: gives all the include options to add when compiling the generated component (-I...).
+   :param sources: gives all the external source files to add in the compilation step (list of paths).
+   :param exe_path: is only used when kind is "exe" and gives the path to the standalone component.
+   :param compodefs: can be used to add extra definition code in the component for example when using a base class
+      to define the component class by deriving it (see *inheritedclass* parameter)
+   :param inheritedclass: can be used to define a base class for the component. The base class can be defined in external
+      source or with the *compodefs* parameter. The value of the *inheritedclass* parameter is the name of the base class.
+   :param idls: can be used to add extra idl CORBA interfaces to the component. This parameter must gives a list of idl file
+      names that are added into the generated module (idl directory) and compiled with the generated idl of the module.
+   :param interfacedefs: can be used to add idl definitions (or includes of idl files) into the generated idl of the module.
+   :param inheritedinterface: can be used to make the component inherit an extra idl interface that has been included through
+      the *idls* and *interfacedefs* parameters. See the cppgui1 example for how to use these last parameters.
+   :param addmethods: is a C++ specific parameter that can be used to redefine a component method (DumpPython for example). This
+      parameter is a string that must contain the definition and implementation code of the method. See the cppgui1 example
+      for how to use it.
+
+   For example, the following call defines a standalone component named "mycompo" with one service s1 (it must have been defined before)::
+
+      >>> c1 = module_generator.CPPComponent('mycompo', services=[s1,], kind="exe",
+                                             exe_path="./launch.sh")
+  """
+  def __init__(self, name, services=None, libs="", rlibs="", includes="", kind="lib",
+                     exe_path=None, sources=None, inheritedclass="", compodefs="",
+                     idls=None,interfacedefs="",inheritedinterface="",addedmethods=""):
     self.exe_path = exe_path
-    Component.__init__(self, name, services, impl="CPP", libs=libs,
-                             rlibs=rlibs, includes=includes, kind=kind,
-                             sources=sources,inheritedclass=inheritedclass,
-                             compodefs=compodefs)
+    Component.__init__(self, name, services, impl="CPP", libs=libs, rlibs=rlibs,
+                             includes=includes, kind=kind, sources=sources,
+                             inheritedclass=inheritedclass, compodefs=compodefs, idls=idls,
+                             interfacedefs=interfacedefs, inheritedinterface=inheritedinterface,
+                             addedmethods=addedmethods)
 
   def validate(self):
     """ validate component definition parameters"""
@@ -102,6 +135,9 @@ AM_CFLAGS=$(SALOME_INCLUDES) -fexceptions
       service = "    %s %s(" % (corba_rtn_type(serv.ret,gen.module.name),serv.name)
       service = service+gen.makeArgs(serv)+");"
       services.append(service)
+
+    if self.addedmethods:
+      services.append(self.addedmethods)
     servicesdef = "\n".join(services)
 
     inheritedclass=self.inheritedclass
index 55d2bafbe9feeccc53e3a387e17ad08ee6843025..c466fe3b3f1f4ac48b20f3ce891e46207fdcfdb9 100644 (file)
@@ -29,6 +29,27 @@ else:
   f77Types = {"double":"double *", "long":"long *", "string":"const char *"}
 
 class F77Component(CPPComponent):
+  """
+   A :class:`F77Component` instance represents a Fortran SALOME component with services given as a list of :class:`Service`
+   instances with the parameter *services*.
+
+   :param name: gives the name of the component.
+   :type name: str
+   :param services: the list of services (:class:`Service`) of the component.
+   :param kind: If it is given and has the value "exe", the component will be built as a standalone
+      component (executable or shell script). The default is to build the component as a dynamic library.
+   :param libs: gives all the libraries options to add when linking the generated component (-L...).
+   :param rlibs: gives all the runtime libraries options to add when linking the generated component (-R...).
+   :param sources: gives all the external source files to add in the compilation step (list of paths).
+   :param exe_path: is only used when kind is "exe" and gives the path to the standalone component.
+
+   For example, the following call defines a Fortran component named "mycompo" with one service s1 (it must have been defined before).
+   This component is implemented as a dynamic library linked with a user's library "mylib"::
+
+      >>> c1 = module_generator.F77Component('mycompo', services=[s1,],
+                                                       libs="-lmylib -Lmydir")
+
+  """
   def __init__(self, name, services=None, libs="", rlibs="", 
                      kind="lib", exe_path=None, sources=None):
     CPPComponent.__init__(self, name, services, libs=libs, rlibs=rlibs, 
index fe889166a13f95636f42b05547f3b6fe64cdac7e..4fc94e577ec8228e29108579c4ca09dcf99fe98c 100644 (file)
@@ -61,6 +61,35 @@ def makedirs(namedir):
   os.makedirs(namedir)
 
 class Module(object):
+  """
+   A :class:`Module` instance represents a SALOME module that contains components given as a list of
+   component instances (:class:`CPPComponent` or :class:`PYComponent` or :class:`F77Component` or :class:`ASTERComponent`)
+   with the parameter *components*.
+
+   :param name: gives the name of the module. The SALOME source module
+      will be located in the <name_SRC> directory.
+   :type name: str
+   :param components: gives the list of components of the module.
+   :param prefix: is the path of the installation directory.
+   :param layout: If given and has the value "monodir", all components
+      will be generated in a single directory. The default is to generate each component in its
+      own directory.
+   :param doc: can be used to add an online documentation to the module. It must be a list of file names (sources, images, ...) that will be
+      used to build a sphinx documentation (see http://sphinx.pocoo.org, for more information). If not given, the Makefile.am
+      and the conf.py (sphinx configuration) files are generated. In this case, the file name extension of source files must be .rst.
+      See small examples in Examples/pygui1 and Examples/cppgui1.
+   :param gui: can be used to add a GUI to the module. It must be a list of file names (sources, images, qt designer files, ...).
+      If not given, the Makefile.am and SalomeApp.xml are generated. All image files are put in the resources directory of the module.
+      The GUI can be implemented in C++ (file name extension '.cxx') or in Python (file name extension '.py').
+      See small examples in Examples/pygui1 and Examples/cppgui1.
+
+   For example, the following call defines a module named "mymodule" with 2 components c1 and c2  (they must have been
+   defined before) that will be installed in the "install" directory::
+
+      >>> m = module_generator.Module('mymodule', components=[c1,c2],
+                                                  prefix="./install")
+
+  """
   def __init__(self, name, components=None, prefix="",layout="multidir", doc=None, gui=None):
     self.name = name
     self.components = components or []
@@ -94,7 +123,8 @@ class Module(object):
 class Component(object):
   def __init__(self, name, services=None, impl="PY", libs="", rlibs="",
                      includes="", kind="lib", sources=None,
-                     inheritedclass="",compodefs=""):
+                     inheritedclass="",compodefs="",
+                     idls=None,interfacedefs="",inheritedinterface="",addedmethods=""):
     self.name = name
     self.impl = impl
     self.kind = kind
@@ -105,6 +135,10 @@ class Component(object):
     self.sources = sources or []
     self.inheritedclass=inheritedclass
     self.compodefs=compodefs
+    self.idls=idls
+    self.interfacedefs=interfacedefs
+    self.inheritedinterface=inheritedinterface
+    self.addedmethods=addedmethods
 
   def validate(self):
     if self.impl not in ValidImpl:
@@ -129,8 +163,40 @@ class Component(object):
     return {}
 
 class Service(object):
-  def __init__(self, name, inport=None, outport=None, ret="void", instream=None, 
-                     outstream=None, parallel_instream=None, parallel_outstream=None, body="", defs="", impl_type="sequential"):
+  """
+   A :class:`Service` instance represents a component service with dataflow and datastream ports.
+
+   :param name: gives the name of the service.
+   :type name: str
+   :param inport: gives the list of input dataflow ports.
+   :param outport: gives the list of output dataflow ports. An input or output dataflow port is defined
+      by a 2-tuple (port name, data type name). The list of supported basic data types is: "double", "long", "string",
+      "dblevec", "stringvec", "intvec", "file" and "pyobj" only for Python services. Depending on the implementation
+      language, it is also possible to use some types from SALOME modules (see :ref:`yacstypes`).
+   :param ret: gives the type of the return parameter
+   :param instream: gives the list of input datastream ports.
+   :param outstream: gives the list of output datastream ports. An input or output datastream port is defined
+      by a 3-tuple (port name, data type name, mode name). The list of possible data types is: "CALCIUM_double", "CALCIUM_integer",
+      "CALCIUM_real", "CALCIUM_string", "CALCIUM_complex", "CALCIUM_logical", "CALCIUM_long". The mode can be "I" (iterative mode)
+      or "T" (temporal mode).
+   :param defs: gives the source code to insert in the definition section of the component. It can be C++ includes
+      or Python imports
+   :type defs: str
+   :param body: gives the source code to insert in the service call. It can be any C++
+      or Python code that fits well in the body of the service method.
+   :type body: str
+
+   For example, the following call defines a minimal Python service with one input dataflow port (name "a", type double)
+   and one input datastream port::
+
+      >>> s1 = module_generator.Service('myservice', inport=[("a","double"),],
+                                        instream=[("aa","CALCIUM_double","I")],
+                                        body="print a")
+
+
+  """
+  def __init__(self, name, inport=None, outport=None, ret="void", instream=None, outstream=None,
+                     parallel_instream=None, parallel_outstream=None, defs="", body="", impl_type="sequential"):
     self.name = name
     self.inport = inport or []
     self.outport = outport or []
@@ -170,7 +236,7 @@ class Service(object):
       if name in lports:
         raise Invalid("%s is already defined as a stream port" % name)
       lports.add(name)
-    
+
     for port in self.parallel_instream:
       name, typ = self.validateParallelStream(port)
       if name in lports:
@@ -225,6 +291,19 @@ class Service(object):
     return name, typ
 
 class Generator(object):
+  """
+   A :class:`Generator` instance take a :class:`Module` instance as its first parameter and can be used to generate the
+   SALOME source module, builds it, installs it and includes it in a SALOME application.
+
+   :param module: gives the :class:`Module` instance that will be used for the generation.
+   :param context: If given , its content is used to specify the prerequisites
+      environment file (key *"prerequisites"*) and the SALOME KERNEL installation directory (key *"kernel"*).
+   :type context: dict
+
+   For example, the following call creates a generator for the module m::
+
+      >>> g = module_generator.Generator(m,context)
+  """
   def __init__(self, module, context=None):
     self.module = module
     self.context = context or {}
@@ -236,7 +315,7 @@ class Generator(object):
       raise Invalid("To generate a module with GUI, you need to set the 'gui' parameter in the context dictionnary")
 
   def generate(self):
-    """generate SALOME module as described by module attribute"""
+    """Generate a SALOME source module"""
     module = self.module
     namedir = module.name+"_SRC"
     force = self.context.get("force")
@@ -409,12 +488,24 @@ echo "  Qt ..................... : $qt_ok"
                                                other_require=other_require,
                                               )
 
+    #if components have other idls
+    other_idls=""
+    other_sks=""
+    for compo in module.components:
+      if compo.idls:
+        for idl in compo.idls:
+          for fidl in glob.glob(idl):
+            other_idls=other_idls+os.path.basename(fidl) +" "
+            other_sks=other_sks+os.path.splitext(os.path.basename(fidl))[0]+"SK.cc "
+
     idlfiles={"Makefile.am":    idlMakefile.substitute(module=module.name,
                                                        PACO_BUILT_SOURCES=PACO_BUILT_SOURCES,
                                                        PACO_SALOMEINCLUDE_HEADERS=PACO_SALOMEINCLUDE_HEADERS,
                                                        PACO_INCLUDES=PACO_INCLUDES,
                                                        PACO_salomepython_DATA=PACO_salomepython_DATA,
-                                                       PACO_salomeidl_DATA=PACO_salomeidl_DATA),
+                                                       PACO_salomeidl_DATA=PACO_salomeidl_DATA,
+                                                       other_idls=other_idls,other_sks=other_sks,
+                                                       ),
               idlfile : self.makeidl(),
              }
     if paco:
@@ -433,6 +524,12 @@ echo "  Qt ..................... : $qt_ok"
         else:
           shutil.copyfile(src, os.path.join(namedir, "src", os.path.basename(src)))
 
+      if compo.idls:
+        #copy provided idl files in idl directory
+        for idl in compo.idls:
+          for fidl in glob.glob(idl):
+            shutil.copyfile(fidl, os.path.join(namedir, "idl", os.path.basename(fidl)))
+
     for m4file in ("check_Kernel.m4", "check_omniorb.m4",
                    "ac_linker_options.m4", "ac_cxx_option.m4",
                    "python.m4", "enable_pthreads.m4", "check_f77.m4",
@@ -440,6 +537,7 @@ echo "  Qt ..................... : $qt_ok"
                    "check_mpi.m4", "check_lam.m4", "check_openmpi.m4", "check_mpich.m4"):
       shutil.copyfile(os.path.join(self.kernel, "salome_adm", "unix", "config_files", m4file),
                       os.path.join(namedir, "adm_local", m4file))
+
     if self.module.gui:
       for m4file in ("check_GUI.m4", "check_qt.m4", "check_opengl.m4"):
         shutil.copyfile(os.path.join(self.gui, "adm_local", "unix", "config_files", m4file),
@@ -617,7 +715,9 @@ echo "  Qt ..................... : $qt_ok"
           service = "    void %s(" % serv.name
           service = service+",".join(params)+");"
           services.append(service)
+
         interfaces.append(parallel_interface.substitute(component=compo.name, services="\n".join(services)))
+
       else:
         services = []
         for serv in compo.services:
@@ -639,21 +739,29 @@ echo "  Qt ..................... : $qt_ok"
           service = "    %s %s(" % (idlTypes[serv.ret],serv.name)
           service = service+",".join(params)+") raises (SALOME::SALOME_Exception);"
           services.append(service)
+
         from hxxcompo import HXX2SALOMEComponent
         if isinstance(compo,HXX2SALOMEComponent):
           from hxx_tmpl import interfaceidlhxx
-         Inherited=""
-         if compo.use_medmem==True:
-             Inherited=", SALOME_MED::MED_Gen_Driver"
+          Inherited=""
+          if compo.use_medmem==True:
+              Inherited=", SALOME_MED::MED_Gen_Driver"
           interfaces.append(interfaceidlhxx.substitute(component=compo.name,inherited=Inherited, services="\n".join(services)))
         else:
-            interfaces.append(interface.substitute(component=compo.name, services="\n".join(services)))
+          inheritedinterface=""
+          if compo.inheritedinterface:
+            inheritedinterface=compo.inheritedinterface+","
+          interfaces.append(interface.substitute(component=compo.name, services="\n".join(services),inheritedinterface=inheritedinterface))
 
     #build idl includes for SALOME modules
     idldefs=""
     for mod in self.used_modules:
       idldefs = idldefs + salome_modules[mod]["idldefs"]
 
+    for compo in self.module.components:
+      if compo.interfacedefs:
+        idldefs = idldefs + compo.interfacedefs
+
     return idl.substitute(module=self.module.name, interfaces='\n'.join(interfaces),idldefs=idldefs)
 
   # For PaCO++
@@ -687,13 +795,13 @@ echo "  Qt ..................... : $qt_ok"
         self.makeFiles(content, filename)
 
   def bootstrap(self):
-    """execute module autogen.sh script: execution of libtool, autoconf, automake"""
+    """Execute the first build step (bootstrap autotools with autogen.sh script) : execution of libtool, autoconf, automake"""
     ier = os.system("cd %s_SRC;sh autogen.sh" % self.module.name)
     if ier != 0:
       raise Invalid("bootstrap has ended in error")
 
   def configure(self):
-    """execute module configure script with installation prefix (prefix attribute of module)"""
+    """Execute the second build step (configure) with installation prefix as given by the prefix attribute of module"""
     prefix = self.module.prefix
     paco = self.context.get("paco")
     mpi = self.context.get("mpi")
@@ -714,7 +822,7 @@ echo "  Qt ..................... : $qt_ok"
       raise Invalid("configure has ended in error")
 
   def make(self):
-    """execute module Makefile : make"""
+    """Execute the third build step (compile and link) : make"""
     make_command = "make "
     if self.makeflags:
       make_command += self.makeflags
@@ -723,14 +831,39 @@ echo "  Qt ..................... : $qt_ok"
       raise Invalid("make has ended in error")
 
   def install(self):
-    """install module: make install """
+    """Execute the installation step : make install """
     makedirs(self.module.prefix)
     ier = os.system("cd %s_SRC;make install" % self.module.name)
     if ier != 0:
       raise Invalid("install has ended in error")
 
   def make_appli(self, appliname, restrict=None, altmodules=None, resources=""):
-    """generate SALOME application"""
+    """
+   Create a SALOME application containing the module and preexisting SALOME modules.
+
+   :param appliname: is a string that gives the name of the application (directory path where the application
+      will be installed).
+   :type appliname: str
+   :param restrict: If given (a list of module names), only those SALOME modules will be included in the
+      application. The default is to include all modules that are located in the same directory as the KERNEL module and have
+      the same suffix (for example, if KERNEL directory is KERNEL_V5 and GEOM directory is GEOM_V5, GEOM module is automatically
+      included, except if restrict is used).
+   :param altmodules: can be used to add SALOME modules that cannot be managed with the precedent rule. This parameter
+      is a dict with a module name as the key and the installation path as the value.
+   :param resources: can be used to define an alternative resources catalog (path of the file).
+
+   For example, the following calls create a SALOME application with external modules and resources catalog in "appli" directory::
+
+     >>> g=Generator(m,context)
+     >>> g.generate()
+     >>> g.bootstrap()
+     >>> g.configure()
+     >>> g.make()
+     >>> g.install()
+     >>> g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR},
+                      resources="myresources.xml")
+
+    """
     makedirs(appliname)
 
     rootdir, kerdir = os.path.split(self.kernel)
index 74f29648775853255a0bec6895112910f7f3f807..2cc897bf5b8204565c342288a5d8bf264d7c15bd 100644 (file)
@@ -36,7 +36,7 @@ BUILT_SOURCES=${uisources}
 lib_LTLIBRARIES= lib${module}.la
 lib${module}_la_SOURCES = ${sources}
 lib${module}_la_CPPFLAGS = $$(SALOME_INCLUDES) $$(GUI_CXXFLAGS) $$(QT_INCLUDES) -I$$(top_builddir)/idl
-lib${module}_la_LIBADD   = -L$$(top_builddir)/idl -l${module}
+lib${module}_la_LIBADD   = -L$$(top_builddir)/idl -lSalomeIDL${module}
 
 salomeres_DATA =SalomeApp.xml ${other_sources}
 
index 411c936cf9111ba4c3a84d450109f943f9119001..3e6953d0f8a7a50f6b42b6de8d7a8f10b9741022 100644 (file)
@@ -35,13 +35,40 @@ def indent(text, prefix='    '):
   return join(lines, '\n')
 
 class PYComponent(Component):
-  def __init__(self, name, services=None, python_path=None, kind="lib",
-                     sources=None, inheritedclass="", compodefs=""):
+  """
+   A :class:`PYComponent` instance represents a Python SALOME component with services given as a list of :class:`Service`
+   instances with the parameter *services*.
+
+   :param name: gives the name of the component.
+   :type name: str
+   :param services: the list of services (:class:`Service`) of the component.
+   :param kind: If it is given and has the value "exe", the component will be built as a standalone
+      component (python executable). The default is to build the component as a python module.
+   :param sources: gives all the external Python source files to add in the component directory (list of paths).
+   :param python_path: If it is given (as a list of paths), all the paths are added to the python path (sys.path).
+   :param compodefs: can be used to add extra definition code in the component for example when using a base class
+      to define the component class by deriving it (see *inheritedclass* parameter)
+   :param inheritedclass: can be used to define a base class for the component. The base class can be defined in external
+      source or with the *compodefs* parameter. The value of the *inheritedclass* parameter is the name of the base class.
+   :param idls: can be used to add extra idl CORBA interfaces. This parameter must gives a list of idl file names that are
+      added into the generated module (idl directory) and compiled with the generated idl of the module.
+   :param interfacedefs: can be used to add idl definitions (or includes of idl files) into the generated idl of the module.
+   :param inheritedinterface: can be used to make the component inherit an extra idl interface that has been included through
+      the *idls* and *interfacedefs* parameters. See the pygui1 example for how to use these last parameters.
+
+   For example, the following call defines a Python component named "mycompo" with one service s1 (it must have been defined before)::
+
+      >>> c1 = module_generator.PYComponent('mycompo', services=[s1,],
+                                                       python_path="apath")
+
+  """
+  def __init__(self, name, services=None, kind="lib", sources=None, python_path=None,
+                     compodefs="", inheritedclass="", idls=None, interfacedefs="", inheritedinterface=""):
     """initialise component attributes"""
     self.python_path = python_path or []
-    Component.__init__(self, name, services, impl="PY", kind=kind,
-                             sources=sources, inheritedclass=inheritedclass,
-                             compodefs=compodefs)
+    Component.__init__(self, name, services, impl="PY", kind=kind, sources=sources,
+                             inheritedclass=inheritedclass, compodefs=compodefs,
+                             idls=idls,interfacedefs=interfacedefs,inheritedinterface=inheritedinterface)
 
   def validate(self):
     """validate component attributes"""
index 4996d6d4031af3c145af5cd7ba6228fa6b3b5bd8..e88595b3303240ce0956f9f2aeffb6d95311e089 100644 (file)
@@ -25,7 +25,7 @@ except:
 pyCompo="""
 import sys,traceback,os
 sys.path=sys.path+[${python_path}]
-import ${module}__POA
+import ${module}_ORB__POA
 import calcium
 import dsccalcium
 import SALOME
@@ -45,11 +45,11 @@ ${compodefs}
 ${servicesdef}
 #ENDDEF
 
-class ${component}(${inheritedclass} ${module}__POA.${component},dsccalcium.PyDSCComponent):
+class ${component}(${module}_ORB__POA.${component}, ${inheritedclass} dsccalcium.PyDSCComponent):
   '''
      To be identified as a SALOME component this Python class
      must have the same name as the component, inherit omniorb
-     class ${module}__POA.${component} and DSC class dsccalcium.PyDSCComponent
+     class ${module}_ORB__POA.${component} and DSC class dsccalcium.PyDSCComponent
      that implements DSC API.
   '''
   def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ):
index e0cd3559dff4bc23798580d7187c09191ee65087..8aa90f1bad396ace6212c3ad7bb9814bcea94b8c 100644 (file)
 corbaTypes = {"double":"CORBA::Double", "long":"CORBA::Long",
               "string":"const char*", "dblevec":"const %s::dblevec&",
               "stringvec":"const %s::stringvec&", "intvec":"const %s::intvec&",
-             "file":None, "boolean":"CORBA::Boolean", "void":"void"
+              "file":None, "boolean":"CORBA::Boolean", "void":"void"
              }
 
 corbaOutTypes = {"double":"CORBA::Double&", "long":"CORBA::Long&",
                  "string":"CORBA::String_out", "dblevec":"%s::dblevec_out",
                  "stringvec":"%s::stringvec_out", "intvec":"%s::intvec_out",
-                "file":None, "boolean":"CORBA::Boolean_out", "void":None
+                 "file":None, "boolean":"CORBA::Boolean_out", "void":None
                 }
+moduleTypes = {"double":"", "long":"", "string":"", "dblevec":"", "stringvec":"", "intvec":"", "file":"", "pyobj":"", "boolean":"", "void":"" }
+
+idlTypes = {"double":"double", "long":"long", "string":"string", "dblevec":"dblevec", "stringvec":"stringvec", "intvec":"intvec", 
+            "file":"", "boolean":"boolean", "void":"void" }
 
 corbaRtnTypes = {"double":"CORBA::Double", "long":"CORBA::Long",
                  "string":"char*", "dblevec":"%s::dblevec*",
                  "stringvec":"%s::stringvec*", "intvec":"%s::intvec*",
-                "file":None, "boolean":"CORBA::Boolean", "void":"void"
+                 "file":None, "boolean":"CORBA::Boolean", "void":"void"
                 }
 
-moduleTypes = {"double":"", "long":"", "string":"", "dblevec":"", "stringvec":"", "intvec":"", "file":"", "boolean":"", "void":"" }
 
-idlTypes = {"double":"double", "long":"long", "string":"string", "dblevec":"dblevec", "stringvec":"stringvec", "intvec":"intvec", "file":"", "boolean":"boolean", "void":"void" }
 
 def corba_in_type(typ, module):
   if corbaTypes[typ].count("%s")>0:
-    return corbaTypes[typ] % module
+    return corbaTypes[typ] % (module+"_ORB")
   else:
     return corbaTypes[typ]
 
 def corba_out_type(typ, module):
   if corbaOutTypes[typ].count("%s")>0:
-    return corbaOutTypes[typ] % module
+    return corbaOutTypes[typ] % (module+"_ORB")
   else:
     return corbaOutTypes[typ]
 
 def corba_rtn_type(typ, module):
   if corbaRtnTypes[typ].count("%s")>0:
-    return corbaRtnTypes[typ] % module
+    return corbaRtnTypes[typ] % (module+"_ORB")
   else:
     return corbaRtnTypes[typ]
 
index 6bc29e722b3cd112b4a0b333f040f699bf9c3757..d71293d6616dde690325a1646f02b3fb06106c35 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,7 @@
 
 from distutils.core import setup
 setup(name='YACSGEN',
-      version='5.1.4',
+      version='5.1.5',
       author='C. Caremoli',
       packages=['module_generator'],
      )