Version: 9.16.0
YACS::ENGINE::SalomePythonNode Class Reference

#include <SalomePythonNode.hxx>

Inheritance diagram for YACS::ENGINE::SalomePythonNode:
Collaboration diagram for YACS::ENGINE::SalomePythonNode:

Public Member Functions

 SalomePythonNode (const SalomePythonNode &other, ComposedNode *father)
 
 SalomePythonNode (const std::string &name)
 
virtual void execute ()
 
virtual void load ()
 Load the component associated to the node. More...
 
std::string getKind () const
 Return the service node kind. More...
 
ServiceNodecreateNode (const std::string &name)
 
SalomePythonNodecloneNode (const std::string &name)
 Create a new node of same type with a given name. More...
 
- Public Member Functions inherited from YACS::ENGINE::ServiceInlineNode
void setScript (const std::string &script)
 
std::string getScript () const
 
void accept (Visitor *visitor)
 
virtual std::string typeName ()
 
- Public Member Functions inherited from YACS::ENGINE::ServiceNode
virtual void load ()
 Load the component associated to the node. More...
 
virtual bool isDeployable () const
 By definition of ServiceNode class. More...
 
virtual void setComponent (ComponentInstance *compo)
 Associate an existing component instance to this service node AND check the consistency regarding the deployment from root node point of view. More...
 
virtual ComponentInstancegetComponent ()
 Return the associated component instance. More...
 
virtual const ComponentInstancegetComponent () const
 
virtual ContainergetContainer ()
 Return the associated container. More...
 
virtual void setRef (const std::string &ref)
 Associate a new component instance to this service node. More...
 
virtual std::string getRef ()
 
virtual void setMethod (const std::string &method)
 
virtual std::string getMethod ()
 
virtual ServiceNodecreateNode (const std::string &name)=0
 
virtual ~ServiceNode ()
 
virtual void accept (Visitor *visitor)
 
virtual std::string getKind () const
 Return the service node kind. More...
 
virtual std::string typeName ()
 
- Public Member Functions inherited from YACS::ENGINE::ElementaryNode
virtual ~ElementaryNode ()
 
void exUpdateState ()
 Update the node state. More...
 
void init (bool start=true)
 
bool isDeployable () const
 
ComponentInstancegetComponent ()
 
const ComponentInstancegetComponent () const
 
ContainergetContainer ()
 
YACS::StatesForNode getState () const
 
void getReadyTasks (std::vector< Task * > &tasks)
 
void edRemovePort (Port *port)
 
std::list< ElementaryNode * > getRecursiveConstituents () const
 
std::list< ProgressWeightgetProgressWeight () const
 Get the progress weight for all elementary nodes. More...
 
NodegetChildByName (const std::string &name) const
 
virtual void checkBasicConsistency () const
 
ComposedNodegetDynClonerIfExists (const ComposedNode *levelToStop) const
 
int getNumberOfInputPorts () const
 
int getNumberOfOutputPorts () const
 
std::string getInPortName (const InPort *) const
 
std::string getOutPortName (const OutPort *) const
 
InputPortgetInputPort (const std::string &name) const
 
OutputPortgetOutputPort (const std::string &name) const
 
std::list< InputPort * > getSetOfInputPort () const
 
std::list< OutputPort * > getSetOfOutputPort () const
 
std::list< InputPort * > getLocalInputPorts () const
 
std::list< OutputPort * > getLocalOutputPorts () const
 
std::set< OutPort * > getAllOutPortsLeavingCurrentScope () const
 
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope () const
 
virtual std::vector< std::pair< OutPort *, InPort * > > getSetOfLinksLeavingCurrentScope () const
 
virtual std::vector< std::pair< InPort *, OutPort * > > getSetOfLinksComingInCurrentScope () const
 
std::list< InputDataStreamPort * > getSetOfInputDataStreamPort () const
 
std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort () const
 
