Version: 9.15.0
YACS::ENGINE::RuntimeSALOME Class Reference

#include <RuntimeSALOME.hxx>

Inheritance diagram for YACS::ENGINE::RuntimeSALOME:
Collaboration diagram for YACS::ENGINE::RuntimeSALOME:

Public Types

enum  {
  IsPyExt = 1 , UsePython = 2 , UseCorba = 4 , UseXml = 8 ,
  UseCpp = 16 , UseSalome = 32
}
 

Public Member Functions

std::unique_ptr< SALOME_NamingService_Container_Abstract > getNS ()
 
virtual std::string getVersion () const
 
virtual void init (long flags, int argc, char *argv[])
 CORBA and Python initialization. More...
 
virtual void fini (bool isFinalizingPython=true)
 
PyObject * launchSubProcess (const std::vector< std::string > &cmds)
 
virtual std::vector< std::pair< std::string, int > > getCatalogOfComputeNodes () const
 
virtual InputPortcreateInputPort (const std::string &name, const std::string &impl, Node *node, TypeCode *type)
 
virtual OutputPortcreateOutputPort (const std::string &name, const std::string &impl, Node *node, TypeCode *type)
 
virtual InputDataStreamPortcreateInputDataStreamPort (const std::string &name, Node *node, TypeCode *type)
 
virtual OutputDataStreamPortcreateOutputDataStreamPort (const std::string &name, Node *node, TypeCode *type)
 
virtual DataNodecreateInDataNode (const std::string &kind, const std::string &name)
 
virtual DataNodecreateOutDataNode (const std::string &kind, const std::string &name)
 
virtual InlineFuncNodecreateFuncNode (const std::string &kind, const std::string &name)
 
virtual InlineNodecreateScriptNode (const std::string &kind, const std::string &name)
 
virtual ServiceNodecreateRefNode (const std::string &kind, const std::string &name)
 
virtual ServiceNodecreateCompoNode (const std::string &kind, const std::string &name)
 
virtual ServiceInlineNodecreateSInlineNode (const std::string &kind, const std::string &name)
 
virtual ComponentInstancecreateComponentInstance (const std::string &name, const std::string &kind="")
 
virtual ContainercreateContainer (const std::string &kind="")
 
virtual WhileLoopcreateWhileLoop (const std::string &name)
 
virtual ForLoopcreateForLoop (const std::string &name)
 
virtual OptimizerLoopcreateOptimizerLoop (const std::string &name, const std::string &algLib, const std::string &factoryName, bool algInitOnFile, const std::string &kind="", Proc *procForTypes=NULL)
 
virtual BloccreateBloc (const std::string &name)
 
virtual ProccreateProc (const std::string &name)
 
virtual TypeCodecreateInterfaceTc (const std::string &id, const std::string &name, std::list< TypeCodeObjref * > ltc)
 
virtual TypeCodecreateSequenceTc (const std::string &id, const std::string &name, TypeCode *content)
 
virtual TypeCodeStructcreateStructTc (const std::string &id, const std::string &name)
 
virtual InputPortadapt (InputPort *source, const std::string &impl, TypeCode *type, bool init=false)
 Main adapter function : adapt an InputPort to be able to connect it to an OutputPort with a possible different implementation. More...
 
virtual InputPortadapt (InPropertyPort *source, const std::string &impl, TypeCode *type, bool init=false)
 Adapter function for InPropertyPort. More...
 
virtual InputPortadaptNeutral (InputPort *source, const std::string &impl, TypeCode *type, bool init)
 Adapt a Neutral input port to connect it to an output port with a given implementation. More...
 
virtual InputPortadapt (InputCorbaPort *source, const std::string &impl, TypeCode *type, bool init)
 Adapt a CORBA input port to an output which implementation and type are given by impl and type. More...
 
virtual InputPortadaptCorbaToCorba (InputCorbaPort *source, TypeCode *type)
 Adapt a CORBA input port to a CORBA output port. More...
 
virtual InputPortadaptCorbaToNeutral (InputCorbaPort *source, TypeCode *type)
 Adapt a CORBA input port to a neutral data. More...
 
virtual InputPortadaptCorbaToPython (InputCorbaPort *source, TypeCode *type)
 Adapt a CORBA input port to a Python output port. More...
 
virtual InputPortadaptCorbaToCpp (InputCorbaPort *source, TypeCode *type)
 Adapt a CORBA input port to a C++ output port. More...
 
virtual InputPortadaptCorbaToXml (InputCorbaPort *source, TypeCode *type)
 Adapt a CORBA input port to connect it to a XML output port. More...
 
virtual InputPortadapt (InputPyPort *source, const std::string &impl, TypeCode *type, bool init)
 Adapt a Python input port to an output port with a given implementation. More...
 
virtual InputPortadaptPythonToCorba (InputPyPort *source, TypeCode *type)
 Adapt a Python input port to a Corba output port. More...
 
virtual InputPortadaptPythonToNeutral (InputPyPort *source, TypeCode *type)
 Adapt a Python input port to a Neutral data port. More...
 
virtual InputPortadaptPythonToPython (InputPyPort *source, TypeCode *type, bool init)
 Adapt a Python input port to a Python output port. More...
 
virtual InputPortadaptPythonToXml (InputPyPort *source, TypeCode *type)
 Adapt a Python input port to a Xml output port. More...
 
virtual InputPortadaptPythonToCpp (InputPyPort *source, TypeCode *type)
 Adapt a Python input port to a C++ output port. More...
 
virtual InputPortadapt (InputCppPort *source, const std::string &impl, TypeCode *type, bool init)
 Adapt a C++ input port to connect it to an output port with a given implementation. More...
 
virtual InputPortadaptCppToCorba (InputCppPort *source, TypeCode *type)
 Adapt a C++ input port to connect it to a CORBA output port. More...
 
virtual InputPortadaptCppToNeutral (InputCppPort *source, TypeCode *type)
 Adapt a C++ input port to a Neutral output port. More...
 
virtual InputPortadaptCppToPython (InputCppPort *source, TypeCode *type)
 Adapt a C++ input port to a Python output port. More...
 
virtual InputPortadaptCppToXml (InputCppPort *source, TypeCode *type)
 
virtual InputPortadaptCppToCpp (InputCppPort *source, TypeCode *type)
 Adapt a C++ input port to a C++ output port. More...
 
virtual InputPortadapt (InputXmlPort *source, const std::string &impl, TypeCode *type, bool init)
 Adapt an Xml input port to an output port which implementation is given by impl. More...
 
virtual InputPortadaptXmlToCorba (InputXmlPort *source, TypeCode *type)
 Adapt a XML input port to connect it to a CORBA output port. More...
 
virtual InputPortadaptXmlToPython (InputXmlPort *inport, TypeCode *type)
 Adapt a XML input port to a Python output port. More...
 
virtual InputPortadaptXmlToCpp (InputXmlPort *inport, TypeCode *type)
 Adapt a XML input port to a C++ output port. More...
 
virtual InputPortadaptXmlToNeutral (InputXmlPort *inport, TypeCode *type)
 Adapt a XML input port to a Neutral output port. More...
 
virtual InputPortadaptXmlToXml (InputXmlPort *inport, TypeCode *type, bool init)
 Adapt a XML input port to a Xml output port. More...
 
virtual InputPortadaptNeutralToXml (InputPort *inport, TypeCode *type)
 Adapt a Neutral input port to a Xml output port. More...
 
virtual InputPortadaptNeutralToPython (InputPort *inport, TypeCode *type)
 Adapt a Neutral input port to a Python output port. More...
 
virtual InputPortadaptNeutralToCorba (InputPort *inport, TypeCode *type)
 Adapt a Neutral input port to a Corba output port. More...
 
virtual InputPortadaptNeutralToCpp (InputPort *inport, TypeCode *type)
 Adapt a Neutral input port to a C++ output port. More...
 
virtual void * convertNeutral (TypeCode *type, Any *data)
 Convert a YACS::ENGINE::Any object to an external object with type type. More...
 
virtual std::string convertNeutralAsString (TypeCode *type, Any *data)
 Convert a YACS::ENGINE::Any object to a string to be used in GUI for example. More...
 
virtual std::string convertPyObjectToString (PyObject *ob)
 
virtual PyObject * convertStringToPyObject (const std::string &s)
 
virtual ~RuntimeSALOME ()
 
void loadModulCatalog ()
 
CORBA::ORB_ptr getOrb () const
 
CORBA::Object_var getFromNS (const char *entry) const
 
PyObject * getPyOrb () const
 
PyObject * getBuiltins () const
 
DynamicAny::DynAnyFactory_ptr getDynFactory () const
 
omniORBpyAPI * getApi ()
 
PyObject * get_omnipy ()
 
ConnectionManagergetConnectionManager ()
 
- Public Member Functions inherited from YACS::ENGINE::Runtime
virtual void init ()
 
virtual void fini ()
 
virtual CatalogloadCatalog (const std::string &sourceKind, const std::string &path)
 Load a catalog of calculation to use as factory. More...
 
virtual ForEachLoopcreateForEachLoop (const std::string &name, TypeCode *type)
 
virtual ForEachLoopDyncreateForEachLoopDyn (const std::string &name, TypeCode *type)
 
virtual SwitchcreateSwitch (const std::string &name)
 
virtual void removeRuntime ()
 
virtual ~Runtime ()
 
virtual void setCatalogLoaderFactory (const std::string &name, CatalogLoader *factory)
 Add a catalog loader factory to the map _catalogLoaderFactoryMap under the name name. More...
 
CataloggetBuiltinCatalog ()
 Get the catalog of base nodes (elementary and composed) More...
 
virtual void addCatalog (Catalog *catalog)
 Add a catalog of types and nodes to the runtime. More...
 
virtual TypeCodegetTypeCode (const std::string &name)
 Get a typecode by its name from runtime catalogs. More...
 

Static Public Member Functions

static void setRuntime (long flags=UsePython+UseCorba+UseXml+UseCpp+UseSalome, int argc=0, char *argv[]=NULL)
 

Public Attributes

enum YACS::ENGINE::RuntimeSALOME:: { ... }  FLAGS
 
- Public Attributes inherited from YACS::ENGINE::Runtime
std::map< std::string, CatalogLoader * > _catalogLoaderFactoryMap
 

Protected Member Functions

 RuntimeSALOME ()
 
 RuntimeSALOME (long flags, int argc, char *argv[])
 
void initBuiltins ()
 
- Protected Member Functions inherited from YACS::ENGINE::Runtime
 Runtime ()
 

Protected Attributes

CORBA::ORB_var _orb
 
PyObject * _pyorb
 
PyObject * _bltins
 
DynamicAny::DynAnyFactory_var _dynFactory
 
omniORBpyAPI * _api
 
PyObject * _omnipy
 
long _flags
 
bool _usePython
 
bool _useCorba
 
bool _useCpp
 
bool _useXml
 
- Protected Attributes inherited from YACS::ENGINE::Runtime
std::set< std::string > _setOfImplementation
 
Catalog_builtinCatalog
 
std::vector< Catalog * > _catalogs
 

Static Private Member Functions

static RuntimegetSingleton ()
 

Private Attributes

ConnectionManager _connectionManager
 

Friends

RuntimeSALOMEgetSALOMERuntime ()
 

Additional Inherited Members

- Static Public Attributes inherited from YACS::ENGINE::Runtime
static const char RUNTIME_ENGINE_INTERACTION_IMPL_NAME [] ="Neutral"
 
static YACS::ENGINE::TypeCode_tc_double = 0
 
static YACS::ENGINE::TypeCode_tc_int = 0
 
static YACS::ENGINE::TypeCode_tc_bool = 0
 
static YACS::ENGINE::TypeCode_tc_string = 0
 
static YACS::ENGINE::TypeCode_tc_file = 0
 
static YACS::ENGINE::TypeCode_tc_stringpair = 0
 
static YACS::ENGINE::TypeCode_tc_propvec = 0
 
- Static Protected Attributes inherited from YACS::ENGINE::Runtime
static Runtime_singleton = 0
 

Detailed Description

Definition at line 58 of file RuntimeSALOME.hxx.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
IsPyExt 
UsePython 
UseCorba 
UseXml 
UseCpp 
UseSalome 

Definition at line 64 of file RuntimeSALOME.hxx.

Constructor & Destructor Documentation

◆ ~RuntimeSALOME()

RuntimeSALOME::~RuntimeSALOME ( )
virtual

Definition at line 244 of file RuntimeSALOME.cxx.

