-// Copyright (C) 2006-2014 CEA/DEN, EDF R&D
+// Copyright (C) 2006-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include "InlineNode.hxx"
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SALOME_PyNode)
+#include CORBA_CLIENT_HEADER(SALOME_Component)
#include <Python.h>
{
namespace ENGINE
{
- class YACSRUNTIMESALOME_EXPORT PythonNode : public InlineNode
+ class YACSRUNTIMESALOME_EXPORT PythonEntry
+ {
+ protected:
+ PythonEntry();
+ ~PythonEntry();
+ virtual void assignRemotePyInterpretor(Engines::PyNodeBase_var remoteInterp) = 0;
+ //! returns (if any) an object, you have to deal with (UnRegister)
+ virtual Engines::PyNodeBase_var retrieveDftRemotePyInterpretorIfAny(Engines::Container_ptr objContainer) const = 0;
+ //! returns an object, you have to deal with (UnRegister)
+ virtual void createRemoteAdaptedPyInterpretor(Engines::Container_ptr objContainer) = 0;
+ virtual Engines::PyNodeBase_var getRemoteInterpreterHandle() = 0;
+ virtual const char *getSerializationScript() const = 0;
+ //
+ void commonRemoteLoad(InlineNode *reqNode);
+ void loadRemoteContainer(InlineNode *reqNode);
+ Engines::Container_var loadPythonAdapter(InlineNode *reqNode, bool& isInitializeRequested);
+ void loadRemoteContext(InlineNode *reqNode, Engines::Container_ptr objContainer, bool isInitializeRequested);
+ static std::string GetContainerLog(const std::string& mode, Container *container, const Task *askingTask);
+ virtual bool hasImposedResource()const;
+ protected:
+ PyObject *_context;
+ PyObject *_pyfuncSer;
+ PyObject *_pyfuncUnser;
+ PyObject *_pyfuncSimpleSer;
+ std::string _imposedResource;
+ std::string _imposedContainer;
+ public:
+ static const char SCRIPT_FOR_SIMPLE_SERIALIZATION[];
+ };
+
+ class YACSRUNTIMESALOME_EXPORT PythonNode : public InlineNode, public PythonEntry
{
protected:
Node *simpleClone(ComposedNode *father, bool editionOnly) const;
+ // overload part of PythonEntry
+ void createRemoteAdaptedPyInterpretor(Engines::Container_ptr objContainer);
+ Engines::PyNodeBase_var retrieveDftRemotePyInterpretorIfAny(Engines::Container_ptr objContainer) const;
+ void assignRemotePyInterpretor(Engines::PyNodeBase_var remoteInterp);
+ Engines::PyNodeBase_var getRemoteInterpreterHandle();
+ const char *getSerializationScript() const { return SCRIPT_FOR_SERIALIZATION; }
+ // A kernel container may manage several python contexts identified by
+ // their name (PyNode and PyScript node). This function returns the name
+ // of the context used by this object. See SALOME_Component.idl in KERNEL.
+ std::string pythonEntryName()const;
public:
PythonNode(const PythonNode& other, ComposedNode *father);
PythonNode(const std::string& name);
virtual ~PythonNode();
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
virtual void execute();
virtual void load();
virtual void loadRemote();
virtual void executeRemote();
virtual void executeLocal();
virtual void shutdown(int level);
+ void imposeResource(const std::string& resource_name,
+ const std::string& container_name) override;
+ bool canAcceptImposedResource()override;
+ bool hasImposedResource()const override;
+ bool isUsingPythonCache()const;
std::string getContainerLog();
PythonNode* cloneNode(const std::string& name);
+ virtual std::string typeName() { return "YACS__ENGINE__PythonNode"; }
+ void applyDPLScope(ComposedNode *gfn);
+ void setSqueezeStatus(bool sqStatus) { _autoSqueeze=sqStatus; }
+ bool getSqueezeStatus() const { return _autoSqueeze; }
+ void squeezeMemorySafe();
+ protected:
+ void squeezeMemory();
+ void squeezeMemoryRemote();
+ public:
static const char KIND[];
static const char IMPL_NAME[];
- virtual std::string typeName() {return "YACS__ENGINE__PythonNode";}
+ static const char SCRIPT_FOR_SERIALIZATION[];
+ static const char REMOTE_NAME[];
+ static const char DPL_INFO_NAME[];
protected:
- PyObject* _context;
- PyObject* _pyfuncSer;
- PyObject* _pyfuncUnser;
+ bool _autoSqueeze = false;
Engines::PyScriptNode_var _pynode;
};
- class PyFuncNode : public InlineFuncNode
+ class YACSRUNTIMESALOME_EXPORT PyFuncNode : public InlineFuncNode, public PythonEntry
{
protected:
Node *simpleClone(ComposedNode *father, bool editionOnly) const;
+ // overload part of PythonEntry
+ void createRemoteAdaptedPyInterpretor(Engines::Container_ptr objContainer);Engines::
+ PyNodeBase_var retrieveDftRemotePyInterpretorIfAny(Engines::Container_ptr objContainer) const;
+ void assignRemotePyInterpretor(Engines::PyNodeBase_var remoteInterp);
+ Engines::PyNodeBase_var getRemoteInterpreterHandle();
+ const char *getSerializationScript() const { return SCRIPT_FOR_SERIALIZATION; }
public:
PyFuncNode(const PyFuncNode& other, ComposedNode *father);
PyFuncNode(const std::string& name);
virtual ~PyFuncNode();
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void init(bool start=true);
+ virtual void checkBasicConsistency() const ;
virtual void execute();
virtual void load();
virtual void loadRemote();
virtual void executeRemote();
virtual void executeLocal();
virtual void shutdown(int level);
+ void imposeResource(const std::string& resource_name,
+ const std::string& container_name) override;
+ bool canAcceptImposedResource()override;
+ bool hasImposedResource()const override;
std::string getContainerLog();
PyFuncNode* cloneNode(const std::string& name);
- virtual std::string typeName() {return "YACS__ENGINE__PyFuncNode";}
+ virtual std::string typeName() { return "YACS__ENGINE__PyFuncNode"; }
+ public:
+ static const char SCRIPT_FOR_SERIALIZATION[];
protected:
- PyObject* _context;
PyObject* _pyfunc;
- PyObject* _pyfuncSer;
- PyObject* _pyfuncUnser;
Engines::PyNode_var _pynode;
};
}