1 // Copyright (C) 2006-2019 CEA/DEN, 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
20 #ifndef _PYTHONNODE_HXX_
21 #define _PYTHONNODE_HXX_
23 #include "YACSRuntimeSALOMEExport.hxx"
24 #include "InlineNode.hxx"
25 #include <SALOMEconfig.h>
26 #include CORBA_CLIENT_HEADER(SALOME_PyNode)
27 #include CORBA_CLIENT_HEADER(SALOME_Component)
35 class YACSRUNTIMESALOME_EXPORT PythonEntry
40 virtual void assignRemotePyInterpretor(Engines::PyNodeBase_var remoteInterp) = 0;
41 //! returns (if any) an object, you have to deal with (UnRegister)
42 virtual Engines::PyNodeBase_var retrieveDftRemotePyInterpretorIfAny(Engines::Container_ptr objContainer) const = 0;
43 //! returns an object, you have to deal with (UnRegister)
44 virtual void createRemoteAdaptedPyInterpretor(Engines::Container_ptr objContainer) = 0;
45 virtual Engines::PyNodeBase_var getRemoteInterpreterHandle() = 0;
46 virtual const char *getSerializationScript() const = 0;
48 void commonRemoteLoad(InlineNode *reqNode);
49 void commonRemoteLoadPart1(InlineNode *reqNode);
50 Engines::Container_var commonRemoteLoadPart2(InlineNode *reqNode, bool& isInitializeRequested);
51 void commonRemoteLoadPart3(InlineNode *reqNode, Engines::Container_ptr objContainer, bool isInitializeRequested);
52 static std::string GetContainerLog(const std::string& mode, Container *container, const Task *askingTask);
56 PyObject *_pyfuncUnser;
57 PyObject *_pyfuncSimpleSer;
59 static const char SCRIPT_FOR_SIMPLE_SERIALIZATION[];
62 class YACSRUNTIMESALOME_EXPORT PythonNode : public InlineNode, public PythonEntry
65 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
66 // overload part of PythonEntry
67 void createRemoteAdaptedPyInterpretor(Engines::Container_ptr objContainer);
68 Engines::PyNodeBase_var retrieveDftRemotePyInterpretorIfAny(Engines::Container_ptr objContainer) const;
69 void assignRemotePyInterpretor(Engines::PyNodeBase_var remoteInterp);
70 Engines::PyNodeBase_var getRemoteInterpreterHandle();
71 const char *getSerializationScript() const { return SCRIPT_FOR_SERIALIZATION; }
73 PythonNode(const PythonNode& other, ComposedNode *father);
74 PythonNode(const std::string& name);
75 virtual ~PythonNode();
76 virtual void checkBasicConsistency() const ;
77 virtual void execute();
79 virtual void loadRemote();
80 virtual void loadLocal();
81 virtual void executeRemote();
82 virtual void executeLocal();
83 virtual void shutdown(int level);
84 std::string getContainerLog();
85 PythonNode* cloneNode(const std::string& name);
86 virtual std::string typeName() { return "YACS__ENGINE__PythonNode"; }
87 void applyDPLScope(ComposedNode *gfn);
88 void setSqueezeStatus(bool sqStatus) { _autoSqueeze=sqStatus; }
89 bool getSqueezeStatus() const { return _autoSqueeze; }
90 void squeezeMemorySafe();
93 void squeezeMemoryRemote();
95 static const char KIND[];
96 static const char IMPL_NAME[];
97 static const char SCRIPT_FOR_SERIALIZATION[];
98 static const char REMOTE_NAME[];
99 static const char DPL_INFO_NAME[];
101 bool _autoSqueeze = false;
102 Engines::PyScriptNode_var _pynode;
105 class YACSRUNTIMESALOME_EXPORT PyFuncNode : public InlineFuncNode, public PythonEntry
108 Node *simpleClone(ComposedNode *father, bool editionOnly) const;
109 // overload part of PythonEntry
110 void createRemoteAdaptedPyInterpretor(Engines::Container_ptr objContainer);Engines::
111 PyNodeBase_var retrieveDftRemotePyInterpretorIfAny(Engines::Container_ptr objContainer) const;
112 void assignRemotePyInterpretor(Engines::PyNodeBase_var remoteInterp);
113 Engines::PyNodeBase_var getRemoteInterpreterHandle();
114 const char *getSerializationScript() const { return SCRIPT_FOR_SERIALIZATION; }
116 PyFuncNode(const PyFuncNode& other, ComposedNode *father);
117 PyFuncNode(const std::string& name);
118 virtual ~PyFuncNode();
119 virtual void init(bool start=true);
120 virtual void checkBasicConsistency() const ;
121 virtual void execute();
123 virtual void loadRemote();
124 virtual void loadLocal();
125 virtual void executeRemote();
126 virtual void executeLocal();
127 virtual void shutdown(int level);
128 std::string getContainerLog();
129 PyFuncNode* cloneNode(const std::string& name);
130 virtual std::string typeName() { return "YACS__ENGINE__PyFuncNode"; }
132 static const char SCRIPT_FOR_SERIALIZATION[];
135 Engines::PyNode_var _pynode;