Salome HOME
Copyrights update 2015.
[tools/yacsgen.git] / module_generator / cata_tmpl.py
1 # Copyright (C) 2009-2015  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, 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 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 # PACO Part
98 idlMakefilePaCO_BUILT_SOURCES = "${module}PaCO.cxx "
99 idlMakefilePaCO_nodist_salomeinclude_HEADERS = "${module}PaCO.hxx "
100 idlMakefilePaCO_BUILT_SOURCES = Template(idlMakefilePaCO_BUILT_SOURCES)
101 idlMakefilePaCO_nodist_salomeinclude_HEADERS = Template(idlMakefilePaCO_nodist_salomeinclude_HEADERS)
102 idlMakefilePACO_INCLUDES = "-I@PACOPATH@/idl"
103 idlMakefilePACO_salomepython_DATA = "${module}PaCO_idl.py"
104 idlMakefilePACO_salomepython_DATA = Template(idlMakefilePACO_salomepython_DATA)
105 idlMakefilePACO_salomeidl_DATA = "${module}PaCO.idl"
106 idlMakefilePACO_salomeidl_DATA = Template(idlMakefilePACO_salomeidl_DATA)
107
108 #SALOME catalog
109
110 catalog="""<?xml version='1.0' encoding='us-ascii' ?>
111
112 <!-- XML component catalog -->
113 <begin-catalog>
114
115 <!-- Path prefix information -->
116
117 <path-prefix-list>
118 </path-prefix-list>
119
120 <!-- Commonly used types  -->
121 <type-list>
122   <objref name="pyobj" id="python:obj:1.0"/>
123   <objref name="file" id="file"/>
124 </type-list>
125
126 <!-- Component list -->
127 <component-list>
128 ${components}
129 </component-list>
130 </begin-catalog>
131 """
132 catalog=Template(catalog)
133
134 cataCompo="""
135   <component>
136         <!-- Component identification -->
137         <component-name>${component}</component-name>
138         <component-username>${component}</component-username>
139         <component-type>Data</component-type>
140         <component-author>${author}</component-author>
141         <component-version>1.0</component-version>
142         <component-comment></component-comment>
143         <component-multistudy>0</component-multistudy>
144         <component-impltype>${impltype}</component-impltype>
145         <component-implname>${implname}</component-implname>
146         <component-interface-list>
147             <component-interface-name>${component}</component-interface-name>
148             <component-interface-comment></component-interface-comment>
149             <component-service-list>
150 ${services}
151             </component-service-list>
152         </component-interface-list>
153   </component>"""
154 cataCompo=Template(cataCompo)
155
156 cataService="""                <component-service>
157                     <!-- service-identification -->
158                     <service-name>${service}</service-name>
159                     <service-author>${author}</service-author>
160                     <service-version>1.0</service-version>
161                     <service-comment></service-comment>
162                     <service-by-default>0</service-by-default>
163                     <!-- service-connexion -->
164                     <inParameter-list>
165 ${inparams}
166                     </inParameter-list>
167                     <outParameter-list>
168 ${outparams}
169                     </outParameter-list>
170                     <DataStream-list>
171 ${datastreams}
172                     </DataStream-list>
173                 </component-service>"""
174 cataService=Template(cataService)
175
176 cataInparam="""                        <inParameter>
177                           <inParameter-name>${name}</inParameter-name>
178                           <inParameter-type>${type}</inParameter-type>
179                        </inParameter>"""
180 cataInparam=Template(cataInparam)
181
182 cataOutparam="""                        <outParameter>
183                           <outParameter-name>${name}</outParameter-name>
184                           <outParameter-type>${type}</outParameter-type>
185                        </outParameter>"""
186 cataOutparam=Template(cataOutparam)
187
188 cataInStream="""                       <inParameter>
189                           <inParameter-name>${name}</inParameter-name>
190                           <inParameter-type>${type}</inParameter-type>
191                           <inParameter-dependency>${dep}</inParameter-dependency>
192                        </inParameter>"""
193 cataInStream=Template(cataInStream)
194
195 cataOutStream="""                       <outParameter>
196                           <outParameter-name>${name}</outParameter-name>
197                           <outParameter-type>${type}</outParameter-type>
198                           <outParameter-dependency>${dep}</outParameter-dependency>
199                        </outParameter>"""
200 cataOutStream=Template(cataOutStream)
201
202 cataInParallelStream="""                       <inParameter>
203                           <inParameter-name>${name}</inParameter-name>
204                           <inParameter-type>${type}</inParameter-type>
205                        </inParameter>"""
206 cataInParallelStream=Template(cataInParallelStream)
207
208 cataOutParallelStream="""                       <outParameter>
209                           <outParameter-name>${name}</outParameter-name>
210                           <outParameter-type>${type}</outParameter-type>
211                        </outParameter>"""
212 cataOutParallelStream=Template(cataOutParallelStream)