1 # Copyright (C) 2009-2022 EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #import context from ..
23 exec(compile(open("../context.py").read(), "../context.py", 'exec'))
25 from module_generator import Generator,Module,Service,CPPComponent,PYComponent,add_type,add_module
27 #overload GEOM_Object definition
28 add_type("GEOM_Object", "GEOM::GEOM_Object_ptr", "GEOM::GEOM_Object_out", "GEOM", "GEOM::GEOM_Object","GEOM::GEOM_Object_ptr")
39 std::cerr << "Parameter:" << std::endl;
40 std::cerr << "a: " << a.name << "=" << a.value << std::endl;
41 std::cerr << "" << std::endl;
44 std::cerr << "ParameterList:" << std::endl;
45 for(CORBA::ULong i = 0;i<b.length();i++)
46 std::cerr << "b["<<i<<"]:"<<b[i].name <<"="<<b[i].value << std::endl;
47 std::cerr << "" << std::endl;
50 std::cerr << "Variable:" << std::endl;
51 for(CORBA::ULong i = 0;i<c.length();i++)
52 std::cerr << "c["<<i<<"]="<<c[i] << std::endl;
53 std::cerr << "" << std::endl;
56 std::cerr << "VariableSequence:" << std::endl;
57 for(CORBA::ULong i = 0;i<d.length();i++)
58 for(CORBA::ULong j = 0;j<d[i].length();j++)
59 std::cerr << "d["<<i<<"]["<< j<< "]="<<d[i][j] << std::endl;
60 std::cerr << "" << std::endl;
63 std::cerr << "StateSequence:" << std::endl;
64 for(CORBA::ULong i = 0;i<d2.length();i++)
65 for(CORBA::ULong j = 0;j<d2[i].length();j++)
66 for(CORBA::ULong k = 0;k<d2[i][j].length();k++)
67 std::cerr << "d2["<<i<<"]["<< j<< "]["<<k<<"]="<<d2[i][j][k] << std::endl;
68 std::cerr << "" << std::endl;
71 std::cerr << "TimeSequence:" << std::endl;
72 for(CORBA::ULong i = 0;i<d3.length();i++)
73 for(CORBA::ULong j = 0;j<d3[i].length();j++)
74 for(CORBA::ULong k = 0;k<d3[i][j].length();k++)
75 for(CORBA::ULong l = 0;l<d3[i][j][k].length();l++)
76 std::cerr << "d3["<<i<<"]["<< j<< "]["<<k<<"]["<<l<<"]="<<d3[i][j][k][l] << std::endl;
77 std::cerr << "" << std::endl;
80 for(CORBA::ULong i = 0;i<f.inputVarList.length();i++)
81 std::cerr << "f.inputVarList["<<i<<"]="<<f.inputVarList[i] << std::endl;
82 for(CORBA::ULong i = 0;i<f.outputVarList.length();i++)
83 std::cerr << "f.outputVarList["<<i<<"]="<<f.outputVarList[i] << std::endl;
84 for(CORBA::ULong i = 0;i<f.inputValues.length();i++)
85 for(CORBA::ULong j = 0;j<f.inputValues[i].length();j++)
86 for(CORBA::ULong k = 0;k<f.inputValues[i][j].length();k++)
87 for(CORBA::ULong l = 0;l<f.inputValues[i][j][k].length();l++)
88 std::cerr << "f.inputValues["<<i<<"]["<< j<< "]["<<k<<"]["<<l<<"]="<<f.inputValues[i][j][k][l] << std::endl;
89 for(CORBA::ULong i = 0;i<f.specificParameters.length();i++)
90 std::cerr << "f.specificParameters["<<i<<"]:"<<f.specificParameters[i].name <<"="<<f.specificParameters[i].value << std::endl;
93 for(CORBA::ULong i = 0;i<g.outputValues.length();i++)
94 for(CORBA::ULong j = 0;j<g.outputValues[i].length();j++)
95 for(CORBA::ULong k = 0;k<g.outputValues[i][j].length();k++)
96 for(CORBA::ULong l = 0;l<g.outputValues[i][j][k].length();l++)
97 std::cerr << "g.outputValues["<<i<<"]["<< j<< "]["<<k<<"]["<<l<<"]="<<g.outputValues[i][j][k][l] << std::endl;
101 aa=new SALOME_TYPES::Parameter;
102 aa->name=CORBA::string_dup(a.name);
103 aa->value=CORBA::string_dup(a.value);
104 std::cerr << "aa: " << aa->name << "=" << aa->value << std::endl;
106 ab=new SALOME_TYPES::ParameterList;
107 ac= new SALOME_TYPES::Variable;
108 ad= new SALOME_TYPES::VariableSequence;
109 ad2= new SALOME_TYPES::StateSequence;
110 ad3= new SALOME_TYPES::TimeSequence;
111 ae= new SALOME_TYPES::VarList;
112 af= new SALOME_TYPES::ParametricInput;
113 ag= new SALOME_TYPES::ParametricOutput;
117 std::cerr << "service s2 C++ component" << std::endl;
118 aa=GEOM::GEOM_Object::_duplicate(a);
122 c1=CPPComponent("compo1",services=[
123 Service("s1",inport=[("a","SALOME_TYPES/Parameter"),
124 ("b","SALOME_TYPES/ParameterList"),
125 ("c","SALOME_TYPES/Variable"),
126 ("d","SALOME_TYPES/VariableSequence"),
127 ("d2","SALOME_TYPES/StateSequence"),
128 ("d3","SALOME_TYPES/TimeSequence"),
129 ("e","SALOME_TYPES/VarList"),
130 ("f","SALOME_TYPES/ParametricInput"),
131 ("g","SALOME_TYPES/ParametricOutput"),
133 outport=[("aa","SALOME_TYPES/Parameter"),
134 ("ab","SALOME_TYPES/ParameterList"),
135 ("ac","SALOME_TYPES/Variable"),
136 ("ad","SALOME_TYPES/VariableSequence"),
137 ("ad2","SALOME_TYPES/StateSequence"),
138 ("ad3","SALOME_TYPES/TimeSequence"),
139 ("ae","SALOME_TYPES/VarList"),
140 ("af","SALOME_TYPES/ParametricInput"),
141 ("ag","SALOME_TYPES/ParametricOutput"),
145 Service("s2",inport=[("a","GEOM_Object"),],outport=[("aa","GEOM_Object"),],body=s2body,),
149 pydefs="""import SALOME_TYPES"""
152 print (a,b,c,d,d2,d3,e,f,g)
153 aa=SALOME_TYPES.Parameter(name="a",value="45.")
160 af=SALOME_TYPES.ParametricInput(inputVarList=ae,outputVarList=ae, inputValues=[[[[1,2,3]]]],specificParameters=[])
161 ag=SALOME_TYPES.ParametricOutput(outputValues=[[[[1,2,3]]]], specificOutputInfos=[], returnCode=1, errorMessage="error")
162 print (aa,ab,ac,ad,ad2,ad3,ae,af,ag)
166 print ("service s2 python component")
171 c2=PYComponent("compo2",services=[
172 Service("s1",inport=[("a","SALOME_TYPES/Parameter"),
173 ("b","SALOME_TYPES/ParameterList"),
174 ("c","SALOME_TYPES/Variable"),
175 ("d","SALOME_TYPES/VariableSequence"),
176 ("d2","SALOME_TYPES/StateSequence"),
177 ("d3","SALOME_TYPES/TimeSequence"),
178 ("e","SALOME_TYPES/VarList"),
179 ("f","SALOME_TYPES/ParametricInput"),
180 ("g","SALOME_TYPES/ParametricOutput"),
182 outport=[("aa","SALOME_TYPES/Parameter"),
183 ("ab","SALOME_TYPES/ParameterList"),
184 ("ac","SALOME_TYPES/Variable"),
185 ("ad","SALOME_TYPES/VariableSequence"),
186 ("ad2","SALOME_TYPES/StateSequence"),
187 ("ad3","SALOME_TYPES/TimeSequence"),
188 ("ae","SALOME_TYPES/VarList"),
189 ("af","SALOME_TYPES/ParametricInput"),
190 ("ag","SALOME_TYPES/ParametricOutput"),
192 body=pybody,defs=pydefs,
194 Service("s2",inport=[("a","GEOM_Object"),],outport=[("aa","GEOM_Object"),],body=s2pybody,),
199 g=Generator(Module("mymodule",components=[c1,c2],prefix="./install"),context)
204 g.make_appli("appli", restrict=["KERNEL"],
205 altmodules={"GUI":GUI_ROOT_DIR,
206 "YACS":YACS_ROOT_DIR,
207 "GEOM":GEOM_ROOT_DIR},
208 sys_modules=SYS_MODULES)