245 {
246  DEBTRACE("RuntimeSALOME::~RuntimeSALOME");
247  // destroy catalog loader prototypes
248  std::map<std::string, CatalogLoader*>::const_iterator pt;
249  for(pt=_catalogLoaderFactoryMap.begin();pt!=_catalogLoaderFactoryMap.end();pt++)
250  {
251  delete (*pt).second;
252  }
254 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
ConnectionManager _connectionManager
std::map< std::string, CatalogLoader * > _catalogLoaderFactoryMap
Definition: Runtime.hxx:144

References DEBTRACE.

◆ RuntimeSALOME() [1/2]

RuntimeSALOME::RuntimeSALOME ( )
protected

Singleton creation, initialize converter map

Definition at line 165 of file RuntimeSALOME.cxx.

166 {
167  YASSERT(0);
168 }
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59

References YASSERT.

◆ RuntimeSALOME() [2/2]

RuntimeSALOME::RuntimeSALOME ( long  flags,
int  argc,
char *  argv[] 
)
protected

Definition at line 214 of file RuntimeSALOME.cxx.

215 {
216  // If all flags (apart the IsPyExt flags) are unset, force them to true
217  if ((flags - flags & RuntimeSALOME::IsPyExt) == 0)
220 
221  // Salome Nodes implies Corba Nodes
222  if (flags & RuntimeSALOME::UseSalome)
223  flags |= RuntimeSALOME::UseCorba;
224 
225  // Corba Nodes implies Python Nodes
226  if (flags & RuntimeSALOME::UseCorba)
227  flags |= RuntimeSALOME::UsePython;
228 
231  _useCpp = flags & RuntimeSALOME::UseCpp;
232  _useXml = flags & RuntimeSALOME::UseXml;
233 
234  /* Init libxml */
235  xmlInitParser();
236 
241  init(flags, argc, argv);
242 }
static const char IMPL_NAME[]
Definition: CORBANode.hxx:57
static const char IMPL_NAME[]
Definition: CppNode.hxx:61
static const char IMPL_NAME[]
Definition: PythonNode.hxx:123
virtual void init()
Definition: Runtime.hxx:72
std::set< std::string > _setOfImplementation
Definition: Runtime.hxx:152
static const char IMPL_NAME[]
Definition: XMLNode.hxx:46

Member Function Documentation

◆ adapt() [1/6]

InputPort * RuntimeSALOME::adapt ( InPropertyPort source,
const std::string &  impl,
TypeCode type,
bool  init = false 
)
virtual

Adapter function for InPropertyPort.

Parameters
source: InPropertyPort to be adapted
impl: new implementation (C++, python, CORBA, XML, Neutral)
type: data type provided by the InPropertyPort
init: indicates if the adapted InPropertyPort will be used for initialization (value true) or not (value false)
Returns
: adapted InputPort

Implements YACS::ENGINE::Runtime.

Definition at line 892 of file RuntimeSALOME.cxx.

895 {
896  return adaptNeutral((InputPort *)source,impl,type,init);
897 }
Base class for Input Ports.
Definition: InputPort.hxx:44
virtual InputPort * adaptNeutral(InputPort *source, const std::string &impl, TypeCode *type, bool init)
Adapt a Neutral input port to connect it to an output port with a given implementation.

◆ adapt() [2/6]

InputPort * RuntimeSALOME::adapt ( InputCorbaPort source,
const std::string &  impl,
TypeCode type,
bool  init 
)
virtual

Adapt a CORBA input port to an output which implementation and type are given by impl and type.

Parameters
source: input port to adapt to implementation impl and type type
impl: output port implementation (C++, Python or Corba)
type: outport data type
init: if init is true the proxy port will be used in initialization of input port (needs value check)
Returns
an adaptator port which type depends on impl

Definition at line 1437 of file RuntimeSALOME.cxx.

1440 {
1441  if(impl == CppNode::IMPL_NAME)
1442  {
1443  return adaptCorbaToCpp(source,type);
1444  }
1445  else if(impl == PythonNode::IMPL_NAME)
1446  {
1447  return adaptCorbaToPython(source,type);
1448  }
1449  else if(impl == CORBANode::IMPL_NAME)
1450  {
1451  if(init)
1452  return adaptCorbaToCorba(source,type);
1453  else
1454  return adaptCorbaToCorba(source,type);
1455  }
1456  else if(impl == XmlNode::IMPL_NAME )
1457  {
1458  return adaptCorbaToXml(source,type);
1459  }
1461  {
1462  return adaptCorbaToNeutral(source,type);
1463  }
1464  else
1465  {
1466  stringstream msg;
1467  msg << "Cannot connect InputCorbaPort : unknown implementation " ;
1468  msg << __FILE__ << ":" <<__LINE__;
1469  throw ConversionException(msg.str());
1470  }
1471 }
virtual InputPort * adaptCorbaToXml(InputCorbaPort *source, TypeCode *type)
Adapt a CORBA input port to connect it to a XML output port.
virtual InputPort * adaptCorbaToCpp(InputCorbaPort *source, TypeCode *type)
Adapt a CORBA input port to a C++ output port.
virtual InputPort * adaptCorbaToPython(InputCorbaPort *source, TypeCode *type)
Adapt a CORBA input port to a Python output port.
virtual InputPort * adaptCorbaToNeutral(InputCorbaPort *source, TypeCode *type)
Adapt a CORBA input port to a neutral data.
virtual InputPort * adaptCorbaToCorba(InputCorbaPort *source, TypeCode *type)
Adapt a CORBA input port to a CORBA output port.
static const char RUNTIME_ENGINE_INTERACTION_IMPL_NAME[]
Definition: Runtime.hxx:135

◆ adapt() [3/6]

InputPort * RuntimeSALOME::adapt ( InputCppPort source,
const std::string &  impl,
TypeCode type,
bool  init 
)
virtual

Adapt a C++ input port to connect it to an output port with a given implementation.

Parameters
source: input port to adapt to implementation impl and type type
impl: output port implementation (C++, Python or Corba)
type: output port supported type
init: if init is true the proxy port will be used in initialization of input port (needs value check)
Returns
the adaptated port

Definition at line 1868 of file RuntimeSALOME.cxx.

1871 {
1872  DEBTRACE("RuntimeSALOME::adapt(InputCppPort* source)");
1873  if(impl == CORBANode::IMPL_NAME)
1874  {
1875  return adaptCppToCorba(source,type);
1876  }
1877  else if(impl == PythonNode::IMPL_NAME)
1878  {
1879  return adaptCppToPython(source,type);
1880  }
1881  else if(impl == XmlNode::IMPL_NAME)
1882  {
1883  return adaptCppToXml(source,type);
1884  }
1885  else if(impl == CppNode::IMPL_NAME)
1886  {
1887  return adaptCppToCpp(source, type);
1888  }
1890  {
1891  return adaptCppToNeutral(source, type);
1892  }
1893  else
1894  {
1895  stringstream msg;
1896  msg << "Cannot connect InputCppPort to " << impl << " implementation";
1897  msg << " (" << __FILE__ << ":" << __LINE__ << ")";
1898  throw ConversionException(msg.str());
1899  }
1900 }
virtual InputPort * adaptCppToCpp(InputCppPort *source, TypeCode *type)
Adapt a C++ input port to a C++ output port.
virtual InputPort * adaptCppToCorba(InputCppPort *source, TypeCode *type)
Adapt a C++ input port to connect it to a CORBA output port.
virtual InputPort * adaptCppToPython(InputCppPort *source, TypeCode *type)
Adapt a C++ input port to a Python output port.
virtual InputPort * adaptCppToNeutral(InputCppPort *source, TypeCode *type)
Adapt a C++ input port to a Neutral output port.
virtual InputPort * adaptCppToXml(InputCppPort *source, TypeCode *type)

References DEBTRACE.

◆ adapt() [4/6]

InputPort * RuntimeSALOME::adapt ( InputPort source,
const std::string &  impl,
TypeCode type,
bool  init = false 
)
virtual

Main adapter function : adapt an InputPort to be able to connect it to an OutputPort with a possible different implementation.

Parameters
source: InputPort to be adapted
impl: new implementation (C++, python, CORBA, XML, Neutral)
type: data type provided by the InputPort
init: indicates if the adapted InputPort will be used for initialization (value true) or not (value false)
Returns
: adapted InputPort

Implements YACS::ENGINE::Runtime.

Definition at line 849 of file RuntimeSALOME.cxx.

852 {
853  string imp_source=source->getNode()->getImplementation();
854  if(imp_source == PythonNode::IMPL_NAME)
855  {
856  return adapt((InputPyPort*)source,impl,type,init);
857  }
858  else if(imp_source == CppNode::IMPL_NAME)
859  {
860  return adapt((InputCppPort*)source,impl,type,init);
861  }
862  else if(imp_source == CORBANode::IMPL_NAME)
863  {
864  return adapt((InputCorbaPort*)source,impl,type,init);
865  }
866  else if(imp_source == XmlNode::IMPL_NAME)
867  {
868  return adapt((InputXmlPort*)source,impl,type,init);
869  }
870  else if(imp_source == Runtime::RUNTIME_ENGINE_INTERACTION_IMPL_NAME)
871  {
872  return adaptNeutral(source,impl,type,init);
873  }
874  else
875  {
876  stringstream msg;
877  msg << "Cannot adapt " << imp_source << " InputPort to " << impl;
878  msg << " (" << __FILE__ << ":" << __LINE__ << ")";
879  throw ConversionException(msg.str());
880  }
881 }
Class for CORBA Input Ports.
Definition: CORBAPorts.hxx:45
Class for C++ Ports.
Definition: CppPorts.hxx:40
Class for Python Ports.
Definition: PythonPorts.hxx:74
Class for XML Input Ports.
Definition: XMLPorts.hxx:38
std::string getImplementation() const
Definition: Node.cxx:350
Node * getNode() const
Definition: Port.hxx:46
virtual InputPort * adapt(InputPort *source, const std::string &impl, TypeCode *type, bool init=false)
Main adapter function : adapt an InputPort to be able to connect it to an OutputPort with a possible ...

References gui.adapt::adapt(), YACS::ENGINE::Node::getImplementation(), and YACS::ENGINE::Port::getNode().

◆ adapt() [5/6]

InputPort * RuntimeSALOME::adapt ( InputPyPort source,
const std::string &  impl,
TypeCode type,
bool  init 
)
virtual

Adapt a Python input port to an output port with a given implementation.

Parameters
source: input port to adapt to implementation impl and type type
impl: output port implementation (C++, Python or Corba)
type: output port type
init: if init is true the proxy port will be used in initialization of input port (needs value check)
Returns
adaptated input port

Definition at line 1703 of file RuntimeSALOME.cxx.

1706 {
1707  if(impl == CppNode::IMPL_NAME)
1708  {
1709  return adaptPythonToCpp(source,type);
1710  }
1711  else if(impl == PythonNode::IMPL_NAME)
1712  {
1713  return adaptPythonToPython(source,type,init);
1714  }
1715  else if(impl == CORBANode::IMPL_NAME)
1716  {
1717  return adaptPythonToCorba(source,type);
1718  }
1720  {
1721  return adaptPythonToNeutral(source,type);
1722  }
1723  else if(impl == XmlNode::IMPL_NAME)
1724  {
1725  return adaptPythonToXml(source,type);
1726  }
1727  else
1728  {
1729  stringstream msg;
1730  msg << "Cannot connect InputPyPort : unknown implementation " << impl;
1731  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1732  throw ConversionException(msg.str());
1733  }
1734 }
virtual InputPort * adaptPythonToPython(InputPyPort *source, TypeCode *type, bool init)
Adapt a Python input port to a Python output port.
virtual InputPort * adaptPythonToCorba(InputPyPort *source, TypeCode *type)
Adapt a Python input port to a Corba output port.
virtual InputPort * adaptPythonToXml(InputPyPort *source, TypeCode *type)
Adapt a Python input port to a Xml output port.
virtual InputPort * adaptPythonToNeutral(InputPyPort *source, TypeCode *type)
Adapt a Python input port to a Neutral data port.
virtual InputPort * adaptPythonToCpp(InputPyPort *source, TypeCode *type)
Adapt a Python input port to a C++ output port.

◆ adapt() [6/6]

InputPort * RuntimeSALOME::adapt ( InputXmlPort source,
const std::string &  impl,
TypeCode type,
bool  init 
)
virtual

Adapt an Xml input port to an output port which implementation is given by impl.

Parameters
source: input port to adapt to implementation impl and type type
impl: output port implementation (C++, Python or Corba)
type: output port supported type
init: if init is true the proxy port will be used in initialization of input port (needs value check)
Returns
the adaptated port

Definition at line 1175 of file RuntimeSALOME.cxx.

1178 {
1179  if(impl == CORBANode::IMPL_NAME)
1180  {
1181  return adaptXmlToCorba(source,type);
1182  }
1183  else if(impl == PythonNode::IMPL_NAME)
1184  {
1185  return adaptXmlToPython(source,type);
1186  }
1187  else if(impl == CppNode::IMPL_NAME)
1188  {
1189  return adaptXmlToCpp(source,type);
1190  }
1191  else if(impl == XmlNode::IMPL_NAME )
1192  {
1193  return adaptXmlToXml(source,type,init);
1194  }
1196  {
1197  return adaptXmlToNeutral(source,type);
1198  }
1199  else
1200  {
1201  stringstream msg;
1202  msg << "Cannot connect InputXmlPort to " << impl << " implementation";
1203  msg << " (" << __FILE__ << ":" << __LINE__ << ")";
1204  throw ConversionException(msg.str());
1205  }
1206 }
virtual InputPort * adaptXmlToXml(InputXmlPort *inport, TypeCode *type, bool init)
Adapt a XML input port to a Xml output port.
virtual InputPort * adaptXmlToPython(InputXmlPort *inport, TypeCode *type)
Adapt a XML input port to a Python output port.
virtual InputPort * adaptXmlToCorba(InputXmlPort *source, TypeCode *type)
Adapt a XML input port to connect it to a CORBA output port.
virtual InputPort * adaptXmlToCpp(InputXmlPort *inport, TypeCode *type)
Adapt a XML input port to a C++ output port.
virtual InputPort * adaptXmlToNeutral(InputXmlPort *inport, TypeCode *type)
Adapt a XML input port to a Neutral output port.

◆ adaptCorbaToCorba()

InputPort * RuntimeSALOME::adaptCorbaToCorba ( InputCorbaPort inport,
TypeCode type 
)
virtual

Adapt a CORBA input port to a CORBA output port.

Parameters
inport: input port to adapt to CORBA outport data type
type: outport data type
Returns
an adaptator port of type InputCORBAPort

Definition at line 1215 of file RuntimeSALOME.cxx.

1217 {
1218  if(type->isA(inport->edGetType()))
1219  {
1220  //types are compatible : no conversion
1221  //outport data type is more specific than inport required type
1222  //so the inport can be used safely
1223  return new ProxyPort(inport);
1224  }
1225  else if(isAdaptableCorbaCorba(type,inport->edGetType()))
1226  {
1227  //ouport data can be converted to inport data type
1228  return new CorbaCorba(inport);
1229  }
1230  //outport data can not be converted
1231  stringstream msg;
1232  msg << "Cannot connect Corba output port with type: " << type->id() ;
1233  msg << " to CORBA input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1234 #ifdef _DEVDEBUG_
1235  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1236 #endif
1237  throw ConversionException(msg.str());
1238 }
Class for conversion from CORBA Output port to CORBA Input port.
TypeCode * edGetType() const
Definition: DataPort.hxx:53
std::string getName() const
Definition: DataPort.hxx:55
Base class for Proxy Input Ports.
Definition: InputPort.hxx:100
virtual const char * id() const
Definition: TypeCode.cxx:82
virtual int isA(const char *repositoryId) const
Definition: TypeCode.cxx:99
int isAdaptableCorbaCorba(const TypeCode *t1, const TypeCode *t2)

References YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), YACS::ENGINE::TypeCode::isA(), and YACS::ENGINE::isAdaptableCorbaCorba().

