Salome HOME
updated copyright message
[tools/yacsgen.git] / module_generator / cata_tmpl.py
1 # Copyright (C) 2009-2023  EDF
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, or (at your option) any later version.
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 module_generator.compat import Template,set
24
25 # CORBA idl
26
27 idl="""
28 #ifndef _${module}_IDL_
29 #define _${module}_IDL_
30
31 #include "SALOME_Exception.idl"
32 #include "SALOME_Component.idl"
33 #include "SALOME_Comm.idl"
34
35 ${idldefs}
36
37 module ${module}_ORB
38 {
39 typedef sequence<string> stringvec;
40 typedef sequence<double> dblevec;
41 typedef sequence<long> intvec;
42 typedef Engines::dataref dataref;
43
44 ${interfaces}
45 };
46
47 #endif
48 """
49 idl=Template(idl)
50
51 interface="""
52   interface ${component}:${inheritedinterface} Engines::Superv_Component
53   {
54 ${services}
55   };
56 """
57 interface=Template(interface)
58
59 parallel_interface="""
60 interface ${component} : Engines::Parallel_DSC
61   {
62 ${services}
63   };
64 """
65 parallel_interface=Template(parallel_interface)
66
67 xml="""\
68 <?xml version="1.0"?>
69 <!-- YACSGEN -->
70
71 <PaCO_Interface_description>
72   <Module>
73     <Name>${module}_ORB</Name>
74 ${interfaces}
75   </Module>
76 </PaCO_Interface_description>
77 """
78 xml = Template(xml)
79
80 xml_interface="""\
81     <Interface>
82       <Name>${component}</Name>
83 ${xml_services}
84     </Interface>"""
85 xml_interface = Template(xml_interface)
86
87 xml_service = """\
88       <Method>
89         <Name>${service_name}</Name>
90         <Type>distributed</Type>
91       </Method>"""
92 xml_service = Template(xml_service)
93
94 # PACO Part
95 idlMakefilePaCO_BUILT_SOURCES = "${module}PaCO.cxx "
96 idlMakefilePaCO_nodist_salomeinclude_HEADERS = "${module}PaCO.hxx "
97 idlMakefilePaCO_BUILT_SOURCES = Template(idlMakefilePaCO_BUILT_SOURCES)
98 idlMakefilePaCO_nodist_salomeinclude_HEADERS = Template(idlMakefilePaCO_nodist_salomeinclude_HEADERS)
99 idlMakefilePACO_INCLUDES = "-I@PACOPATH@/idl"
100 idlMakefilePACO_salomepython_DATA = "${module}PaCO_idl.py"
101 idlMakefilePACO_salomepython_DATA = Template(idlMakefilePACO_salomepython_DATA)
102 idlMakefilePACO_salomeidl_DATA = "${module}PaCO.idl"
103 idlMakefilePACO_salomeidl_DATA = Template(idlMakefilePACO_salomeidl_DATA)
104
105 #SALOME catalog
106
107 catalog="""<?xml version='1.0' encoding='us-ascii' ?>
108
109 <!-- XML component catalog -->
110 <begin-catalog>
111
112 <!-- Path prefix information -->
113
114 <path-prefix-list>
115 </path-prefix-list>
116
117 <!-- Commonly used types  -->
118 <type-list>
119   <objref name="pyobj" id="python:obj:1.0"/>
120   <objref name="file" id="file"/>
121 </type-list>
122
123 <!-- Component list -->
124 <component-list>
125 ${components}
126 </component-list>
127 </begin-catalog>
128 """
129 catalog=Template(catalog)
130
131 cataCompo="""
132   <component>
133         <!-- Component identification -->
134         <component-name>${component}</component-name>
135         <component-username>${component}</component-username>
136         <component-type>Data</component-type>
137         <component-author>${author}</component-author>
138         <component-version>1.0</component-version>
139         <component-comment></component-comment>
140         <component-multistudy>0</component-multistudy>
141         <component-impltype>${impltype}</component-impltype>
142         <component-implname>${implname}</component-implname>
143         <component-interface-list>
144             <component-interface-name>${component}</component-interface-name>
145             <component-interface-comment></component-interface-comment>
146             <component-service-list>
147 ${services}
148             </component-service-list>
149         </component-interface-list>
150   </component>"""
151 cataCompo=Template(cataCompo)
152
153 cataService="""                <component-service>
154                     <!-- service-identification -->
155                     <service-name>${service}</service-name>
156                     <service-author>${author}</service-author>
157                     <service-version>1.0</service-version>
158                     <service-comment></service-comment>
159                     <service-by-default>0</service-by-default>
160                     <!-- service-connexion -->
161                     <inParameter-list>
162 ${inparams}
163                     </inParameter-list>
164                     <outParameter-list>
165 ${outparams}
166                     </outParameter-list>
167                     <DataStream-list>
168 ${datastreams}
169                     </DataStream-list>
170                 </component-service>"""
171 cataService=Template(cataService)
172
173 cataInparam="""                        <inParameter>
174                           <inParameter-name>${name}</inParameter-name>
175                           <inParameter-type>${type}</inParameter-type>
176                        </inParameter>"""
177 cataInparam=Template(cataInparam)
178
179 cataOutparam="""                        <outParameter>
180                           <outParameter-name>${name}</outParameter-name>
181                           <outParameter-type>${type}</outParameter-type>
182                        </outParameter>"""
183 cataOutparam=Template(cataOutparam)
184
185 cataInStream="""                       <inParameter>
186                           <inParameter-name>${name}</inParameter-name>
187                           <inParameter-type>${type}</inParameter-type>
188                           <inParameter-dependency>${dep}</inParameter-dependency>
189                        </inParameter>"""
190 cataInStream=Template(cataInStream)
191
192 cataOutStream="""                       <outParameter>
193                           <outParameter-name>${name}</outParameter-name>
194                           <outParameter-type>${type}</outParameter-type>
195                           <outParameter-dependency>${dep}</outParameter-dependency>
196                        </outParameter>"""
197 cataOutStream=Template(cataOutStream)
198
199 cataInParallelStream="""                       <inParameter>
200                           <inParameter-name>${name}</inParameter-name>
201                           <inParameter-type>${type}</inParameter-type>
202                        </inParameter>"""
203 cataInParallelStream=Template(cataInParallelStream)
204
205 cataOutParallelStream="""                       <outParameter>
206                           <outParameter-name>${name}</outParameter-name>
207                           <outParameter-type>${type}</outParameter-type>
208                        </outParameter>"""
209 cataOutParallelStream=Template(cataOutParallelStream)