1 # Copyright (C) 2009-2023 EDF
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
20 #import context from ..
21 exec(compile(open("../context.py").read(), "../context.py", 'exec'))
24 from module_generator import *
27 #include "myinterface.idl"
33 class A: public virtual POA_Idl_A
36 void createObject(::SALOMEDS::Study_ptr theStudy, const char* name){};
39 virtual SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile){return 0;};
40 virtual SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile){return 0;};
41 virtual bool Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile){return 0;};
42 virtual bool LoadASCII(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile){return 0;};
43 virtual void Close(SALOMEDS::SComponent_ptr IORSComponent){};
44 virtual char* ComponentDataType(){return (char*)"cppcompos";};
45 virtual char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, const char* IORString, CORBA::Boolean isMultiFile, CORBA::Boolean isASCII){return 0;};
46 virtual char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, const char* aLocalPersistentID, CORBA::Boolean isMultiFile,
47 CORBA::Boolean isASCII){return 0;};
48 virtual bool CanPublishInStudy(CORBA::Object_ptr theIOR){return 0;};
49 virtual SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::SObject_ptr theSObject,CORBA::Object_ptr theObject,
50 const char* theName){return 0;};
51 virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject){return 0;};
52 virtual SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID){return 0;};
53 virtual CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID){return 0;};
54 virtual SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, CORBA::Long theObjectID, SALOMEDS::SObject_ptr theObject){return 0;};
61 Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
62 CORBA::Boolean isPublished,
63 CORBA::Boolean isMultiFile,
64 CORBA::Boolean& isValidScript)
66 std::cerr << "je suis dans le dump:" << __LINE__ << std::endl;
67 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
68 if(CORBA::is_nil(aStudy))
69 return new Engines::TMPFile(0);
71 SALOMEDS::SObject_var aSO = aStudy->FindComponent("cppcompos");
72 if(CORBA::is_nil(aSO))
73 return new Engines::TMPFile(0);
75 std::string Script = "import cppcompos_ORB\n";
76 Script += "import salome\n";
77 Script += "compo = salome.lcc.FindOrLoadComponent('FactoryServer','cppcompos')\n";
78 Script += "def RebuildData(theStudy):\n";
79 Script += " compo.SetCurrentStudy(theStudy)\n";
80 const char* aScript=Script.c_str();
82 char* aBuffer = new char[strlen(aScript)+1];
83 strcpy(aBuffer, aScript);
84 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
85 int aBufferSize = strlen(aBuffer)+1;
86 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1);
88 return aStreamFile._retn();
95 std::cerr << "a: " << a << std::endl;
96 std::cerr << "b: " << b << std::endl;
98 std::cerr << "c: " << c << std::endl;
100 c1=CPPComponent("cppcompos",services=[
101 Service("s1",inport=[("a","double"),("b","double")],
102 outport=[("c","double")],
103 defs="//def1",body=body,
107 interfacedefs=idldefs,
108 inheritedinterface="Idl_A",
111 addedmethods=compomethods,
114 modul=Module("cppcompos",components=[c1],prefix="./install",
116 gui=["cppcomposGUI.cxx","cppcomposGUI.h","demo.ui","*.png"],
119 g=Generator(modul,context)
121 #g.configure("-DTBB_INCLUDE_DIR=/opt/tbb/2018.u6/include -DTBB_ROOT=/opt/tbb/2018.u6/")
125 g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}, sys_modules=SYS_MODULES)