EXPORT_HEADERS = SALOME_LifeCycleCORBA.hxx
-EXPORT_PYSCRIPTS = LifeCycleCORBA.py Launchers.py
+EXPORT_PYSCRIPTS = Launchers.py
# Libraries targets
SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns)
{
- _NS = ns;
+ if (!ns)
+ {
+ int argc = 0;
+ char *xargv = "";
+ char **argv = &xargv;
+ CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+ _NS = new SALOME_NamingService(orb);
+ }
+ else _NS = ns;
//add try catch
_NS->Change_Directory("/"); // mpv 250105: current directory may be not root
// (in SALOMEDS for an example)
//=============================================================================
/*! Public -
* Find and aready existing and registered component instance or load a new
- * component instance on a container defined by machine parameters
+ * component instance on a container defined by machine parameters.
+ * Renamed (Else / Or) to avoid problems with Python (Swig) version and keep
+ * compatiblity with existing Python method FindOrLoadComponent
* \param params machine parameters like type or name...
* \param componentName the name of component class
* \param studyId default = 0 : multistudy instance
Engines::Component_ptr
SALOME_LifeCycleCORBA::
-FindOrLoad_Component(const Engines::MachineParameters& params,
- const char *componentName,
- int studyId)
+FindElseLoadComponent(const Engines::MachineParameters& params,
+ const char *componentName,
+ int studyId)
{
if (! isKnownComponentClass(componentName))
return Engines::Component::_nil();
params->hostname=CORBA::string_dup(stContainer);
params->OS=CORBA::string_dup("LINUX");
free(stContainer);
- return FindOrLoad_Component(params,componentName);
+ return FindElseLoadComponent(params,componentName);
}
}
class SALOME_LifeCycleCORBA
{
public:
- SALOME_LifeCycleCORBA(SALOME_NamingService *ns);
+ SALOME_LifeCycleCORBA(SALOME_NamingService *ns = 0);
virtual ~SALOME_LifeCycleCORBA();
Engines::Container_ptr
int studyId=0);
Engines::Component_ptr
- FindOrLoad_Component(const Engines::MachineParameters& params,
- const char *componentName,
- int studyId=0);
+ FindElseLoadComponent(const Engines::MachineParameters& params,
+ const char *componentName,
+ int studyId=0);
Engines::Component_ptr
FindOrLoad_Component(const char *containerName,
--- /dev/null
+# SALOME LifeCycleCORBA : implementation of containers and engines life cycle both in Python and C++
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : LifeCycleCORBA.py
+# Author : Paul RASCLE, EDF
+# Module : SALOME
+# $Header$
+
+
+import Engines
+from libSALOME_LifeCycleCORBA import *
+
+class LifeCycleCORBA (SALOME_LifeCycleCORBA):
+
+ def __init__(self, orb = None):
+ SALOME_LifeCycleCORBA.__init__(self)
+
+ def FindOrLoadComponent(self, containerName, componentName):
+ return SALOME_LifeCycleCORBA.FindOrLoad_Component(self,
+ containerName,
+ componentName)
--- /dev/null
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : Makefile.in
+# Author : Paul RASCLE, EDF
+# Module : SALOME
+# $Header$
+
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl
+
+
+@COMMENCE@
+
+# Libraries targets
+
+LIB = libSALOME_LifeCycleCORBAcmodule.la
+LIB_SRC =
+
+LIB_CLIENT_IDL = SALOME_Component.idl SALOME_ContainerManager.idl
+
+SWIG_DEF = libSALOME_LifeCycleCORBA.i
+
+EXPORT_PYSCRIPTS = libSALOME_LifeCycleCORBA.py LifeCycleCORBA.py TestLifeCycleCORBA.py
+
+CPPFLAGS+= $(PYTHON_INCLUDES)
+
+LIBS+= $(PYTHON_LIBS) -lSalomeLifeCycleCORBA
+
+LDFLAGS+=
+
+@CONCLUDE@
--- /dev/null
+
+import Engines
+import LifeCycleCORBA
+
+lcc = LifeCycleCORBA.LifeCycleCORBA()
+
+obj=lcc.FindOrLoad_Component("FactoryServer","SalomeTestComponent")
+comp=obj._narrow(Engines.TestComponent)
+comp.Coucou(1)
+
--- /dev/null
+
+
+%module libSALOME_LifeCycleCORBA
+
+%{
+#include "utilities.h"
+#include "SALOME_LifeCycleCORBA.hxx"
+
+ using namespace std;
+%}
+
+%typemap(python,out) Engines::Container_ptr, Engines::Component_ptr
+{
+ MESSAGE("typemap out on CORBA object ptr");
+ SCRUTE($1);
+
+ // --- Get the Python orb
+
+ PyObject* pdict = PyDict_New();
+ PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
+ PyRun_String("import CORBA", Py_single_input, pdict, pdict);
+ PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
+ pdict, pdict);
+ PyObject* orb = PyDict_GetItemString(pdict, "o");
+
+ // --- Get the C++ orb
+
+ int argc = 0;
+ char *xargv = "";
+ char **argv = &xargv;
+ CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
+ string s = ORB->object_to_string($1);
+ SCRUTE(s);
+ PyObject * tmp = PyString_FromString(s.c_str());
+ SCRUTE(tmp);
+ $result = PyObject_CallMethod(orb, "string_to_object", "O", tmp);
+ SCRUTE($result);
+}
+
+%typemap(python,in) const Engines::MachineParameters &
+{
+ MESSAGE("typemap in on Engines::MachineParameters");
+ ASSERT (PyDict_Check($input))
+ {
+ Engines::MachineParameters *param = new Engines::MachineParameters ;
+ PyObject *key, *value;
+ int pos = 0;
+ while (PyDict_Next($input, &pos, &key, &value))
+ {
+ char* keystr = PyString_AsString(key);
+ MESSAGE("key: " << keystr);
+ if (strcmp(keystr,"container_name")==0)
+ {
+ param->container_name = CORBA::string_dup(PyString_AsString(value));
+ }
+ else if (strcmp(keystr,"hostname")==0)
+ {
+ param->hostname = CORBA::string_dup(PyString_AsString(value));
+ }
+ else if (strcmp(keystr,"OS")==0)
+ {
+ param->OS = CORBA::string_dup(PyString_AsString(value));
+ }
+ else if (strcmp(keystr,"mem_mb")==0)
+ {
+ param->mem_mb = PyLong_AsLong(value);
+ }
+ else if (strcmp(keystr,"cpu_clock")==0)
+ {
+ param->cpu_clock = PyLong_AsLong(value);
+ }
+ else if (strcmp(keystr,"nb_proc_per_node")==0)
+ {
+ param->nb_proc_per_node = PyLong_AsLong(value);
+ }
+ else if (strcmp(keystr,"nb_node")==0)
+ {
+ param->nb_node = PyLong_AsLong(value);
+ }
+ }
+ $1 = param;
+ }
+}
+
+%typemap(python,freearg) const Engines::MachineParameters &
+{
+ MESSAGE("delete $1");
+ delete $1;
+}
+
+%include "SALOME_LifeCycleCORBA.hxx"
GenericObj MEDWrapper NamingService Registry \
ModuleCatalog DataTypeCatalog RessourcesCatalog \
ResourcesManager Notification NOTIFICATION_SWIG \
- Container TestContainer LifeCycleCORBA HDFPersist Prs \
+ Container TestContainer LifeCycleCORBA LifeCycleCORBA_SWIG HDFPersist Prs \
VTKFilter OBJECT \
TOOLSDS SALOMEDS Event \
SALOMEGUI TOOLSGUI Plot2d VTKViewer OCCViewer \