◆ adaptCorbaToCpp()

InputPort * RuntimeSALOME::adaptCorbaToCpp ( InputCorbaPort inport,
TypeCode type 
)
virtual

Adapt a CORBA input port to a C++ output port.

Parameters
inport: input port to adapt to C++ type type
type: outport data type
Returns
an adaptator port of type InputCPPPort

Definition at line 1352 of file RuntimeSALOME.cxx.

1354 {
1355  DEBTRACE("RuntimeSALOME::adaptCorbaToCpp(InputCorbaPort* inport" );
1356  if(isAdaptableCorbaCpp(type,inport->edGetType()))
1357  {
1358  //output type is convertible to input type
1359  return new CppCorba(inport);
1360  }
1361  //output type is not convertible
1362  stringstream msg;
1363  msg << "Cannot connect Cpp output port with type: " << type->id() ;
1364  msg << " to Corba input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1365 #ifdef _DEVDEBUG_
1366  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1367 #endif
1368  throw ConversionException(msg.str());
1369 }
int isAdaptableCorbaCpp(const TypeCode *t1, const TypeCode *t2)

References DEBTRACE, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), and YACS::ENGINE::isAdaptableCorbaCpp().

◆ adaptCorbaToNeutral()

InputPort * RuntimeSALOME::adaptCorbaToNeutral ( InputCorbaPort inport,
TypeCode type 
)
virtual

Adapt a CORBA input port to a neutral data.

Parameters
inport: InputPort to adapt to Neutral type type
type: outport data type
Returns
an adaptator port of type Neutralxxxx

Definition at line 1378 of file RuntimeSALOME.cxx.

1380 {
1381  if(inport->edGetType()->kind() == Double)
1382  {
1383  if(isAdaptableCorbaNeutral(type,inport->edGetType()))return new NeutralCorbaDouble(inport);
1384  }
1385  else if(inport->edGetType()->kind() == Int)
1386  {
1387  if(isAdaptableCorbaNeutral(type,inport->edGetType()))return new NeutralCorbaInt(inport);
1388  }
1389  else if(inport->edGetType()->kind() == String)
1390  {
1391  if(isAdaptableCorbaNeutral(type,inport->edGetType())) return new NeutralCorbaString(inport);
1392  }
1393  else if(inport->edGetType()->kind() == Bool)
1394  {
1395  if(isAdaptableCorbaNeutral(type,inport->edGetType()))return new NeutralCorbaBool(inport);
1396  }
1397  else if(inport->edGetType()->kind() == Objref)
1398  {
1399  if(isAdaptableCorbaNeutral(type,inport->edGetType())) return new NeutralCorbaObjref(inport);
1400  }
1401  else if(inport->edGetType()->kind() == Sequence)
1402  {
1403  if(isAdaptableCorbaNeutral(type,inport->edGetType()))
1404  return new NeutralCorbaSequence(inport);
1405  else
1406  {
1407  stringstream msg;
1408  msg << "Cannot convert this sequence type " ;
1409  msg << __FILE__ << ":" <<__LINE__;
1410  throw ConversionException(msg.str());
1411  }
1412  }
1413  else if(inport->edGetType()->kind() == Struct)
1414  {
1415  if(isAdaptableCorbaNeutral(type,inport->edGetType())) return new NeutralCorbaStruct(inport);
1416  }
1417 
1418  // Adaptation not possible
1419  stringstream msg;
1420  msg << "Cannot connect Neutral output port with type: " << type->id() ;
1421  msg << " to Corba input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1422 #ifdef _DEVDEBUG_
1423  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1424 #endif
1425  throw ConversionException(msg.str());
1426 }
DynType kind() const
Definition: TypeCode.cxx:47
int isAdaptableCorbaNeutral(const TypeCode *t1, const TypeCode *t2)

References YACS::ENGINE::Bool, YACS::ENGINE::Double, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), YACS::ENGINE::Int, YACS::ENGINE::isAdaptableCorbaNeutral(), YACS::ENGINE::TypeCode::kind(), YACS::ENGINE::Objref, YACS::ENGINE::Sequence, YACS::ENGINE::String, and YACS::ENGINE::Struct.

◆ adaptCorbaToPython()

InputPort * RuntimeSALOME::adaptCorbaToPython ( InputCorbaPort inport,
TypeCode type 
)
virtual

Adapt a CORBA input port to a Python output port.

Parameters
inport: input port to adapt to Python type type
type: outport data type
Returns
an adaptator port of type InputPyPort

Definition at line 1247 of file RuntimeSALOME.cxx.

1249 {
1250  if(inport->edGetType()->kind() == Double)
1251  {
1252  if(isAdaptableCorbaPyObject(type,inport->edGetType()))return new PyCorbaDouble(inport);
1253  }
1254  else if(inport->edGetType()->kind() == Int)
1255  {
1256  if(isAdaptableCorbaPyObject(type,inport->edGetType()))return new PyCorbaInt(inport);
1257  }
1258  else if(inport->edGetType()->kind() == String)
1259  {
1260  if(isAdaptableCorbaPyObject(type,inport->edGetType()))return new PyCorbaString(inport);
1261  }
1262  else if(inport->edGetType()->kind() == Bool)
1263  {
1264  if(isAdaptableCorbaPyObject(type,inport->edGetType()))return new PyCorbaBool(inport);
1265  }
1266  else if(inport->edGetType()->kind() == Objref )
1267  {
1268  if(isAdaptableCorbaPyObject(type,inport->edGetType()))
1269  {
1270  return new PyCorbaObjref(inport);
1271  }
1272  else
1273  {
1274  stringstream msg;
1275  msg << "Cannot connect Python output port with type: " << type->id() ;
1276  msg << " to CORBA input port " << inport->getName() << " with incompatible objref type: " << inport->edGetType()->id();
1277  msg << " (" << __FILE__ << ":" <<__LINE__ << ")";
1278  throw ConversionException(msg.str());
1279  }
1280  }
1281  else if(inport->edGetType()->kind() == Sequence)
1282  {
1283  if(isAdaptableCorbaPyObject(type,inport->edGetType()))
1284  {
1285  return new PyCorbaSequence(inport);
1286  }
1287  else
1288  {
1289  stringstream msg;
1290  msg << "Cannot convert this sequence type " ;
1291  msg << __FILE__ << ":" <<__LINE__;
1292  throw ConversionException(msg.str());
1293  }
1294  }
1295  else if(inport->edGetType()->kind() == YACS::ENGINE::Struct)
1296  {
1297  if(isAdaptableCorbaPyObject(type,inport->edGetType()))
1298  {
1299  return new PyCorbaStruct(inport);
1300  }
1301  else
1302  {
1303  stringstream msg;
1304  msg << "Cannot convert this struct type " << type->id() << " to " << inport->edGetType()->id();
1305  msg << __FILE__ << ":" <<__LINE__;
1306  throw ConversionException(msg.str());
1307  }
1308  }
1309  // Adaptation not possible
1310  stringstream msg;
1311  msg << "Cannot connect Python output port with type: " << type->id() ;
1312  msg << " to CORBA input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1313 #ifdef _DEVDEBUG_
1314  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1315 #endif
1316  throw ConversionException(msg.str());
1317 }
int isAdaptableCorbaPyObject(const TypeCode *t1, const TypeCode *t2)

References YACS::ENGINE::Bool, YACS::ENGINE::Double, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), YACS::ENGINE::Int, YACS::ENGINE::isAdaptableCorbaPyObject(), YACS::ENGINE::TypeCode::kind(), YACS::ENGINE::Objref, YACS::ENGINE::Sequence, YACS::ENGINE::String, and YACS::ENGINE::Struct.

◆ adaptCorbaToXml()

InputPort * RuntimeSALOME::adaptCorbaToXml ( InputCorbaPort inport,
TypeCode type 
)
virtual

Adapt a CORBA input port to connect it to a XML output port.

Parameters
inport: input port to adapt to Xml type type
type: type supported by output port
Returns
an adaptator port of type InputXmlPort

Definition at line 1326 of file RuntimeSALOME.cxx.

1328 {
1329  // BEWARE : using the generic check
1330  if(inport->edGetType()->isAdaptable(type))
1331  {
1332  //output type is convertible to input type
1333  return new XmlCorba(inport);
1334  }
1335  //output type is not convertible
1336  stringstream msg;
1337  msg << "Cannot connect Xml output port with type: " << type->id() ;
1338  msg << " to Corba input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1339 #ifdef _DEVDEBUG_
1340  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1341 #endif
1342  throw ConversionException(msg.str());
1343 }
virtual int isAdaptable(const TypeCode *tc) const
Check if this TypeCode is adaptable to a given TypeCode (tc)
Definition: TypeCode.cxx:116

References YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), and YACS::ENGINE::TypeCode::isAdaptable().

◆ adaptCppToCorba()

InputPort * RuntimeSALOME::adaptCppToCorba ( InputCppPort inport,
TypeCode type 
)
virtual

Adapt a C++ input port to connect it to a CORBA output port.

Parameters
inport: input port to adapt to CORBA type type
type: type supported by output port
Returns
an adaptator port of type InputCorbaPort

Definition at line 1744 of file RuntimeSALOME.cxx.

1746 {
1747  DEBTRACE("RuntimeSALOME::adaptCppToCorba(InputCppPort* inport)");
1748  if(isAdaptableCppCorba(type,inport->edGetType()))
1749  {
1750  //output type is convertible to input type
1751  return new CorbaCpp(inport);
1752  }
1753  //output type is not convertible
1754  stringstream msg;
1755  msg << "Cannot connect Corba output port with type: " << type->id() ;
1756  msg << " to Cpp input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1757 #ifdef _DEVDEBUG_
1758  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1759 #endif
1760  throw ConversionException(msg.str());
1761 }
int isAdaptableCppCorba(const TypeCode *t1, const TypeCode *t2)

References DEBTRACE, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), and YACS::ENGINE::isAdaptableCppCorba().

◆ adaptCppToCpp()

InputPort * RuntimeSALOME::adaptCppToCpp ( InputCppPort inport,
TypeCode type 
)
virtual

Adapt a C++ input port to a C++ output port.

Parameters
inport: input port to adapt to C++ type type
type: output port type
Returns
an adaptated input port of type InputPyPort

Definition at line 1794 of file RuntimeSALOME.cxx.

1796 {
1797  DEBTRACE("RuntimeSALOME::adaptCppToCpp(InputPort* inport" );
1798  DEBTRACE(type->kind() << " " << inport->edGetType()->kind() );
1799  if(type->isAdaptable(inport->edGetType()))
1800  {
1801  //the output data is convertible to inport type
1802  return new CppCpp(inport);
1803  }
1804  //non convertible type
1805  stringstream msg;
1806  msg << "Cannot connect Cpp output port with type: " << type->id() ;
1807  msg << " to Cpp input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1808 #ifdef _DEVDEBUG_
1809  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1810 #endif
1811  throw ConversionException(msg.str());
1812 }
Class for conversion from C++ Output port to C++ Input port.
Definition: CppCppConv.hxx:37

References DEBTRACE, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), YACS::ENGINE::TypeCode::isAdaptable(), and YACS::ENGINE::TypeCode::kind().

◆ adaptCppToNeutral()

InputPort * RuntimeSALOME::adaptCppToNeutral ( InputCppPort inport,
TypeCode type 
)
virtual

Adapt a C++ input port to a Neutral output port.

Parameters
inport: input port to adapt to C++ type type
type: output port type
Returns
an adaptated input port of type InputPyPort

Definition at line 1820 of file RuntimeSALOME.cxx.

1822 {
1823  DEBTRACE("RuntimeSALOME::adaptCppToNeutral(InputPort* inport" );
1824  DEBTRACE(type->kind() << " " << inport->edGetType()->kind() );
1825  if(type->isAdaptable(inport->edGetType()))
1826  {
1827  //the output data is convertible to inport type
1828  return new NeutralCpp(inport);
1829  }
1830  //non convertible type
1831  stringstream msg;
1832  msg << "Cannot connect Neutral output port with type: " << type->id() ;
1833  msg << " to Cpp input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1834 #ifdef _DEVDEBUG_
1835  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1836 #endif
1837  throw ConversionException(msg.str());
1838 }
Class for conversion from Neutral Output port to Xml Input port.