InputDataStreamPortgetInputDataStreamPort (const std::string &name) const
 
OutputDataStreamPortgetOutputDataStreamPort (const std::string &name) const
 
virtual InputPortcreateInputPort (const std::string &inputPortName, TypeCode *type)
 
virtual OutputPortcreateOutputPort (const std::string &outputPortName, TypeCode *type)
 
virtual InputDataStreamPortcreateInputDataStreamPort (const std::string &inputPortDSName, TypeCode *type)
 
virtual OutputDataStreamPortcreateOutputDataStreamPort (const std::string &outputPortDSName, TypeCode *type)
 
virtual InputPortedAddInputPort (const std::string &inputPortName, TypeCode *type)
 
virtual OutputPortedAddOutputPort (const std::string &outputPortName, TypeCode *type)
 
virtual InputDataStreamPortedAddInputDataStreamPort (const std::string &inputPortDSName, TypeCode *type)
 
virtual OutputDataStreamPortedAddOutputDataStreamPort (const std::string &outputPortDSName, TypeCode *type)
 
virtual void edOrderInputPorts (const std::list< InputPort * > &ports)
 
virtual void edOrderOutputPorts (const std::list< OutputPort * > &ports)
 
virtual std::string typeName ()
 
virtual void edUpdateState ()
 update the status of the node More...
 
virtual void ensureLoading ()
 Put this node into TOLOAD state when possible. More...
 
int getMaxLevelOfParallelism () const
 
ComplexWeightgetWeight ()
 
void setWeight (double elementaryWeight)
 
void getWeightRegardingDPL (ComplexWeight *weight)
 
void partitionRegardingDPL (const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)
 
void begin ()
 
bool isReady ()
 
void finished ()
 
void aborted ()
 
void loaded ()
 Notify this node that it is loaded. More...
 
void connected ()
 Notify this node that it is connected. More...
 
virtual std::string getErrorDetails ()
 Give a description of error when node status is ERROR. More...
 
virtual void initService ()
 
virtual void connectService ()
 
virtual void disconnectService ()
 
virtual void load ()
 
virtual void getCoupledTasks (std::set< Task * > &coupledSet)
 Calls getCoupledNodes for Task interface. More...
 
virtual void getCoupledNodes (std::set< Task * > &coupledSet)
 Put all nodes that are coupled to this node in coupledSet. More...
 
void accept (Visitor *visitor)
 
virtual void addDatastreamPortToInitMultiService (const std::string &port_name, int number)
 
- Public Member Functions inherited from YACS::ENGINE::Node
virtual ~Node ()
 
virtual void init (bool start=true)
 
virtual void shutdown (int level)
 Stop all pending activities of the node. More...
 
virtual void resetState (int level)
 Reset the node state depending on the parameter level. More...
 
