Salome HOME
Merge from V6_main 01/04/2013
[tools/yacsgen.git] / module_generator / cata_tmpl.py
1 # Copyright (C) 2009-2013  EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 try:
21   from string import Template
22 except:
23   from compat import Template,set
24
25 # CORBA idl
26
27 idl="""
28 #ifndef _${module}_IDL_
29 #define _${module}_IDL_
30
31 #include "DSC_Engines.idl"
32 #include "SALOME_Exception.idl"
33 #include "SALOME_PACOExtension.idl"
34 #include "SALOME_Component.idl"
35 #include "SALOME_Comm.idl"
36 #include "SALOME_Parametric.idl"
37
38 ${idldefs}
39
40 module ${module}_ORB
41 {
42 typedef sequence<string> stringvec;
43 typedef sequence<double> dblevec;
44 typedef sequence<long> intvec;
45 typedef Engines::dataref dataref;
46
47 ${interfaces}
48 };
49
50 #endif
51 """
52 idl=Template(idl)
53
54 interface="""
55   interface ${component}:${inheritedinterface} Engines::Superv_Component
56   {
57 ${services}
58   };
59 """
60 interface=Template(interface)
61
62 parallel_interface="""
63 interface ${component} : Engines::Parallel_DSC
64   {
65 ${services}
66   };
67 """
68 parallel_interface=Template(parallel_interface)
69
70 xml="""\
71 <?xml version="1.0"?>
72 <!-- YACSGEN -->
73
74 <PaCO_Interface_description>
75   <Module>
76     <Name>${module}_ORB</Name>
77 ${interfaces}
78   </Module>
79 </PaCO_Interface_description>
80 """
81 xml = Template(xml)
82
83 xml_interface="""\
84     <Interface>
85       <Name>${component}</Name>
86 ${xml_services}
87     </Interface>"""
88 xml_interface = Template(xml_interface)
89
90 xml_service = """\
91       <Method>
92         <Name>${service_name}</Name>
93         <Type>distributed</Type>
94       </Method>"""
95 xml_service = Template(xml_service)
96
97 idlMakefile="""
98 include $$(top_srcdir)/adm_local/make_common_starter.am
99
100 BUILT_SOURCES = ${module}SK.cc ${PACO_BUILT_SOURCES} ${other_sks}
101 IDL_FILES=${module}.idl ${other_idls}
102
103 lib_LTLIBRARIES = libSalomeIDL${module}.la
104 salomeidl_DATA = $$(IDL_FILES) ${PACO_salomeidl_DATA}
105 libSalomeIDL${module}_la_SOURCES      =
106 nodist_libSalomeIDL${module}_la_SOURCES = ${module}SK.cc ${other_sks}
107 nodist_salomeinclude_HEADERS= ${module}.hh ${PACO_SALOMEINCLUDE_HEADERS}
108 libSalomeIDL${module}_la_CXXFLAGS     = -I.  $$(SALOME_INCLUDES)
109 libSalomeIDL${module}_la_LIBADD     = $$(SALOME_IDL_LIBS)
110 ##########################################################
111 %SK.cc %.hh : %.idl
112 \t$$(OMNIORB_IDL) -bcxx $$(OMNIORB_IDLCXXFLAGS) $$(IDL_INCLUDES) $$<
113 %_idl.py : %.idl
114 \t$$(OMNIORB_IDL) $$(OMNIORB_IDLPYFLAGS) $$(IDL_INCLUDES) ${PACO_INCLUDES} $$<
115 %PaCO.hxx %PaCO.cxx : %.idl %.xml
116 \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
117
118 CLEANFILES = *.hh *SK.cc *.py *.hxx *.cxx
119
120 EXTRA_DIST = $$(IDL_FILES)
121
122 install-data-local: $$(IDL_FILES)
123 \t$$(INSTALL) -d  $$(DESTDIR)$$(salomepythondir)
124 \tls $$^ | while read file; do \\
125 \t$$(OMNIORB_IDL) $$(OMNIORB_IDLPYFLAGS) $$(IDL_INCLUDES) -C$$(DESTDIR)$$(salomepythondir) $$$$file ; \\
126 \tdone
127
128 uninstall-local:
129 \trm -rf $$(DESTDIR)$$(salomepythondir)/*
130
131 """
132 idlMakefile=Template(idlMakefile)
133
134 # PACO Part
135 idlMakefilePaCO_BUILT_SOURCES = "${module}PaCO.cxx "
136 idlMakefilePaCO_nodist_salomeinclude_HEADERS = "${module}PaCO.hxx "
137 idlMakefilePaCO_BUILT_SOURCES = Template(idlMakefilePaCO_BUILT_SOURCES)
138 idlMakefilePaCO_nodist_salomeinclude_HEADERS = Template(idlMakefilePaCO_nodist_salomeinclude_HEADERS)
139 idlMakefilePACO_INCLUDES = "-I@PACOPATH@/idl"
140 idlMakefilePACO_salomepython_DATA = "${module}PaCO_idl.py"
141 idlMakefilePACO_salomepython_DATA = Template(idlMakefilePACO_salomepython_DATA)
142 idlMakefilePACO_salomeidl_DATA = "${module}PaCO.idl"
143 idlMakefilePACO_salomeidl_DATA = Template(idlMakefilePACO_salomeidl_DATA)
144
145 #SALOME catalog
146
147 catalog="""<?xml version='1.0' encoding='us-ascii' ?>
148
149 <!-- XML component catalog -->
150 <begin-catalog>
151
152 <!-- Path prefix information -->
153
154 <path-prefix-list>
155 </path-prefix-list>
156
157 <!-- Commonly used types  -->
158 <type-list>
159   <objref name="pyobj" id="python:obj:1.0"/>
160   <objref name="file" id="file"/>
161 </type-list>
162
163 <!-- Component list -->
164 <component-list>
165 ${components}
166 </component-list>
167 </begin-catalog>
168 """
169 catalog=Template(catalog)
170
171 cataCompo="""
172   <component>
173         <!-- Component identification -->
174         <component-name>${component}</component-name>
175         <component-username>${component}</component-username>
176         <component-type>Data</component-type>
177         <component-author>${author}</component-author>
178         <component-version>1.0</component-version>
179         <component-comment></component-comment>
180         <component-multistudy>0</component-multistudy>
181         <component-impltype>${impltype}</component-impltype>
182         <component-implname>${implname}</component-implname>
183         <component-interface-list>
184             <component-interface-name>${component}</component-interface-name>
185             <component-interface-comment></component-interface-comment>
186             <component-service-list>
187 ${services}
188             </component-service-list>
189         </component-interface-list>
190   </component>"""
191 cataCompo=Template(cataCompo)
192
193 cataService="""                <component-service>
194                     <!-- service-identification -->
195                     <service-name>${service}</service-name>
196                     <service-author>${author}</service-author>
197                     <service-version>1.0</service-version>
198                     <service-comment></service-comment>
199                     <service-by-default>0</service-by-default>
200                     <!-- service-connexion -->
201                     <inParameter-list>
202 ${inparams}
203                     </inParameter-list>
204                     <outParameter-list>
205 ${outparams}
206                     </outParameter-list>
207                     <DataStream-list>
208 ${datastreams}
209                     </DataStream-list>
210                 </component-service>"""
211 cataService=Template(cataService)
212
213 cataInparam="""                        <inParameter>
214                           <inParameter-name>${name}</inParameter-name>
215                           <inParameter-type>${type}</inParameter-type>
216                        </inParameter>"""
217 cataInparam=Template(cataInparam)
218
219 cataOutparam="""                        <outParameter>
220                           <outParameter-name>${name}</outParameter-name>
221                           <outParameter-type>${type}</outParameter-type>
222                        </outParameter>"""
223 cataOutparam=Template(cataOutparam)
224
225 cataInStream="""                       <inParameter>
226                           <inParameter-name>${name}</inParameter-name>
227                           <inParameter-type>${type}</inParameter-type>
228                           <inParameter-dependency>${dep}</inParameter-dependency>
229                        </inParameter>"""
230 cataInStream=Template(cataInStream)
231
232 cataOutStream="""                       <outParameter>
233                           <outParameter-name>${name}</outParameter-name>
234                           <outParameter-type>${type}</outParameter-type>
235                           <outParameter-dependency>${dep}</outParameter-dependency>
236                        </outParameter>"""
237 cataOutStream=Template(cataOutStream)
238
239 cataInParallelStream="""                       <inParameter>
240                           <inParameter-name>${name}</inParameter-name>
241                           <inParameter-type>${type}</inParameter-type>
242                        </inParameter>"""
243 cataInParallelStream=Template(cataInParallelStream)
244
245 cataOutParallelStream="""                       <outParameter>
246                           <outParameter-name>${name}</outParameter-name>
247                           <outParameter-type>${type}</outParameter-type>
248                        </outParameter>"""
249 cataOutParallelStream=Template(cataOutParallelStream)