References DEBTRACE, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), YACS::ENGINE::TypeCode::isAdaptable(), and YACS::ENGINE::TypeCode::kind().

◆ adaptCppToPython()

InputPort * RuntimeSALOME::adaptCppToPython ( InputCppPort inport,
TypeCode type 
)
virtual

Adapt a C++ input port to a Python output port.

Parameters
inport: input port to adapt to Python type type
type: output port type
Returns
an adaptated input port of type InputPyPort

Definition at line 1769 of file RuntimeSALOME.cxx.

1771 {
1772  DEBTRACE("RuntimeSALOME::adaptCppToPython(InputCppPort* inport)");
1773  if(isAdaptableCppPyObject(type,inport->edGetType()))
1774  {
1775  //output type is convertible to input type
1776  return new PyCpp(inport);
1777  }
1778  //output type is not convertible
1779  stringstream msg;
1780  msg << "Cannot connect Python output port with type: " << type->id() ;
1781  msg << " to Cpp input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1782 #ifdef _DEVDEBUG_
1783  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1784 #endif
1785  throw ConversionException(msg.str());
1786 }
int isAdaptableCppPyObject(const TypeCode *t1, const TypeCode *t2)

References DEBTRACE, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), and YACS::ENGINE::isAdaptableCppPyObject().

◆ adaptCppToXml()

InputPort * RuntimeSALOME::adaptCppToXml ( InputCppPort source,
TypeCode type 
)
virtual

Definition at line 1840 of file RuntimeSALOME.cxx.

1842 {
1843  DEBTRACE("RuntimeSALOME::adaptCppToXml(InputCppPort* inport" );
1844  if(isAdaptableCppXml(type,inport->edGetType()))
1845  {
1846  //convertible type
1847  return new XmlCpp(inport);
1848  }
1849  //non convertible type
1850  stringstream msg;
1851  msg << "Cannot connect Xml output port with type: " << type->id() ;
1852  msg << " to Cpp input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1853 #ifdef _DEVDEBUG_
1854  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1855 #endif
1856  throw ConversionException(msg.str());
1857 }
int isAdaptableCppXml(const TypeCode *t1, const TypeCode *t2)
Definition: XMLCppConv.cxx:105

References DEBTRACE, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), and YACS::ENGINE::isAdaptableCppXml().

◆ adaptNeutral()

InputPort * RuntimeSALOME::adaptNeutral ( InputPort source,
const std::string &  impl,
TypeCode type,
bool  init 
)
virtual

Adapt a Neutral input port to connect it to an output port with a given implementation.

Parameters
source: Neutral input port to adapt to implementation impl and type type
impl: output port implementation (C++, Python, Corba, Xml or Neutral)
type: output port supported type
init: if init is true the proxy port will be used in initialization of input port (needs value check)
Returns
the adaptated port

Definition at line 1012 of file RuntimeSALOME.cxx.

1015 {
1016  if(impl == CppNode::IMPL_NAME)
1017  {
1018  return adaptNeutralToCpp(source,type);
1019  }
1020  else if(impl == PythonNode::IMPL_NAME)
1021  {
1022  return adaptNeutralToPython(source,type);
1023  }
1024  else if(impl == CORBANode::IMPL_NAME)
1025  {
1026  return adaptNeutralToCorba(source,type);
1027  }
1028  else if(impl == XmlNode::IMPL_NAME )
1029  {
1030  return adaptNeutralToXml(source,type);
1031  }
1033  {
1034  if(init)
1035  return new NeutralInit(source);
1036  else
1037  return new ProxyPort(source);
1038  }
1039  stringstream msg;
1040  msg << "Cannot connect InputPort : unknown implementation " << impl;
1041  msg << " (" <<__FILE__ << ":" <<__LINE__ << ")";
1042  throw ConversionException(msg.str());
1043 }
Class for initialization of a Neutral port with YACS::ENGINE::Any* object.
virtual InputPort * adaptNeutralToXml(InputPort *inport, TypeCode *type)
Adapt a Neutral input port to a Xml output port.
virtual InputPort * adaptNeutralToCorba(InputPort *inport, TypeCode *type)
Adapt a Neutral input port to a Corba output port.
virtual InputPort * adaptNeutralToPython(InputPort *inport, TypeCode *type)
Adapt a Neutral input port to a Python output port.
virtual InputPort * adaptNeutralToCpp(InputPort *inport, TypeCode *type)
Adapt a Neutral input port to a C++ output port.

◆ adaptNeutralToCorba()

InputPort * RuntimeSALOME::adaptNeutralToCorba ( InputPort inport,
TypeCode type 
)
virtual

Adapt a Neutral input port to a Corba output port.

Parameters
inport: Neutral input port to adapt to Corba type type
type: output port type
Returns
an adaptated input port of type InputCorbaPort

Definition at line 905 of file RuntimeSALOME.cxx.

907 {
908  // BEWARE : using the generic check
909  if(inport->edGetType()->isAdaptable(type))
910  {
911  //the output data is convertible to inport type
912  return new CorbaNeutral(inport);
913  }
914  //non convertible type
915  stringstream msg;
916  msg << "Cannot connect Corba output port with type: " << type->id() ;
917  msg << " to Neutral input port " << inport->getName() << " with type: " << inport->edGetType()->id();
918 #ifdef _DEVDEBUG_
919  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
920 #endif
921  throw ConversionException(msg.str());
922 }

References YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), and YACS::ENGINE::TypeCode::isAdaptable().

◆ adaptNeutralToCpp()

InputPort * RuntimeSALOME::adaptNeutralToCpp ( InputPort inport,
TypeCode type 
)
virtual

Adapt a Neutral input port to a C++ output port.

Parameters
inport: input port to adapt to C++ type type
type: output port type
Returns
an input port of type InputCppPort

Definition at line 985 of file RuntimeSALOME.cxx.

987 {
988  DEBTRACE("RuntimeSALOME::adaptNeutralToCpp(InputPort* inport" );
989  if(isAdaptableNeutralCpp(type,inport->edGetType()))
990  {
991  //convertible type
992  return new CppNeutral(inport);
993  }
994  //non convertible type
995  stringstream msg;
996  msg << "Cannot connect Cpp output port with type: " << type->id() ;
997  msg << " to Neutral input port " << inport->getName() << " with type: " << inport->edGetType()->id();
998 #ifdef _DEVDEBUG_
999  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1000 #endif
1001  throw ConversionException(msg.str());
1002 }
int isAdaptableNeutralCpp(const TypeCode *t1, const TypeCode *t2)

References DEBTRACE, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), and YACS::ENGINE::isAdaptableNeutralCpp().

◆ adaptNeutralToPython()

InputPort * RuntimeSALOME::adaptNeutralToPython ( InputPort inport,
TypeCode type 
)
virtual

Adapt a Neutral input port to a Python output port.

Parameters
inport: input port to adapt to Python type type
type: output port type
Returns
an adaptated input port of type InputPyPort

Definition at line 930 of file RuntimeSALOME.cxx.

932 {
933  // BEWARE : using the generic check
934  if(inport->edGetType()->isAdaptable(type))
935  {
936  //convertible type
937  return new PyNeutral(inport);
938  }
939  //last chance : an py output that is seq[objref] can be connected to a neutral input objref (P13268)
940  else if(type->kind()==Sequence && type->contentType()->kind()==Objref && inport->edGetType()->kind()==Objref)
941  {
942  return new PyNeutral(inport);
943  }
944  //non convertible type
945  stringstream msg;
946  msg << "Cannot connect Python output port with type: " << type->id() ;
947  msg << " to Neutral input port " << inport->getName() << " with type: " << inport->edGetType()->id();
948 #ifdef _DEVDEBUG_
949  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
950 #endif
951  throw ConversionException(msg.str());
952 }
virtual const TypeCode * contentType() const
Definition: TypeCode.cxx:174

References YACS::ENGINE::TypeCode::contentType(), YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), YACS::ENGINE::TypeCode::isAdaptable(), YACS::ENGINE::TypeCode::kind(), YACS::ENGINE::Objref, and YACS::ENGINE::Sequence.

◆ adaptNeutralToXml()

InputPort * RuntimeSALOME::adaptNeutralToXml ( InputPort inport,
TypeCode type 
)
virtual

Adapt a Neutral input port to a Xml output port.

Parameters
inport: input port to adapt to Xml type type
type: output port type
Returns
an input port of type InputXmlPort

Definition at line 960 of file RuntimeSALOME.cxx.

962 {
963  // BEWARE : using the generic check
964  if(inport->edGetType()->isAdaptable(type))
965  {
966  //convertible type
967  return new XmlNeutral(inport);
968  }
969  //non convertible type
970  stringstream msg;
971  msg << "Cannot connect Xml output port with type: " << type->id() ;
972  msg << " to Neutral input port " << inport->getName() << " with type: " << inport->edGetType()->id();
973 #ifdef _DEVDEBUG_
974  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
975 #endif
976  throw ConversionException(msg.str());
977 }

References YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), and YACS::ENGINE::TypeCode::isAdaptable().

◆ adaptPythonToCorba()

InputPort * RuntimeSALOME::adaptPythonToCorba ( InputPyPort inport,
TypeCode type 
)
virtual

Adapt a Python input port to a Corba output port.

Always convert the data

Parameters
inport: InputPort to adapt to Corba type type
type: outport data type
Returns
an adaptator port of Corba type (InputCorbaPort)

Definition at line 1597 of file RuntimeSALOME.cxx.

1599 {
1600  if(inport->edGetType()->kind() == Double)
1601  {
1602  if(isAdaptablePyObjectCorba(type,inport->edGetType()))return new CorbaPyDouble(inport);
1603  }
1604  else if(inport->edGetType()->kind() == Int)
1605  {
1606  if(isAdaptablePyObjectCorba(type,inport->edGetType()))return new CorbaPyInt(inport);
1607  }
1608  else if(inport->edGetType()->kind() == String)
1609  {
1610  if(isAdaptablePyObjectCorba(type,inport->edGetType()))return new CorbaPyString(inport);
1611  }
1612  else if(inport->edGetType()->kind() == Bool)
1613  {
1614  if(isAdaptablePyObjectCorba(type,inport->edGetType()))return new CorbaPyBool(inport);
1615  }
1616  else if(inport->edGetType()->kind() == Objref)
1617  {
1618  if(isAdaptablePyObjectCorba(type,inport->edGetType()))
1619  {
1620  return new CorbaPyObjref(inport);
1621  }
1622  else
1623  {
1624  stringstream msg;
1625  msg << "Cannot connect InputCorbaPort : incompatible objref types " << type->id() << " " << inport->edGetType()->id();
1626  msg << " " << __FILE__ << ":" <<__LINE__;
1627  throw ConversionException(msg.str());
1628  }
1629  }
1630  else if(inport->edGetType()->kind() == Sequence)
1631  {
1632  if(isAdaptablePyObjectCorba(type,inport->edGetType()))
1633  {
1634  return new CorbaPySequence(inport);
1635  }
1636  else
1637  {
1638  stringstream msg;
1639  msg << "Cannot convert this sequence type " ;
1640  msg << __FILE__ << ":" <<__LINE__;
1641  throw ConversionException(msg.str());
1642  }
1643  }
1644  else if(inport->edGetType()->kind() == YACS::ENGINE::Struct)
1645  {
1646  if(isAdaptablePyObjectCorba(type,inport->edGetType()))
1647  {
1648  return new CorbaPyStruct(inport);
1649  }
1650  else
1651  {
1652  stringstream msg;
1653  msg << "Cannot convert this struct type " << type->id() << " to " << inport->edGetType()->id();
1654  msg << " " << __FILE__ << ":" <<__LINE__;
1655  throw ConversionException(msg.str());
1656  }
1657  }
1658  // Adaptation not possible
1659  stringstream msg;
1660  msg << "Cannot connect Corba output port with type: " << type->id() ;
1661  msg << " to Python input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1662 #ifdef _DEVDEBUG_
1663  msg << " ("__FILE__ << ":" << __LINE__ << ")";
1664 #endif
1665  throw ConversionException(msg.str());
1666 }
Class for conversion from CORBA Output port to Python Input port.
Class for conversion from CORBA Output port to Python Input port.
Class for conversion from CORBA Output port to Python Input port.
Class for conversion from CORBA Output port to Python Input port.
Class for conversion from CORBA Output port to Python Input port.
Class for conversion from CORBA Output port to Python Input port.
Class for conversion of struct objects from CORBA Output port to Python Input port.
int isAdaptablePyObjectCorba(const TypeCode *t1, const TypeCode *t2)

References YACS::ENGINE::Bool, YACS::ENGINE::Double, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), YACS::ENGINE::Int, YACS::ENGINE::isAdaptablePyObjectCorba(), YACS::ENGINE::TypeCode::kind(), YACS::ENGINE::Objref, YACS::ENGINE::Sequence, YACS::ENGINE::String, and YACS::ENGINE::Struct.

◆ adaptPythonToCpp()

InputPort * RuntimeSALOME::adaptPythonToCpp ( InputPyPort inport,
TypeCode type 
)
virtual

Adapt a Python input port to a C++ output port.

Parameters
inport: InputPort to adapt to C++ type type
type: outport data type
Returns
an adaptator port of C++ type (InputCppPort)

Definition at line 1513 of file RuntimeSALOME.cxx.

1515 {
1516  DEBTRACE("RuntimeSALOME::adaptPythonToCpp(InputPyPort* inport" );
1517  if(isAdaptablePyObjectCpp(type,inport->edGetType()))
1518  {
1519  //output type is convertible to input type
1520  return new CppPy(inport);
1521  }
1522  //output type is not convertible
1523  stringstream msg;
1524  msg << "Cannot connect Cpp output port with type: " << type->id() ;
1525  msg << " to Python input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1526 #ifdef _DEVDEBUG_
1527  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1528 #endif
1529  throw ConversionException(msg.str());
1530 }
int isAdaptablePyObjectCpp(const TypeCode *t1, const TypeCode *t2)

References DEBTRACE, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), and YACS::ENGINE::isAdaptablePyObjectCpp().

◆ adaptPythonToNeutral()

InputPort * RuntimeSALOME::adaptPythonToNeutral ( InputPyPort inport,
TypeCode type 
)
virtual

Adapt a Python input port to a Neutral data port.

Parameters
inport: InputPort to adapt to Neutral type type
type: outport data type
Returns
an adaptator port of Neutral type (Neutralxxxx)

Definition at line 1539 of file RuntimeSALOME.cxx.

1541 {
1542  if(inport->edGetType()->kind() == Double)
1543  {
1544  if(isAdaptablePyObjectNeutral(type,inport->edGetType()))return new NeutralPyDouble(inport);
1545  }
1546  else if(inport->edGetType()->kind() == Int)
1547  {
1548  if(isAdaptablePyObjectNeutral(type,inport->edGetType()))return new NeutralPyInt(inport);
1549  }
1550  else if(inport->edGetType()->kind() == String)
1551  {
1552  if(isAdaptablePyObjectNeutral(type,inport->edGetType()))return new NeutralPyString(inport);
1553  }
1554  else if(inport->edGetType()->kind() == Bool)
1555  {
1556  if(isAdaptablePyObjectNeutral(type,inport->edGetType()))return new NeutralPyBool(inport);
1557  }
1558  else if(inport->edGetType()->kind() == Objref)
1559  {
1560  if(isAdaptablePyObjectNeutral(type,inport->edGetType()))return new NeutralPyObjref(inport);
1561  }
1562  else if(inport->edGetType()->kind() == Sequence)
1563  {
1564  if(isAdaptablePyObjectNeutral(type,inport->edGetType()))
1565  return new NeutralPySequence(inport);
1566  else
1567  {
1568  stringstream msg;
1569  msg << "Cannot convert this sequence type " ;
1570  msg << __FILE__ << ":" <<__LINE__;
1571  throw ConversionException(msg.str());
1572  }
1573  }
1574  else if(inport->edGetType()->kind() == Struct)
1575  {
1576  if(isAdaptablePyObjectNeutral(type,inport->edGetType())) return new NeutralPyStruct(inport);
1577  }
1578 
1579  // Adaptation not possible
1580  stringstream msg;
1581  msg << "Cannot connect Neutral output port with type: " << type->id() ;
1582  msg << " to Python input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1583 #ifdef _DEVDEBUG_
1584  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1585 #endif
1586  throw ConversionException(msg.str());
1587 }
int isAdaptablePyObjectNeutral(const TypeCode *t1, const TypeCode *t2)

References YACS::ENGINE::Bool, YACS::ENGINE::Double, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), YACS::ENGINE::Int, YACS::ENGINE::isAdaptablePyObjectNeutral(), YACS::ENGINE::TypeCode::kind(), YACS::ENGINE::Objref, YACS::ENGINE::Sequence, YACS::ENGINE::String, and YACS::ENGINE::Struct.

◆ adaptPythonToPython()

InputPort * RuntimeSALOME::adaptPythonToPython ( InputPyPort inport,
TypeCode type,
bool  init 
)
virtual

Adapt a Python input port to a Python output port.

No need to make conversion or cast. Only check, it's possible.

Parameters
inport: InputPort to adapt to Python type type
type: outport data type
init: if init is true the proxy port will be used in initialization of input port (needs value check)
Returns
an adaptator port of type InputPyPort

Definition at line 1483 of file RuntimeSALOME.cxx.

1485 {
1486  if(init)
1487  return new PyInit(inport);
1488 
1489  if(isAdaptablePyObjectPyObject(type,inport->edGetType()))
1490  {
1491  //output data is convertible to input type
1492  //With python, no need to convert. Conversion will be done automatically
1493  //by the interpreter
1494  return new ProxyPort(inport);
1495  }
1496  //output data is not convertible to input type
1497  stringstream msg;
1498  msg << "Cannot connect Python output port with type: " << type->id() ;
1499  msg << " to Python input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1500 #ifdef _DEVDEBUG_
1501  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1502 #endif
1503  throw ConversionException(msg.str());
1504 }
int isAdaptablePyObjectPyObject(const TypeCode *t1, const TypeCode *t2)

References YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), and YACS::ENGINE::isAdaptablePyObjectPyObject().

◆ adaptPythonToXml()

InputPort * RuntimeSALOME::adaptPythonToXml ( InputPyPort inport,
TypeCode type 
)
virtual

Adapt a Python input port to a Xml output port.

Parameters
inport: input port to adapt to Xml type type
type: output port type
Returns
an input port of type InputXmlPort

Definition at line 1675 of file RuntimeSALOME.cxx.

1677 {
1678  // BEWARE : using the generic check
1679  if(inport->edGetType()->isAdaptable(type))
1680  {
1681  //convertible type
1682  return new XmlPython(inport);
1683  }
1684  //non convertible type
1685  stringstream msg;
1686  msg << "Cannot connect Xml output port with type: " << type->id() ;
1687  msg << " to Python input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1688 #ifdef _DEVDEBUG_
1689  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1690 #endif
1691  throw ConversionException(msg.str());
1692 }

References YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), and YACS::ENGINE::TypeCode::isAdaptable().

◆ adaptXmlToCorba()

InputPort * RuntimeSALOME::adaptXmlToCorba ( InputXmlPort inport,
TypeCode type 
)
virtual

Adapt a XML input port to connect it to a CORBA output port.

Parameters
inport: input port to adapt to CORBA type type
type: type supported by output port
Returns
an adaptator port of type InputCorbaPort

Definition at line 1052 of file RuntimeSALOME.cxx.

1054 {
1055  if(isAdaptableXmlCorba(type,inport->edGetType()))
1056  {
1057  //output type is convertible to input type
1058  return new CorbaXml(inport);
1059  }
1060  //output type is not convertible
1061  stringstream msg;
1062  msg << "Cannot connect Corba output port with type: " << type->id() ;
1063  msg << " to Xml input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1064 #ifdef _DEVDEBUG_
1065  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1066 #endif
1067  throw ConversionException(msg.str());
1068 }
int isAdaptableXmlCorba(const TypeCode *t1, const TypeCode *t2)

References YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), and YACS::ENGINE::isAdaptableXmlCorba().

◆ adaptXmlToCpp()

InputPort * RuntimeSALOME::adaptXmlToCpp ( InputXmlPort inport,
TypeCode type 
)
virtual

Adapt a XML input port to a C++ output port.

Parameters
inport: input port to adapt to C++ type type
type: output port type
Returns
an adaptated input port of type InputPyPort

Definition at line 1100 of file RuntimeSALOME.cxx.

1102 {
1103  DEBTRACE("RuntimeSALOME::adaptXmlToCpp(InputPort* inport" );
1104  DEBTRACE(type->kind() << " " << inport->edGetType()->kind() );
1105  if(type->isAdaptable(inport->edGetType()))
1106  {
1107  //the output data is convertible to inport type
1108  return new CppXml(inport);
1109  }
1110  //non convertible type
1111  stringstream msg;
1112  msg << "Cannot connect Cpp output port with type: " << type->id() ;
1113  msg << " to Xml input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1114 #ifdef _DEVDEBUG_
1115  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1116 #endif
1117  throw ConversionException(msg.str());
1118 }

References DEBTRACE, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), YACS::ENGINE::TypeCode::isAdaptable(), and YACS::ENGINE::TypeCode::kind().

◆ adaptXmlToNeutral()

InputPort * RuntimeSALOME::adaptXmlToNeutral ( InputXmlPort inport,
TypeCode type 
)
virtual

Adapt a XML input port to a Neutral output port.

Parameters
inport: input port to adapt to Neutral type type
type: output port type
Returns
an adaptated input port of type Neutralxxxx

Definition at line 1126 of file RuntimeSALOME.cxx.

1128 {
1129  if(inport->edGetType()->isAdaptable(type))
1130  {
1131  //the output data is convertible to inport type
1132  return new NeutralXml(inport);
1133  }
1134  //non convertible type
1135  stringstream msg;
1136  msg << "Cannot connect Xml InputPort to OutputNeutralPort : " ;
1137  msg << "(" <<__FILE__ << ":" <<__LINE__<< ")";
1138  throw ConversionException(msg.str());
1139 }
Class for conversion from Neutral Output port to XML Input port.

References YACS::ENGINE::DataPort::edGetType(), and YACS::ENGINE::TypeCode::isAdaptable().

◆ adaptXmlToPython()

InputPort * RuntimeSALOME::adaptXmlToPython ( InputXmlPort inport,
TypeCode type 
)
virtual

Adapt a XML input port to a Python output port.

Parameters
inport: input port to adapt to Python type type
type: output port type
Returns
an adaptated input port of type InputPyPort

Definition at line 1076 of file RuntimeSALOME.cxx.

1078 {
1079  if(inport->edGetType()->isAdaptable(type))
1080  {
1081  //the output data is convertible to inport type
1082  return new PyXml(inport);
1083  }
1084  //non convertible type
1085  stringstream msg;
1086  msg << "Cannot connect Python output port with type: " << type->id() ;
1087  msg << " to Xml input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1088 #ifdef _DEVDEBUG_
1089  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1090 #endif
1091  throw ConversionException(msg.str());
1092 }

References YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), and YACS::ENGINE::TypeCode::isAdaptable().

◆ adaptXmlToXml()

InputPort * RuntimeSALOME::adaptXmlToXml ( InputXmlPort inport,
TypeCode type,
bool  init 
)
virtual

Adapt a XML input port to a Xml output port.

Parameters
inport: input port to adapt to Xml type type
type: output port type
init: if init is true the proxy port will be used in initialization of input port (needs value check)
Returns
an adaptated input port of type Xmlxxxx

Definition at line 1148 of file RuntimeSALOME.cxx.

1150 {
1151  if(init)
1152  return new ProxyPort(inport);
1153 
1154  if(inport->edGetType()->isAdaptable(type))
1155  return new ProxyPort(inport);
1156 
1157  stringstream msg;
1158  msg << "Cannot connect Xml output port with type: " << type->id() ;
1159  msg << " to Xml input port " << inport->getName() << " with type: " << inport->edGetType()->id();
1160 #ifdef _DEVDEBUG_
1161  msg << " ("<<__FILE__ << ":" << __LINE__<<")";
1162 #endif
1163  throw ConversionException(msg.str());
1164 }

References YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::id(), and YACS::ENGINE::TypeCode::isAdaptable().

◆ convertNeutral()

void * RuntimeSALOME::convertNeutral ( TypeCode type,
Any data 
)
virtual

Convert a YACS::ENGINE::Any object to an external object with type type.

This method is used to convert Neutral objects to script languages. For example Python language. The runtime has one external script language. The object is returned as a void * because engine knows nothing about external script language.

Parameters
typethe type of the converted object if the conversion is possible
datathe object to convert
Returns
the converted object

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 1969 of file RuntimeSALOME.cxx.

1970 {
1971  if(data)
1972  return (void *)convertNeutralPyObject(type,data);
1973  else
1974  {
1975  Py_INCREF(Py_None);
1976  return (void *)Py_None;
1977  }
1978 }
PyObject * convertNeutralPyObject(const TypeCode *t, YACS::ENGINE::Any *data)

References YACS::ENGINE::convertNeutralPyObject().

◆ convertNeutralAsString()

std::string RuntimeSALOME::convertNeutralAsString ( TypeCode type,
Any data 
)
virtual

Convert a YACS::ENGINE::Any object to a string to be used in GUI for example.

engine package does not provide a conversion to string. It has to be implemented in the runtime package.

Parameters
typethe type of the object to convert
datathe object to convert
Returns
the string representation of the object

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 1980 of file RuntimeSALOME.cxx.

1981 {
1982  PyObject* ob;
1983  if(data)
1984  {
1985  // The call to PyGILState_Ensure was moved here because there was also
1986  // a crash when calling convertNeutralPyObject with a sequence of pyobj.
1987  // see also the comment below.
1988  PyGILState_STATE gstate = PyGILState_Ensure();
1989  ob=convertNeutralPyObject(type,data);
1990  std::string s=convertPyObjectToString(ob);
1991 
1992  // Note (Renaud Barate, 8 jan 2013): With Python 2.7, this call to Py_DECREF causes a crash
1993  // (SIGSEGV) when ob is a sequence and the call is not protected with the global interpreter
1994  // lock. I thus added the call to PyGILState_Ensure / PyGILState_Release. It worked fine in
1995  // Python 2.6 without this call. If anyone finds the real reason of this bug and another fix,
1996  // feel free to change this code.
1997  //PyGILState_STATE gstate = PyGILState_Ensure();
1998  Py_DECREF(ob);
1999  PyGILState_Release(gstate);
2000  return s;
2001  }
2002  else
2003  {
2004  return "None";
2005  }
2006 }
virtual std::string convertPyObjectToString(PyObject *ob)

References YACS::ENGINE::convertNeutralPyObject(), and YACS::ENGINE::convertPyObjectToString().

◆ convertPyObjectToString()

std::string RuntimeSALOME::convertPyObjectToString ( PyObject *  ob)
virtual

Definition at line 2008 of file RuntimeSALOME.cxx.

2009 {
2011 }
std::string convertPyObjectToString(PyObject *ob)

References YACS::ENGINE::convertPyObjectToString().

◆ convertStringToPyObject()

PyObject * RuntimeSALOME::convertStringToPyObject ( const std::string &  s)
virtual

Definition at line 2013 of file RuntimeSALOME.cxx.

2014 {
2015  PyObject *mainmod;
2016  PyObject *globals;
2017  PyObject* ob;
2018  PyGILState_STATE gstate = PyGILState_Ensure();
2019  mainmod = PyImport_AddModule("__main__");
2020  globals = PyModule_GetDict(mainmod);
2021  PyObject* d = PyDict_New();
2022  //PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins());
2023  ob= PyRun_String( s.c_str(), Py_eval_input, globals, d);
2024  Py_DECREF(d);
2025  if(ob==NULL)
2026  {
2027  //exception
2028  std::string error;
2029  PyObject* new_stderr = newPyStdOut(error);
2030  PySys_SetObject((char *)"stderr", new_stderr);
2031  PyErr_Print();
2032  PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__stderr__"));
2033  Py_DECREF(new_stderr);
2034  PyGILState_Release(gstate);
2035  throw Exception(error);
2036  }
2037  PyGILState_Release(gstate);
2038  return ob;
2039 }
PyObject * newPyStdOut(std::string &out)
Definition: PyStdout.cxx:129

References YACS::ENGINE::newPyStdOut().

Referenced by YACS::HMI::CommandSetInPortValue::localExecute(), YACS::HMI::CommandSetOutPortValue::localExecute(), YACS::HMI::CommandSetInPortValue::localReverse(), and YACS::HMI::CommandSetOutPortValue::localReverse().

◆ createBloc()

Bloc * RuntimeSALOME::createBloc ( const std::string &  name)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 599 of file RuntimeSALOME.cxx.

600 {
601  return new Bloc(name);
602 }
Composed node to group elementary and composed nodes.
Definition: Bloc.hxx:36

◆ createComponentInstance()

ComponentInstance * RuntimeSALOME::createComponentInstance ( const std::string &  name,
const std::string &  kind = "" 
)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 722 of file RuntimeSALOME.cxx.

724 {
725  ComponentInstance* compo;
726  if(kind == "" || kind == SalomeComponent::KIND)
727  return new SalomeComponent(name);
728  else if(kind == CORBAComponent::KIND)
729  return new CORBAComponent(name);
730  else if(kind == SalomePythonComponent::KIND)
731  return new SalomePythonComponent(name);
732  else if (kind == CppComponent::KIND)
733  return new CppComponent(name);
734  else if (kind == SalomeHPComponent::KIND)
735  return new SalomeHPComponent(name);
736  std::string msg="Component Instance kind ("+kind+") unknown";
737  throw Exception(msg);
738 }
Class for CORBA component instance.
Base class for all component instances.
static const char KIND[]
Class for Salome component instance.

◆ createCompoNode()

ServiceNode * RuntimeSALOME::createCompoNode ( const std::string &  kind,
const std::string &  name 
)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 697 of file RuntimeSALOME.cxx.

698 {
699  ServiceNode* node;
700  if(kind == "" || kind == SalomeNode::KIND )
701  {
702  node=new SalomeNode(name);
703  return node;
704  }
705  else if (kind == CppNode::KIND)
706  {
707  node = new CppNode(name);
708  return node;
709  }
710  std::string msg="CompoNode kind ("+kind+") unknown";
711  throw Exception(msg);
712 }
Class for C++ Nodes (in process component)
Definition: CppNode.hxx:47
static const char KIND[]
Definition: CppNode.hxx:62
Class for Salome component Service Node.
Definition: CORBANode.hxx:68
static const char KIND[]
Definition: CORBANode.hxx:78
Class for calculation node associated with a component service.
Definition: ServiceNode.hxx:35

◆ createContainer()

Container * RuntimeSALOME::createContainer ( const std::string &  kind = "")
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 740 of file RuntimeSALOME.cxx.

741 {
742  if(kind == "" || kind == SalomeContainer::KIND)
743  return new SalomeContainer;
744  if(kind==SalomeHPContainer::KIND)
745  return new SalomeHPContainer;
746  else if (kind == CppContainer::KIND)
747  return new CppContainer;
748  std::string msg="Container kind ("+kind+") unknown";
749  throw Exception(msg);
750 }

◆ createForLoop()

ForLoop * RuntimeSALOME::createForLoop ( const std::string &  name)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 609 of file RuntimeSALOME.cxx.

610 {
611  return new ForLoop(name);
612 }
Class for for loop node.
Definition: ForLoop.hxx:33

◆ createFuncNode()

InlineFuncNode * RuntimeSALOME::createFuncNode ( const std::string &  kind,
const std::string &  name 
)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 654 of file RuntimeSALOME.cxx.

655 {
656  InlineFuncNode* node;
657  if(kind == "" || kind == SalomeNode::KIND || kind == PythonNode::KIND)
658  {
659  node = new PyFuncNode(name);
660  return node;
661  }
662  if(kind == DistributedPythonNode::KIND)
663  return new DistributedPythonNode(name);
664  std::string msg="FuncNode kind ("+kind+") unknown";
665  throw Exception(msg);
666 }
Class for calculation node (function) inlined (and executed) in the schema.
Definition: InlineNode.hxx:93
static const char KIND[]
Definition: PythonNode.hxx:122

◆ createInDataNode()

DataNode * RuntimeSALOME::createInDataNode ( const std::string &  kind,
const std::string &  name 
)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 623 of file RuntimeSALOME.cxx.

624 {
625  DataNode* node;
626  if(kind == "" )
627  {
628  node = new PresetNode(name);
629  return node;
630  }
631  else if(kind == "study" )
632  {
633  return new StudyInNode(name);
634  }
635  std::string msg="DataNode kind ("+kind+") unknown";
636  throw Exception(msg);
637 }
Class for data parameters specification.
Definition: DataNode.hxx:38
Class for data in node.
Definition: PresetNode.hxx:31

◆ createInputDataStreamPort()

InputDataStreamPort * RuntimeSALOME::createInputDataStreamPort ( const std::string &  name,
Node node,
TypeCode type 
)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 812 of file RuntimeSALOME.cxx.

814 {
815  DEBTRACE("createInputDataStreamPort: " << name << " " << type->shortName());
816  if(type->kind() == Objref && std::string(type->shortName(),7) == "CALCIUM")
817  {
818  return new InputCalStreamPort(name,node,type);
819  }
820  else
821  {
822  return new InputDataStreamPort(name,node,type);
823  }
824 }
Class for Input Calcium DataStream Ports.
virtual const char * shortName() const
Definition: TypeCode.cxx:77

References DEBTRACE, YACS::ENGINE::TypeCode::kind(), YACS::ENGINE::Objref, and YACS::ENGINE::TypeCode::shortName().

◆ createInputPort()

InputPort * RuntimeSALOME::createInputPort ( const std::string &  name,
const std::string &  impl,
Node node,
TypeCode type 
)
virtual

Implements YACS::ENGINE::Runtime.

Definition at line 752 of file RuntimeSALOME.cxx.

756 {
757  if(impl == CppNode::IMPL_NAME)
758  {
759  return new InputCppPort(name, node, type);
760  }
761  else if(impl == PythonNode::IMPL_NAME)
762  {
763  return new InputPyPort(name, node, type);
764  }
765  else if(impl == CORBANode::IMPL_NAME)
766  {
767  return new InputCorbaPort(name, node, type);
768  }
769  else if(impl == XmlNode::IMPL_NAME)
770  {
771  return new InputXmlPort(name, node, type);
772  }
773  else
774  {
775  stringstream msg;
776  msg << "Cannot create " << impl << " InputPort" ;
777  msg << " (" << __FILE__ << ":" << __LINE__ << ")";
778  throw Exception(msg.str());
779  }
780 }

◆ createInterfaceTc()

TypeCode * RuntimeSALOME::createInterfaceTc ( const std::string &  id,
const std::string &  name,
std::list< TypeCodeObjref * >  ltc 
)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 575 of file RuntimeSALOME.cxx.

577 {
578  std::string myName;
579  if(id == "") myName = "IDL:" + name + ":1.0";
580  else myName = id;
581  return TypeCode::interfaceTc(myName.c_str(),name.c_str(),ltc);
582 }
static TypeCode * interfaceTc(const char *id, const char *name)
static factory of object reference type given an id and a name
Definition: TypeCode.cxx:229

◆ createOptimizerLoop()

OptimizerLoop * RuntimeSALOME::createOptimizerLoop ( const std::string &  name,
const std::string &  algLib,
const std::string &  factoryName,
bool  algInitOnFile,
const std::string &  kind = "",
Proc procForTypes = NULL 
)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 614 of file RuntimeSALOME.cxx.

616 {
617  OptimizerLoop * ol = (kind == "base") ? new OptimizerLoop(name,algLib,factoryName,algInitOnFile, true, procForTypes) :
618  new SalomeOptimizerLoop(name,algLib,factoryName,algInitOnFile, true, procForTypes);
619  ol->edGetNbOfBranchesPort()->edInit(1);
620  return ol;
621 }
InputPort * edGetNbOfBranchesPort()
Definition: DynParaLoop.hxx:83
void edInit(T value)
Definition: InputPort.hxx:129
class to build optimization loops
class to build optimization loops

References YACS::ENGINE::DynParaLoop::edGetNbOfBranchesPort(), and YACS::ENGINE::InputPort::edInit().

◆ createOutDataNode()

DataNode * RuntimeSALOME::createOutDataNode ( const std::string &  kind,
const std::string &  name 
)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 639 of file RuntimeSALOME.cxx.

640 {
641  if(kind == "" )
642  {
643  return new OutNode(name);
644  }
645  else if(kind == "study" )
646  {
647  return new StudyOutNode(name);
648  }
649 
650  std::string msg="OutDataNode kind ("+kind+") unknown";
651  throw Exception(msg);
652 }
Class for data out node.
Definition: OutNode.hxx:30

◆ createOutputDataStreamPort()

OutputDataStreamPort * RuntimeSALOME::createOutputDataStreamPort ( const std::string &  name,
Node node,
TypeCode type 
)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 826 of file RuntimeSALOME.cxx.

828 {
829  DEBTRACE("createOutputDataStreamPort: " << name << " " << type->shortName());
830  if(type->kind() == Objref && std::string(type->shortName(),7) == "CALCIUM")
831  {
832  return new OutputCalStreamPort(name,node,type);
833  }
834  else
835  {
836  return new OutputDataStreamPort(name,node,type);
837  }
838 }
Class for Output Calcium DataStream Ports.

References DEBTRACE, YACS::ENGINE::TypeCode::kind(), YACS::ENGINE::Objref, and YACS::ENGINE::TypeCode::shortName().

◆ createOutputPort()

OutputPort * RuntimeSALOME::createOutputPort ( const std::string &  name,
const std::string &  impl,
Node node,
TypeCode type 
)
virtual

Implements YACS::ENGINE::Runtime.

Definition at line 782 of file RuntimeSALOME.cxx.

786 {
787  if(impl == CppNode::IMPL_NAME)
788  {
789  return new OutputCppPort(name, node, type);
790  }
791  else if(impl == PythonNode::IMPL_NAME)
792  {
793  return new OutputPyPort(name, node, type);
794  }
795  else if(impl == CORBANode::IMPL_NAME)
796  {
797  return new OutputCorbaPort(name, node, type);
798  }
799  else if(impl == XmlNode::IMPL_NAME)
800  {
801  return new OutputXmlPort(name, node, type);
802  }
803  else
804  {
805  stringstream msg;
806  msg << "Cannot create " << impl << " OutputPort" ;
807  msg << " (" << __FILE__ << ":" << __LINE__ << ")";
808  throw Exception(msg.str());
809  }
810 }
Class for XML Output Ports.
Definition: XMLPorts.hxx:68

◆ createProc()

Proc * RuntimeSALOME::createProc ( const std::string &  name)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 570 of file RuntimeSALOME.cxx.

571 {
572  return new SalomeProc(name);
573 }

Referenced by YACS::HMI::Invocator::Invocator(), and YACS::HMI::GenericGui::onNewSchema().

◆ createRefNode()

ServiceNode * RuntimeSALOME::createRefNode ( const std::string &  kind,
const std::string &  name 
)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 680 of file RuntimeSALOME.cxx.

681 {
682  ServiceNode* node;
683  if(kind == "" || kind == SalomeNode::KIND || kind == CORBANode::KIND)
684  {
685  node = new CORBANode(name);
686  return node;
687  }
688  else if(kind == XmlNode::KIND)
689  {
690  node = new XmlNode(name);
691  return node;
692  }
693  std::string msg="RefNode kind ("+kind+") unknown";
694  throw Exception(msg);
695 }
Class for CORBA Service Node.
Definition: CORBANode.hxx:45
static const char KIND[]
Definition: CORBANode.hxx:54
static const char KIND[]
Definition: XMLNode.hxx:47

◆ createScriptNode()

InlineNode * RuntimeSALOME::createScriptNode ( const std::string &  kind,
const std::string &  name 
)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 668 of file RuntimeSALOME.cxx.

669 {
670  InlineNode* node;
671  if(kind == "" || kind == SalomeNode::KIND || kind == PythonNode::KIND)
672  {
673  node = new PythonNode(name);
674  return node;
675  }
676  std::string msg="ScriptNode kind ("+kind+") unknown";
677  throw Exception(msg);
678 }
Class for calculation node (script) inlined (and executed) in the schema.
Definition: InlineNode.hxx:44

◆ createSequenceTc()

TypeCode * RuntimeSALOME::createSequenceTc ( const std::string &  id,
const std::string &  name,
TypeCode content 
)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 584 of file RuntimeSALOME.cxx.

587 {
588  return TypeCode::sequenceTc(id.c_str(),name.c_str(),content);
589 };
static TypeCode * sequenceTc(const char *id, const char *name, TypeCode *content)
static factory of sequence type given an id, a name and a content type
Definition: TypeCode.cxx:254

◆ createSInlineNode()

ServiceInlineNode * RuntimeSALOME::createSInlineNode ( const std::string &  kind,
const std::string &  name 
)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 714 of file RuntimeSALOME.cxx.

715 {
716  if(kind == "" || kind == SalomeNode::KIND )
717  return new SalomePythonNode(name);
718  std::string msg="CompoNode kind ("+kind+") unknown";
719  throw Exception(msg);
720 }

◆ createStructTc()

TypeCodeStruct * RuntimeSALOME::createStructTc ( const std::string &  id,
const std::string &  name 
)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 591 of file RuntimeSALOME.cxx.

592 {
593  std::string myName;
594  if(id == "") myName = "IDL:" + name + ":1.0";
595  else myName = id;
596  return (TypeCodeStruct *)TypeCode::structTc(myName.c_str(),name.c_str());
597 }
Class for struct type.
Definition: TypeCode.hxx:228
static TypeCode * structTc(const char *id, const char *name)
static factory of struct type given an id and a name
Definition: TypeCode.cxx:269

◆ createWhileLoop()

WhileLoop * RuntimeSALOME::createWhileLoop ( const std::string &  name)
virtual

Reimplemented from YACS::ENGINE::Runtime.

Definition at line 604 of file RuntimeSALOME.cxx.

605 {
606  return new WhileLoop(name);
607 }
Class for a while loop.
Definition: WhileLoop.hxx:39

◆ fini()

void RuntimeSALOME::fini ( bool  isFinalizingPython = true)
virtual

Definition at line 423 of file RuntimeSALOME.cxx.

424 {
425  if (_usePython)
426  {
427  PyGILState_STATE gstate = PyGILState_Ensure();
428 #ifdef REFCNT
429  DEBTRACE("_orb refCount: " << ((omniOrbORB*)_orb.in())->pd_refCount);
430 #endif
431  PyObject *mainmod, *globals;
432  mainmod = PyImport_AddModule("__main__");
433  globals = PyModule_GetDict(mainmod);
434  if (_useCorba)
435  {
436  PyObject* res;
437  res=PyRun_String("orb.destroy()\n"
438  "\n",
439  Py_file_input,globals,globals );
440  if(res == NULL)
441  PyErr_Print();
442  else
443  Py_DECREF(res);
444  }
445  std::map<std::string,Node*>& nodeMap=_builtinCatalog->_nodeMap;
446  delete nodeMap["PyFunction"];
447  delete nodeMap["PyScript"];
448  delete nodeMap["SalomePythonNode"];
449  nodeMap.erase("PyFunction");
450  nodeMap.erase("PyScript");
451  nodeMap.erase("SalomePythonNode");
452 
453  if( isFinalizingPython )
454  Py_Finalize();
455 #ifdef REFCNT
456  DEBTRACE("_orb refCount: " << ((omniOrbORB*)_orb.in())->pd_refCount);
457 #endif
458  }
459  else
460  {
461  if (_useCorba)
462  {
463 #ifdef REFCNT
464  DEBTRACE("_orb refCount: " << ((omniOrbORB*)_orb.in())->pd_refCount);
465 #endif
466  _orb->destroy();
467  }
468  }
469 }
std::map< std::string, Node * > _nodeMap
Definition: Catalog.hxx:51
Catalog * _builtinCatalog
Definition: Runtime.hxx:153

References DEBTRACE.

◆ get_omnipy()

PyObject * RuntimeSALOME::get_omnipy ( )

Definition at line 1959 of file RuntimeSALOME.cxx.

1960 {
1961  return _omnipy;
1962 }

◆ getApi()

omniORBpyAPI * RuntimeSALOME::getApi ( )

Definition at line 1964 of file RuntimeSALOME.cxx.

1965 {
1966  return _api;
1967 }

Referenced by YACS::ENGINE::convertFromYacsObjref< PYTHONImpl, PyObject * >::convert().

◆ getBuiltins()

PyObject * RuntimeSALOME::getBuiltins ( ) const

Definition at line 1949 of file RuntimeSALOME.cxx.

1950 {
1951  return _bltins;
1952 }

◆ getCatalogOfComputeNodes()

std::vector< std::pair< std::string, int > > RuntimeSALOME::getCatalogOfComputeNodes ( ) const
virtual

Implements YACS::ENGINE::Runtime.

Definition at line 503 of file RuntimeSALOME.cxx.

504 {
505  CORBA::ORB_ptr orb(getOrb());
506  SALOME_NamingService_Wrapper namingService;
507  try
508  {
509  namingService.init_orb(orb);
510  }
511  catch(SALOME_Exception& e)
512  {
513  throw Exception("RuntimeSALOME::getCatalogOfComputeNodes : Unable to contact the SALOME Naming Service");
514  }
515  CORBA::Object_var obj(namingService.Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS));
516  if(CORBA::is_nil(obj))
517  throw Exception("RuntimeSALOME::getCatalogOfComputeNodes : Unable to access to the resource manager !");
518  Engines::ResourcesManager_var resManager(Engines::ResourcesManager::_narrow(obj));
519  if(CORBA::is_nil(resManager))
520  throw Exception("RuntimeSALOME::getCatalogOfComputeNodes : Internal error ! The entry attached to the res manager in NS does not have right type !");
521  std::vector< std::pair<std::string,int> > ret;
522  Engines::ResourceParameters params;
523  params.name = "";
524  params.hostname = "";
525  params.OS = "";
526  params.nb_proc = 0;
527  params.mem_mb = 0;
528  params.cpu_clock = 0;
529  params.nb_node = 0;
530  params.nb_proc_per_node = 0;
531  params.policy = "";
532  params.can_launch_batch_jobs = false;
533  params.can_run_containers = true;
534  params.componentList.length(0);
535  try
536  {
537  Engines::ResourceList_var resourceList;
538  resourceList = resManager->GetFittingResources(params);
539  ret.reserve(resourceList->length());
540  for(int i = 0; i<resourceList->length(); i++)
541  {
542  const char* resource_name = resourceList[i];
543  std::string std_resource_name = resource_name;
544  Engines::ResourceDefinition_var resource_definition
545  = resManager->GetResourceDefinition(resource_name);
546  int nb_cores = resource_definition->nb_node *
547  resource_definition->nb_proc_per_node;
548  ret.push_back(std::pair<std::string,int>(resource_name, nb_cores));
549  }
550  }
551  catch(SALOME::SALOME_Exception& e)
552  {
553  std::string message;
554  message=e.details.text.in();
555  throw Exception(message);
556  }
557 
558  return ret;
559 }
void init_orb(CORBA::ORB_ptr orb=0) override
CORBA::Object_ptr Resolve(const char *Path) override
CORBA::ORB_ptr getOrb() const
CORBA::ORB_ptr orb
Definition: yacsSrv.cxx:39

References yacsorb.CORBAEngineTest::i, SALOME_NamingService_Wrapper::init_orb(), orb, and SALOME_NamingService_Wrapper::Resolve().

◆ getConnectionManager()

ConnectionManager& YACS::ENGINE::RuntimeSALOME::getConnectionManager ( )
inline

Definition at line 246 of file RuntimeSALOME.hxx.

246 {return _connectionManager;}

◆ getDynFactory()

◆ getFromNS()

CORBA::Object_var RuntimeSALOME::getFromNS ( const char *  entry) const

Retrieve from custom NS the entry. Custom NS is supposed to be hosted in current process. This method try to emulate CORBA ns convention : "corbaname:rir:#test.my_context/Echo.Object" is converted into "Echo"

See Engines::EmbeddedNamingService

Definition at line 1920 of file RuntimeSALOME.cxx.

1921 {
1922  CORBA::Object_var ret;
1923  std::string entryCpp(entry);
1924  if(entryCpp.substr(0,4) == "IOR:")
1925  {
1926  ret = _orb->string_to_object( entry );
1927  }
1928  else
1929  {
1930  auto pos = entryCpp.find_last_of('/');
1931  std::string entry1( entryCpp.substr(pos+1,std::string::npos) );
1932  pos = entry1.find_last_of('.');
1933  std::string entry2( entry1.substr(0,pos) );
1934  Engines::EmbeddedNamingService_var ns = GetEmbeddedNamingService();
1935  std::unique_ptr<Engines::IORType> iorRet( ns->Resolve( entry2.c_str() ) );
1936  auto len = iorRet->length();
1937  std::unique_ptr<char[]> iorTrans(new char[len+1]); iorTrans[len] = '\0';
1938  for(auto i = 0 ; i < len ; ++i) iorTrans[i] = (*iorRet)[i];
1939  ret = _orb->string_to_object(iorTrans.get());
1940  }
1941  return ret;
1942 }

References yacsorb.CORBAEngineTest::i.

Referenced by YACS::ENGINE::convertFromYacsObjref< PYTHONImpl, PyObject * >::convert(), YACS::ENGINE::convertFromYacsObjref< CORBAImpl, CORBA::Any * >::convert(), and YACS::ENGINE::CORBAComponent::load().

◆ getNS()

std::unique_ptr< SALOME_NamingService_Container_Abstract > RuntimeSALOME::getNS ( )

Definition at line 138 of file RuntimeSALOME.cxx.

139 {
140  std::unique_ptr<SALOME_NamingService_Container_Abstract> ret(new SALOME_NamingService_Wrapper);
141  return ret;
142 }

◆ getOrb()

◆ getPyOrb()

PyObject * RuntimeSALOME::getPyOrb ( ) const

Definition at line 1944 of file RuntimeSALOME.cxx.

1945 {
1946  return _pyorb;
1947 }

Referenced by YACS::ENGINE::PyCorbaObjref::PyCorbaObjref().

◆ getSingleton()

static Runtime* YACS::ENGINE::RuntimeSALOME::getSingleton ( )
inlinestaticprivate

Definition at line 60 of file RuntimeSALOME.hxx.

60 { return Runtime::_singleton; }
static Runtime * _singleton
Definition: Runtime.hxx:150

References YACS::ENGINE::Runtime::_singleton.

◆ getVersion()

std::string RuntimeSALOME::getVersion ( ) const
virtual

Definition at line 561 of file RuntimeSALOME.cxx.

562 {
563 #ifdef YACS_DEVELOPMENT
564  return CORBA::string_dup(YACS_VERSION_STR"dev");
565 #else
566  return CORBA::string_dup(YACS_VERSION_STR);
567 #endif
568 }

◆ init()

void RuntimeSALOME::init ( long  flags,
int  argc,
char *  argv[] 
)
virtual

CORBA and Python initialization.

Parameters
flagscontains several bits bit0 (ispyext) true when method is called from Python (Python initialization must not be done!) bit1 (UsePython) true if python nodes are needed bit1 (UseCorba) true if CORBA nodes are needed bit1 (UseXml) true if python nodes are needed bit1 (UseCpp) true if C++ nodes are needed bit1 (UseSalome) true if Salome nodes are needed
argcnumber of command line arguments (used to initialize the Python interpreter)
argvcommand line arguments (used to initialize the Python interpreter)

Definition at line 280 of file RuntimeSALOME.cxx.

281 {
282  bool ispyext = flags & RuntimeSALOME::IsPyExt;
283  if (_useCorba)
284  {
285  PortableServer::POA_var root_poa;
286  PortableServer::POAManager_var pman;
287  CORBA::Object_var obj;
288  int nbargs = 0; char **args = 0;
289  _orb = CORBA::ORB_init (nbargs, args);
290  obj = _orb->resolve_initial_references("RootPOA");
291  root_poa = PortableServer::POA::_narrow(obj);
292  pman = root_poa->the_POAManager();
293  pman->activate();
294 
295 #ifdef REFCNT
296  DEBTRACE("_orb refCount: " << ((omniOrbORB*)_orb.in())->pd_refCount);
297 #endif
298  obj = _orb->resolve_initial_references("DynAnyFactory");
299  _dynFactory = DynamicAny::DynAnyFactory::_narrow(obj);
300  }
301 
302  if (_usePython)
303  {
304  DEBTRACE("RuntimeSALOME::init, is python extension = " << ispyext);
305 
306  // Initialize Python interpreter in embedded mode
307  if (!Py_IsInitialized())
308  {
309 #if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0
310  Py_Initialize();
311 #else
312  Py_InitializeEx(0); // do not install signal handlers
313 #endif
314  if (argc > 0 && argv != NULL)
315  {
316  wchar_t **changed_argv = new wchar_t*[argc];
317  for (int i = 0; i < argc; i++)
318  {
319  changed_argv[i] = Py_DecodeLocale(argv[i], NULL);
320  }
321  PySys_SetArgv(argc, changed_argv);
322  }
323  else
324  {
325  int pyArgc = 1;
326  char* pyArgv[1];
327  char defaultName[] = "SALOME_YACS_RUNTIME";
328  wchar_t **changed_pyArgv = new wchar_t*[pyArgc];
329  pyArgv[0] = defaultName;
330  for (int i = 0; i < pyArgc; i++)
331  {
332  changed_pyArgv[i] = Py_DecodeLocale(pyArgv[i], NULL);
333  }
334  PySys_SetArgv(pyArgc, changed_pyArgv);
335  }
336 #if PY_VERSION_HEX < 0x03070000
337  PyEval_InitThreads(); /* Create (and acquire) the interpreter lock (for threads)*/
338 #endif
339  PyEval_SaveThread(); /* Release the thread state */
340  //here we do not have the Global Interpreter Lock
341  }
342 
343  PyObject *mainmod,*pyapi,*res ;
344  PyObject *globals;
345  PyGILState_STATE gstate;
346  gstate = PyGILState_Ensure(); // acquire the Global Interpreter Lock
347 
348  mainmod = PyImport_AddModule("__main__");
349  globals = PyModule_GetDict(mainmod);
350  /* globals is a borrowed reference */
351 
352  if (PyDict_GetItemString(globals, "__builtins__") == NULL)
353  {
354  PyObject *bimod = PyImport_ImportModule("builtins");
355  if (bimod == NULL || PyDict_SetItemString(globals, "__builtins__", bimod) != 0)
356  Py_FatalError("can't add __builtins__ to __main__");
357  Py_DECREF(bimod);
358  }
359 
360  _bltins = PyEval_GetBuiltins(); /* borrowed ref */
361 
362  if (_useCorba)
363  {
364 
365  //init section
366  _omnipy = PyImport_ImportModule((char*)"_omnipy");
367  if (!_omnipy)
368  {
369  PyErr_Print();
370  PyErr_SetString(PyExc_ImportError, (char*)"Cannot import _omnipy");
371  goto out;
372  }
373  pyapi = PyObject_GetAttrString(_omnipy, (char*)"API");
374  if (!pyapi)
375  {
376  goto out;
377  }
378  _api = (omniORBpyAPI*)PyCapsule_GetPointer(pyapi,"_omnipy.API");
379  Py_DECREF(pyapi);
380 
381  res=PyRun_String("\n"
382  "from math import *\n"
383  "import sys\n"
384  "sys.path.insert(0,'.')\n"
385  "from omniORB import CORBA\n"
386  "from omniORB import any\n"
387  "orb = CORBA.ORB_init([], CORBA.ORB_ID)\n"
388  "#print(sys.getrefcount(orb))\n"
389  "try:\n"
390  " import SALOME\n"
391  "except:\n"
392  " pass\n"
393  "\n",
394  Py_file_input,globals,globals );
395  if(res == NULL)
396  {
397  PyErr_Print();
398  goto out;
399  }
400  Py_DECREF(res);
401 
402  _pyorb = PyDict_GetItemString(globals,"orb");
403  /* PyDict_GetItemString returns a borrowed reference. There is no need to decref _pyorb */
404 
405  PyObject *pyany;
406  pyany = PyDict_GetItemString(globals,"any");
407  /* PyDict_GetItemString returns a borrowed reference. There is no need to decref pyany */
408 
409 #ifdef REFCNT
410  DEBTRACE("_orb refCount: " << ((omniOrbORB*)_orb.in())->pd_refCount);
411 #endif
412  }
413  out:
414  PyGILState_Release(gstate); // Release the Global Interpreter Lock
415  }
416  if (_useCorba)
417  {
418  // initialize the catalogLoaderFactory map with the session one
420  }
421 }
static wchar_t * Py_DecodeLocale(const char *arg, size_t *size)

References driver_internal::args, DEBTRACE, yacsorb.CORBAEngineTest::i, and Py_DecodeLocale().

◆ initBuiltins()

void RuntimeSALOME::initBuiltins ( )
protected

Definition at line 170 of file RuntimeSALOME.cxx.

171 {
172  //Fill the builtin catalog with nodes specific to the runtime
173  std::map<std::string,TypeCode*>& typeMap=_builtinCatalog->_typeMap;
174  std::map<std::string,Node*>& nodeMap=_builtinCatalog->_nodeMap;
175  std::map<std::string,ComposedNode*>& composednodeMap=_builtinCatalog->_composednodeMap;
176  std::map<std::string,ComponentDefinition*>& componentMap=_builtinCatalog->_componentMap;
177  nodeMap["PyFunction"]=new PyFuncNode("PyFunction");
178  nodeMap["PyScript"]=new PythonNode("PyScript");
179  nodeMap["CORBANode"]=new CORBANode("CORBANode");
180  nodeMap["XmlNode"]=new XmlNode("XmlNode");
181  nodeMap["SalomeNode"]=new SalomeNode("SalomeNode");
182  nodeMap["CppNode"]=new CppNode("CppNode");
183  nodeMap["SalomePythonNode"]=new SalomePythonNode("SalomePythonNode");
184  nodeMap["PresetNode"]=new PresetNode("PresetNode");
185  nodeMap["OutNode"]=new OutNode("OutNode");
186  nodeMap["StudyInNode"]=new StudyInNode("StudyInNode");
187  nodeMap["StudyOutNode"]=new StudyOutNode("StudyOutNode");
188  composednodeMap["OptimizerLoop"]=createOptimizerLoop("OptimizerLoop","","",true);
189  typeMap["dblevec"]= createSequenceTc("dblevec","dblevec",_tc_double);
190  typeMap["intvec"]= createSequenceTc("intvec","intvec",_tc_int);
191  typeMap["stringvec"]= createSequenceTc("stringvec","stringvec",_tc_string);
192  typeMap["boolvec"]= createSequenceTc("boolvec","boolvec",_tc_bool);
193  typeMap["seqdblevec"]= createSequenceTc("seqdblevec","seqdblevec",typeMap["dblevec"]);
194  typeMap["seqintvec"]= createSequenceTc("seqintvec","seqintvec",typeMap["intvec"]);
195  typeMap["seqstringvec"]= createSequenceTc("seqstringvec","seqstringvec",typeMap["stringvec"]);
196  typeMap["seqboolvec"]= createSequenceTc("seqboolvec","seqboolvec",typeMap["boolvec"]);
197  std::list<TypeCodeObjref *> ltc;
198  typeMap["pyobj"]= createInterfaceTc("python:obj:1.0","pyobj",ltc);
199  typeMap["seqpyobj"]= createSequenceTc("seqpyobj","seqpyobj",typeMap["pyobj"]);
200  composednodeMap["Bloc"]=createBloc("Bloc");
201  composednodeMap["Switch"]=createSwitch("Switch");
202  composednodeMap["WhileLoop"]=createWhileLoop("WhileLoop");
203  composednodeMap["ForLoop"]=createForLoop("ForLoop");
204  composednodeMap["ForEachLoop_double"]=createForEachLoop("ForEachLoop_double",Runtime::_tc_double);
205  composednodeMap["ForEachLoop_string"]=createForEachLoop("ForEachLoop_string",Runtime::_tc_string);
206  composednodeMap["ForEachLoop_int"]=createForEachLoop("ForEachLoop_int",Runtime::_tc_int);
207  composednodeMap["ForEachLoop_bool"]=createForEachLoop("ForEachLoop_bool",Runtime::_tc_bool);
208  composednodeMap["ForEachLoop_pyobj"]=createForEachLoop("ForEachLoop_pyobj",typeMap["pyobj"]);;
209  ENGINE::TypeCodeStruct *t = createStructTc("","Engines/dataref");
210  t->addMember("ref",_tc_string);
211  typeMap["dataref"]= t;
212 }
std::map< std::string, ComposedNode * > _composednodeMap
Definition: Catalog.hxx:52
std::map< std::string, ComponentDefinition * > _componentMap
Definition: Catalog.hxx:50
std::map< std::string, TypeCode * > _typeMap
Definition: Catalog.hxx:49
virtual WhileLoop * createWhileLoop(const std::string &name)
virtual TypeCodeStruct * createStructTc(const std::string &id, const std::string &name)
virtual TypeCode * createSequenceTc(const std::string &id, const std::string &name, TypeCode *content)
virtual TypeCode * createInterfaceTc(const std::string &id, const std::string &name, std::list< TypeCodeObjref * > ltc)
virtual Bloc * createBloc(const std::string &name)
virtual ForLoop * createForLoop(const std::string &name)
virtual OptimizerLoop * createOptimizerLoop(const std::string &name, const std::string &algLib, const std::string &factoryName, bool algInitOnFile, const std::string &kind="", Proc *procForTypes=NULL)
static YACS::ENGINE::TypeCode * _tc_double
Definition: Runtime.hxx:136
virtual Switch * createSwitch(const std::string &name)
Definition: Runtime.cxx:236
static YACS::ENGINE::TypeCode * _tc_bool
Definition: Runtime.hxx:138
virtual ForEachLoop * createForEachLoop(const std::string &name, TypeCode *type)
Definition: Runtime.cxx:251
static YACS::ENGINE::TypeCode * _tc_int
Definition: Runtime.hxx:137
static YACS::ENGINE::TypeCode * _tc_string
Definition: Runtime.hxx:139

References gui.Appli::t.

◆ launchSubProcess()

PyObject * RuntimeSALOME::launchSubProcess ( const std::vector< std::string > &  cmds)

Definition at line 471 of file RuntimeSALOME.cxx.

472 {
473  std::ostringstream oss; oss << "from subprocess import Popen" << std::endl;
474  oss << "p = Popen([";
475  for(auto i = 0 ; i < cmds.size() ; ++i)
476  {
477  oss << " " << "\"" << cmds[i] << "\"";
478  if(i < cmds.size()-1)
479  oss << ", ";
480  else
481  oss << " ";
482  }
483  oss << "])";
484  AutoGIL agil;
485  AutoPyRef context = PyDict_New();
486  PyDict_SetItemString( context, "__builtins__", getBuiltins() );
487  std::string errorDetails;
488  try
489  {
490  PythonNode::ExecuteLocalInternal(oss.str().c_str(),context,errorDetails);
491  }
492  catch(const YACS::Exception& e)
493  {
494  std::cerr << e.what() << std::endl << errorDetails << std::endl;
495  throw e;
496  }
497  PyObject *ret = PyDict_GetItemString(context,"p");
498  Py_XINCREF(ret);
499  Py_XINCREF(ret);
500  return ret;
501 }
static void ExecuteLocalInternal(const std::string &codeStr, PyObject *context, std::string &errorDetails)
Definition: PythonNode.cxx:730
PyObject * getBuiltins() const
const char * what(void) const noexcept
Definition: Exception.cxx:50

References yacsorb.CORBAEngineTest::i, and YACS::Exception::what().

◆ loadModulCatalog()

void RuntimeSALOME::loadModulCatalog ( )

Definition at line 256 of file RuntimeSALOME.cxx.

257 {
258  AutoGIL agil;
259  const char * SCRIPT = "from salome_kernel import list_of_catalogs_regarding_environement\n"
260 "import KernelModuleCatalog\n"
261 "KernelModuleCatalog.myModuleCatalog( list_of_catalogs_regarding_environement() )\n";
262  PyRun_SimpleString(SCRIPT);
263 }

Referenced by main(), and shutdownServers().

◆ setRuntime()

void RuntimeSALOME::setRuntime ( long  flags = UsePython+UseCorba+UseXml+UseCpp+UseSalome,
int  argc = 0,
char *  argv[] = NULL 
)
static

Definition at line 144 of file RuntimeSALOME.cxx.

145 {
146  if (! Runtime::_singleton)
147  {
148  RuntimeSALOME* r=new RuntimeSALOME(flags, argc, argv);
150  r->initBuiltins();
151  }
152  DEBTRACE("RuntimeSALOME::setRuntime() done !");
153 }

References DEBTRACE, and testCppPluginInvokation::r.

Referenced by driverTest(), YACS::HMI::GenericGui::GenericGui(), and main().

Friends And Related Function Documentation

◆ getSALOMERuntime

RuntimeSALOME* getSALOMERuntime ( )
friend

Member Data Documentation

◆ _api

omniORBpyAPI* YACS::ENGINE::RuntimeSALOME::_api
protected

Definition at line 256 of file RuntimeSALOME.hxx.

◆ _bltins

PyObject* YACS::ENGINE::RuntimeSALOME::_bltins
protected

Definition at line 254 of file RuntimeSALOME.hxx.

◆ _connectionManager

ConnectionManager YACS::ENGINE::RuntimeSALOME::_connectionManager
private

Definition at line 262 of file RuntimeSALOME.hxx.

◆ _dynFactory

DynamicAny::DynAnyFactory_var YACS::ENGINE::RuntimeSALOME::_dynFactory
protected

Definition at line 255 of file RuntimeSALOME.hxx.

◆ _flags

long YACS::ENGINE::RuntimeSALOME::_flags
protected

Definition at line 258 of file RuntimeSALOME.hxx.

◆ _omnipy

PyObject* YACS::ENGINE::RuntimeSALOME::_omnipy
protected

Definition at line 257 of file RuntimeSALOME.hxx.

◆ _orb

CORBA::ORB_var YACS::ENGINE::RuntimeSALOME::_orb
protected

Definition at line 252 of file RuntimeSALOME.hxx.

◆ _pyorb

PyObject* YACS::ENGINE::RuntimeSALOME::_pyorb
protected

Definition at line 253 of file RuntimeSALOME.hxx.

◆ _useCorba

bool YACS::ENGINE::RuntimeSALOME::_useCorba
protected

Definition at line 259 of file RuntimeSALOME.hxx.

◆ _useCpp

bool YACS::ENGINE::RuntimeSALOME::_useCpp
protected

Definition at line 259 of file RuntimeSALOME.hxx.

◆ _usePython

bool YACS::ENGINE::RuntimeSALOME::_usePython
protected

Definition at line 259 of file RuntimeSALOME.hxx.

◆ _useXml

bool YACS::ENGINE::RuntimeSALOME::_useXml
protected

Definition at line 259 of file RuntimeSALOME.hxx.

◆ 

enum { ... } YACS::ENGINE::RuntimeSALOME::FLAGS

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