Nodeclone (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
NodecloneWithoutCompAndContDeepCpy (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
void setState (YACS::StatesForNode theState)
 Sets the given state for node. More...
 
virtual YACS::StatesForNode getState () const
 
virtual YACS::StatesForNode getEffectiveState () const
 Return the node state in the context of its father. More...
 
virtual YACS::StatesForNode getEffectiveState (const Node *) const
 Return the effective state of a node in the context of this one (its father) More...
 
std::string getColorState (YACS::StatesForNode state) const
 Return the color associated to a state. More...
 
InGategetInGate ()
 
OutGategetOutGate ()
 
const std::string & getName () const
 
void setName (const std::string &name)
 Change the name of the node. More...
 
ComposedNodegetFather () const
 
const std::string getId () const
 
bool exIsControlReady () const
 
std::list< Node * > getOutNodes () const
 
virtual void writeDot (std::ostream &os) const
 Dump to the input stream a dot representation of the node. More...
 
void writeDotInFile (const std::string &fileName) const
 
virtual void exUpdateState ()
 Update the node state. More...
 
virtual void exFailedState ()
 Notify this node that its execution has failed. More...
 
virtual void exDisabledState ()
 Notify this node that it has been disabled. More...
 
virtual void getReadyTasks (std::vector< Task * > &tasks)=0
 
virtual std::list< ElementaryNode * > getRecursiveConstituents () const =0
 
virtual std::list< ProgressWeightgetProgressWeight () const =0
 
virtual int getNumberOfInputPorts () const =0
 
virtual int getNumberOfOutputPorts () const =0
 
std::list< InPort * > getSetOfInPort () const
 
std::list< OutPort * > getSetOfOutPort () const
 
virtual std::list< InputPort * > getSetOfInputPort () const =0
 
virtual std::list< OutputPort * > getSetOfOutputPort () const =0
 
virtual std::list< InputPort * > getLocalInputPorts () const =0
 
virtual std::list< OutputPort * > getLocalOutputPorts () const =0
 
virtual std::set< InputPort * > edGetSetOfUnitializedInputPort () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
virtual bool edAreAllInputPortInitialized () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
virtual std::string getInPortName (const InPort *) const =0
 
virtual std::string getOutPortName (const OutPort *) const =0
 
virtual std::list< InputDataStreamPort * > getSetOfInputDataStreamPort () const =0
 
virtual std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort () const =0
 
InPortgetInPort (const std::string &name) const
 
InPropertyPortgetInPropertyPort () const
 
virtual OutPortgetOutPort (const std::string &name) const
 
virtual std::set< OutPort * > getAllOutPortsLeavingCurrentScope () const =0
 
virtual std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope () const =0
 
virtual std::vector< std::pair< OutPort *, InPort * > > getSetOfLinksLeavingCurrentScope () const =0
 
virtual std::vector< std::pair< InPort *, OutPort * > > getSetOfLinksComingInCurrentScope () const =0
 
virtual InputPortgetInputPort (const std::string &name) const
 
virtual OutputPortgetOutputPort (const std::string &name) const =0
 
virtual InputDataStreamPortgetInputDataStreamPort (const std::string &name) const =0
 
virtual OutputDataStreamPortgetOutputDataStreamPort (const std::string &name) const =0
 
std::list< ComposedNode * > getAllAscendanceOf (ComposedNode *levelToStop=0) const
 
bool operator> (const Node &other) const
 
bool operator< (const Node &other) const
 
std::string getImplementation () const
 
DynParaLoopgetClosestDPLAmongAncestors () const
 
virtual ComposedNodegetRootNode () const
 
virtual void setProperty (const std::string &name, const std::string &value)
 
virtual std::string getProperty (const std::string &name)
 
std::map< std::string, std::string > getProperties ()
 
std::map< std::string, std::string > getPropertyMap ()
 
virtual void setProperties (std::map< std::string, std::string > properties)
 
virtual NodegetChildByName (const std::string &name) const =0
 
virtual ProcgetProc ()
 
virtual const ProcgetProc () const
 
virtual void accept (Visitor *visitor)=0
 
virtual int getMaxLevelOfParallelism () const =0
 
virtual void getWeightRegardingDPL (ComplexWeight *weight)=0
 
virtual void partitionRegardingDPL (const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)=0
 
std::string getQualifiedName () const
 same as Node::getName() in most cases, but differs for children of switch More...
 
int getNumId ()
 return node instance identifiant, unique for each node instance More...
 
std::vector< std::pair< std::string, int > > getDPLScopeInfo (ComposedNode *gfn)
 
virtual void applyDPLScope (ComposedNode *gfn)
 
virtual void sendEvent (const std::string &event)
 emit notification to all observers registered with the dispatcher More...
 
virtual void sendEvent2 (const std::string &event, void *something)
 emit notification to all observers registered with the dispatcher More...
 
virtual std::string typeName ()
 
virtual std::string getErrorDetails () const
 
virtual void setErrorDetails (const std::string &error)
 
virtual void modified ()
 Sets Node in modified state and its father if it exists. More...
 
virtual int isModified ()
 
virtual int isValid ()
 indicates if the node is valid (returns 1) or not (returns 0) More...
 
virtual void edUpdateState ()
 update the status of the node More...
 
virtual std::string getErrorReport ()
 returns a string that contains an error report if the node is in error More...
 
virtual std::string getContainerLog ()
 returns a string that contains the name of the container log file if it exists More...
 
virtual void ensureLoading ()
 Put this node into TOLOAD state when possible. More...
 
virtual void getCoupledNodes (std::set< Task * > &coupledNodes)
 
virtual void cleanNodes ()
 Clean the node in case of not clean exit. More...
 
- Public Member Functions inherited from YACS::ENGINE::Task
virtual void begin ()=0
 
virtual bool isReady ()=0
 
virtual void execute ()=0
 
virtual void load ()=0
 
virtual void loaded ()=0
 
virtual void connected ()=0
 
virtual void initService ()=0
 
virtual void connectService ()=0
 
virtual void disconnectService ()=0
 
virtual void getCoupledTasks (std::set< Task * > &coupledSet)=0
 
virtual bool isDeployable () const =0
 
virtual ComponentInstancegetComponent ()=0
 
virtual const ComponentInstancegetComponent () const =0
 
virtual ContainergetContainer ()=0
 
virtual YACS::StatesForNode getState () const =0
 
virtual void finished ()=0
 
virtual void aborted ()=0
 
virtual void imposeResource (const std::string &resource_name, const std::string &container_name)
 
virtual bool canAcceptImposedResource ()
 
virtual bool hasImposedResource () const
 
virtual ~Task ()
 

Static Public Attributes

static const char PLACEMENT_VAR_NAME_IN_INTERP [] ="__container__from__YACS__"
 
- Static Public Attributes inherited from YACS::ENGINE::ServiceNode
static const char KIND [] =""
 
- Static Public Attributes inherited from YACS::ENGINE::Node
static std::map< int, Node * > idMap
 

Protected Member Functions

NodesimpleClone (ComposedNode *father, bool editionOnly) const
 
- Protected Member Functions inherited from YACS::ENGINE::ServiceInlineNode
 ServiceInlineNode (const std::string &name)
 
 ServiceInlineNode (const ServiceInlineNode &other, ComposedNode *father)
 
- Protected Member Functions inherited from YACS::ENGINE::ServiceNode
 ServiceNode (const std::string &name)
 
 ServiceNode (const ServiceNode &other, ComposedNode *father)
 
void performDuplicationOfPlacement (const Node &other)
 performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute. More...
 
void performShallowDuplicationOfPlacement (const Node &other)
 performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning. More...
 
- Protected Member Functions inherited from YACS::ENGINE::ElementaryNode
 ElementaryNode (const std::string &name)
 
 ElementaryNode (const ElementaryNode &other, ComposedNode *father)
 
void performDuplicationOfPlacement (const Node &other)
 performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute. More...
 
void performShallowDuplicationOfPlacement (const Node &other)
 performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning. More...
 
void initCommonPartWithoutStateManagement (bool start)
 
virtual void createMultiDatastreamPorts ()
 
void edDisconnectAllLinksWithMe ()
 
bool areAllInputPortsValid () const
 
template<class PORT >
PORT * getPort (const std::string &name, const std::list< PORT * > &setOfPorts) const
 
template<class PORT , class ENUMTYPE >
PORT * edAddPort (const std::string &portName, std::list< PORT * > &setOfPorts, ENUMTYPE type)
 
template<class PORT , class ENUMTYPE >
bool edCheckAddPort (const std::string &portName, std::list< PORT * > &setOfPorts, ENUMTYPE type)
 
- Protected Member Functions inherited from YACS::ENGINE::Node
 Node (const std::string &name)
 
 Node (const Node &other, ComposedNode *father)
 
virtual void performDuplicationOfPlacement (const Node &other)=0
 performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute. More...
 
virtual void performShallowDuplicationOfPlacement (const Node &other)=0
 performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning. More...
 
virtual NodesimpleClone (ComposedNode *father, bool editionOnly=true) const =0
 
virtual void exForwardFailed ()
 
virtual void exForwardFinished ()
 
virtual void edDisconnectAllLinksWithMe ()
 

Protected Attributes

PyObject * _context
 
PyObject * _pyfunc
 
- Protected Attributes inherited from YACS::ENGINE::ServiceInlineNode
std::string _script
 
- Protected Attributes inherited from YACS::ENGINE::ServiceNode
ComponentInstance_component
 
std::string _method
 
std::string _ref
 
- Protected Attributes inherited from YACS::ENGINE::ElementaryNode
std::list< InputPort * > _setOfInputPort
 
std::list< OutputPort * > _setOfOutputPort
 
std::list< InputDataStreamPort * > _setOfInputDataStreamPort
 
std::list< OutputDataStreamPort * > _setOfOutputDataStreamPort
 
ComplexWeight _weight
 
bool _createDatastreamPorts
 
bool _multi_port_node
 
- Protected Attributes inherited from YACS::ENGINE::Node
InGate _inGate
 
OutGate _outGate
 
InPropertyPort_inPropertyPort
 
std::string _name
 
ComposedNode_father
 
YACS::StatesForNode _state
 
int _modified
 
std::string _errorDetails
 
int _numId
 
std::string _implementation
 
std::map< std::string, std::string > _propertyMap
 
Node_eventReceiver =nullptr
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::ENGINE::Node
static std::string getStateName (YACS::StatesForNode state)
 Return the name of a state. More...
 
static void checkValidityOfNodeName (const std::string &name)
 
- Public Attributes inherited from YACS::ENGINE::Node
YACS::Colour _colour
 
- Static Protected Member Functions inherited from YACS::ENGINE::ElementaryNode
template<class PORT >
static void edRemovePortTypedFromSet (PORT *port, std::list< PORT * > &setOfPorts)
 
template<class PORT >
static bool isPortNameAlreadyExist (const std::string &portName, const std::list< PORT * > &setOfPorts)
 
- Static Protected Member Functions inherited from YACS::ENGINE::Node
static void checkValidityOfPortName (const std::string &name)
 
static ComposedNodecheckHavingCommonFather (Node *node1, Node *node2)
 
- Static Protected Attributes inherited from YACS::ENGINE::Node
static const char SEP_CHAR_IN_PORT [] ="."
 
static int _total = 0
 

Detailed Description

This class is in charge to deal with python willing to interact with YACS placed container. Typical use is for nodes building GEOM and MESH. The great number of calls needed by this type of application, implies a human impossibility to make the corresponding graph.

Definition at line 35 of file SalomePythonNode.hxx.

Constructor & Destructor Documentation

◆ SalomePythonNode() [1/2]

SalomePythonNode::SalomePythonNode ( const SalomePythonNode other,
ComposedNode father 
)

Definition at line 36 of file SalomePythonNode.cxx.

36 :ServiceInlineNode(other,father),_pyfunc(0),_context(0)
37{
38 //Not a bug : just because port point of view this is like PythonNode.
40 PyGILState_STATE gstate = PyGILState_Ensure();
41 _context=PyDict_New();
42 if( PyDict_SetItemString( _context, "__builtins__", getSALOMERuntime()->getBuiltins() ))
43 {
44 stringstream msg;
45 msg << "Not possible to set builtins" << __FILE__ << ":" << __LINE__;
46 PyGILState_Release(gstate);
47 throw Exception(msg.str());
48 }
49 PyGILState_Release(gstate);
50}
std::string _implementation
Definition: Node.hxx:97
static const char IMPL_NAME[]
Definition: PythonNode.hxx:123
ServiceInlineNode(const std::string &name)
YACSRUNTIMESALOME_EXPORT RuntimeSALOME * getSALOMERuntime()

References _context, YACS::ENGINE::Node::_implementation, YACS::ENGINE::getSALOMERuntime(), and YACS::ENGINE::PythonNode::IMPL_NAME.

Referenced by cloneNode(), createNode(), and simpleClone().

◆ SalomePythonNode() [2/2]

SalomePythonNode::SalomePythonNode ( const std::string &  name)

Definition at line 52 of file SalomePythonNode.cxx.

52 : ServiceInlineNode(name),_pyfunc(0)
53{
54
55 //Not a bug : just because port point of view this is like PythonNode.
57 PyGILState_STATE gstate = PyGILState_Ensure();
58 _context=PyDict_New();
59 if( PyDict_SetItemString( _context, "__builtins__", getSALOMERuntime()->getBuiltins() ))
60 {
61 stringstream msg;
62 msg << "Not possible to set builtins" << __FILE__ << ":" << __LINE__;
63 PyGILState_Release(gstate);
64 throw Exception(msg.str());
65 }
66 PyGILState_Release(gstate);
67}

References _context, YACS::ENGINE::Node::_implementation, YACS::ENGINE::getSALOMERuntime(), and YACS::ENGINE::PythonNode::IMPL_NAME.

Member Function Documentation

◆ cloneNode()

SalomePythonNode * SalomePythonNode::cloneNode ( const std::string &  name)

Create a new node of same type with a given name.

Definition at line 214 of file SalomePythonNode.cxx.

215{
217 n->setScript(_script);
218 n->setMethod(_method);
219 list<InputPort *>::iterator iter;
220 for(iter = _setOfInputPort.begin(); iter != _setOfInputPort.end(); iter++)
221 {
222 InputPyPort *p=(InputPyPort *)*iter;
223 n->edAddInputPort(p->getName(),p->edGetType());
224 }
225 list<OutputPort *>::iterator iter2;
226 for(iter2 = _setOfOutputPort.begin(); iter2 != _setOfOutputPort.end(); iter2++)
227 {
228 OutputPyPort *p=(OutputPyPort *)*iter2;
229 n->edAddOutputPort(p->getName(),p->edGetType());
230 }
231 return n;
232}
std::string getName() const
std::list< InputPort * > _setOfInputPort
std::list< OutputPort * > _setOfOutputPort
Class for Python Ports.
Definition: PythonPorts.hxx:74
SalomePythonNode(const SalomePythonNode &other, ComposedNode *father)
Proc * p
Definition: driver.cxx:216

References YACS::ENGINE::ServiceNode::_method, YACS::ENGINE::ServiceInlineNode::_script, YACS::ENGINE::ElementaryNode::_setOfInputPort, YACS::ENGINE::ElementaryNode::_setOfOutputPort, YACS::ENGINE::ComposedNode::getName(), gui.Appli::n, p, and SalomePythonNode().

◆ createNode()

ServiceNode * SalomePythonNode::createNode ( const std::string &  name)
virtual

Implements YACS::ENGINE::ServiceNode.

Definition at line 206 of file SalomePythonNode.cxx.

207{
208 ServiceNode* node=new SalomePythonNode(name);
210 return node;
211}
Class for calculation node associated with a component service.
Definition: ServiceNode.hxx:35
ComponentInstance * _component
Definition: ServiceNode.hxx:60
virtual void setComponent(ComponentInstance *compo)
Associate an existing component instance to this service node AND check the consistency regarding the...

References YACS::ENGINE::ServiceNode::_component, SalomePythonNode(), and YACS::ENGINE::ServiceNode::setComponent().

◆ execute()

void SalomePythonNode::execute ( )
virtual

Implements YACS::ENGINE::Task.

Definition at line 105 of file SalomePythonNode.cxx.

106{
107 cerr << "++++++++++++++ SalomePythonNode::execute: " << getName() << " ++++++++++++++++++++" << endl;
108 int pos=0;
109 PyObject* ob;
110 if(!_pyfunc)throw Exception("SalomePythonNode badly loaded");
111 PyGILState_STATE gstate = PyGILState_Ensure();
112
113 cerr << "---------------SalomePythonNode::inputs---------------" << endl;
114 PyObject* args = PyTuple_New(getNumberOfInputPorts()) ;
115 list<InputPort *>::iterator iter2;
116 for(iter2 = _setOfInputPort.begin(); iter2 != _setOfInputPort.end(); iter2++)
117 {
118 InputPyPort *p=(InputPyPort *)*iter2;
119 cerr << "port name: " << p->getName() << endl;
120 cerr << "port kind: " << p->edGetType()->kind() << endl;
121 ob=p->getPyObj();
122 PyObject_Print(ob,stderr,Py_PRINT_RAW);
123 cerr << endl;
124 cerr << "ob refcnt: " << ob->ob_refcnt << endl;
125 Py_INCREF(ob);
126 PyTuple_SetItem(args,pos,ob);
127 cerr << "ob refcnt: " << ob->ob_refcnt << endl;
128 pos++;
129 }
130 cerr << "---------------End SalomePythonNode::inputs---------------" << endl;
131
132 cerr << "----------------SalomePythonNode::calculation---------------" << endl;
133 PyObject_Print(_pyfunc,stderr,Py_PRINT_RAW);
134 cerr << endl;
135 PyObject_Print(args,stderr,Py_PRINT_RAW);
136 cerr << endl;
137 PyObject* result = PyObject_CallObject( _pyfunc , args ) ;
138 Py_DECREF(args);
139 if(result == NULL)
140 {
141 PyErr_Print();
142 PyGILState_Release(gstate);
143 throw Exception("Error during execution");
144 }
145 cerr << "----------------End SalomePythonNode::calculation---------------" << endl;
146
147 cerr << "-----------------SalomePythonNode::outputs-----------------" << endl;
148 int nres=1;
149 if(result == Py_None)
150 nres=0;
151 else if(PyTuple_Check(result))
152 nres=PyTuple_Size(result);
153
154 if(getNumberOfOutputPorts() != nres)
155 {
156 Py_DECREF(result);
157 PyGILState_Release(gstate);
158 throw Exception("Number of output arguments : Mismatch between definition and execution");
159 }
160
161 pos=0;
162 PyObject_Print(result,stderr,Py_PRINT_RAW);
163 cerr << endl;
164 list<OutputPort *>::iterator iter;
165 try
166 {
167 for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); iter++)
168 {
169 OutputPyPort *p=(OutputPyPort *)*iter;
170 cerr << "port name: " << p->getName() << endl;
171 cerr << "port kind: " << p->edGetType()->kind() << endl;
172 cerr << "port pos : " << pos << endl;
173 if(PyTuple_Check(result))ob=PyTuple_GetItem(result,pos) ;
174 else ob=result;
175 cerr << "ob refcnt: " << ob->ob_refcnt << endl;
176 PyObject_Print(ob,stderr,Py_PRINT_RAW);
177 cerr << endl;
178 p->put(ob);
179 pos++;
180 }
181 }
183 {
184 Py_DECREF(result);
185 PyGILState_Release(gstate);
186 throw;
187 }
188 cerr << "-----------------End SalomePythonNode::outputs-----------------" << endl;
189
190 Py_DECREF(result);
191 PyGILState_Release(gstate);
192 cerr << "++++++++++++++ End SalomePythonNode::execute: " << getName() << " ++++++++++++++++++++" << endl;
193}
const std::string & getName() const
Definition: Node.hxx:125

References _pyfunc, YACS::ENGINE::ElementaryNode::_setOfInputPort, YACS::ENGINE::ElementaryNode::_setOfOutputPort, driver_internal::args, YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Node::getName(), YACS::ENGINE::ElementaryNode::getNumberOfInputPorts(), YACS::ENGINE::ElementaryNode::getNumberOfOutputPorts(), and p.

◆ getKind()

std::string SalomePythonNode::getKind ( ) const
virtual

Return the service node kind.

A runtime can provide several implementations of a service node. Each implementation has a different kind. A ComponentInstance can be associated to a ServiceNode with the same kind.

Reimplemented from YACS::ENGINE::ServiceNode.

Definition at line 195 of file SalomePythonNode.cxx.

196{
197 static const char LOC_KIND[]="";
198 return LOC_KIND;
199}

◆ load()

void SalomePythonNode::load ( )
virtual

Load the component associated to the node.

Reimplemented from YACS::ENGINE::ServiceNode.

Definition at line 69 of file SalomePythonNode.cxx.

70{
72 cerr << "---------------SalomePythonNode::load function---------------" << endl;
73 list<OutputPort *>::iterator iter;
74 string value2Export=((SalomePythonComponent*)_component)->getStringValueToExportInInterp(this);
75 PyObject* ob=PyBytes_FromString(value2Export.c_str());
76 PyDict_SetItemString(_context,PLACEMENT_VAR_NAME_IN_INTERP,ob);
77 for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); iter++)
78 {
79 OutputPyPort *p=(OutputPyPort *)*iter;
80 cerr << "port name: " << p->getName() << endl;
81 cerr << "port kind: " << p->edGetType()->kind() << endl;
82 }
83 cerr << _script << endl;
84 PyGILState_STATE gstate = PyGILState_Ensure();
85 PyObject *res=PyRun_String(_script.c_str(),Py_file_input,_context,_context);
86 if(res == NULL)
87 {
88 PyErr_Print();
89 PyGILState_Release(gstate);
90 throw Exception("Error during execution");
91 return;
92 }
93 Py_DECREF(res);
94 _pyfunc=PyDict_GetItemString(_context,_method.c_str());
95 if(_pyfunc == NULL)
96 {
97 PyErr_Print();
98 PyGILState_Release(gstate);
99 throw Exception("Error during execution");
100 }
101 cerr << "---------------End SalomePythonNode::load function---------------" << endl;
102 PyGILState_Release(gstate);
103}
static const char PLACEMENT_VAR_NAME_IN_INTERP[]
virtual void load()
Load the component associated to the node.
Definition: ServiceNode.cxx:90

References YACS::ENGINE::ServiceNode::_component, _context, YACS::ENGINE::ServiceNode::_method, _pyfunc, YACS::ENGINE::ServiceInlineNode::_script, YACS::ENGINE::ElementaryNode::_setOfOutputPort, YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::ServiceNode::load(), p, and PLACEMENT_VAR_NAME_IN_INTERP.

◆ simpleClone()

Node * SalomePythonNode::simpleClone ( ComposedNode father,
bool  editionOnly 
) const
protectedvirtual

Implements YACS::ENGINE::Node.

Definition at line 201 of file SalomePythonNode.cxx.

202{
203 return new SalomePythonNode(*this,father);
204}

References SalomePythonNode().

Member Data Documentation

◆ _context

PyObject* YACS::ENGINE::SalomePythonNode::_context
protected

Definition at line 48 of file SalomePythonNode.hxx.

Referenced by load(), and SalomePythonNode().

◆ _pyfunc

PyObject* YACS::ENGINE::SalomePythonNode::_pyfunc
protected

Definition at line 49 of file SalomePythonNode.hxx.

Referenced by execute(), and load().

◆ PLACEMENT_VAR_NAME_IN_INTERP

const char SalomePythonNode::PLACEMENT_VAR_NAME_IN_INTERP ="__container__from__YACS__"
static

Definition at line 51 of file SalomePythonNode.hxx.

Referenced by load().


The documentation for this class was generated from the following files: