# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
+include(${SWIG_USE_FILE})
+
INCLUDE_DIRECTORIES(
${OMNIORB_INCLUDE_DIR}
${PTHREAD_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../LifeCycleCORBA
${CMAKE_CURRENT_SOURCE_DIR}
${PROJECT_BINARY_DIR}/idl
+ ${PYTHON_INCLUDE_DIRS}
)
SET(SalomeNS_SOURCES
FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
+
+SET(NamingService_HEADERS NamingService.i)
+SET(NamingService_SOURCES ${NamingService_HEADERS})
+SET_SOURCE_FILES_PROPERTIES(NamingService.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(NamingService.i PROPERTIES SWIG_FLAGS "-py3")
+SET_SOURCE_FILES_PROPERTIES(NamingService_wrap.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H")
+SET(_swig_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/NamingService.py )
+IF(${CMAKE_VERSION} VERSION_LESS "3.8.0")
+ SWIG_ADD_MODULE(NamingService python ${NamingService_SOURCES})
+ELSE()
+ SWIG_ADD_LIBRARY(NamingService LANGUAGE python SOURCES ${NamingService_SOURCES})
+ENDIF()
+SWIG_LINK_LIBRARIES(NamingService ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} SalomeNS)
+install(TARGETS _NamingService DESTINATION ${SALOME_INSTALL_LIBS})
+install(FILES ${NamingService_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
+SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}" ${SALOME_INSTALL_BINS} EXTRA_DPYS "${SWIG_MODULE_NamingService_REAL_NAME}")
--- /dev/null
+// Copyright (C) 2021 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module NamingService
+
+%{
+#include "SALOME_Fake_NamingService.hxx"
+#include "SALOME_KernelORB.hxx"
+%}
+
+%include "std_string.i"
+%include "std_vector.i"
+
+%rename(NamingService) SALOME_Fake_NamingService ;
+
+%template(svec) std::vector<std::string>;
+
+class SALOME_Fake_NamingService
+{
+public:
+ SALOME_Fake_NamingService();
+ std::vector< std::string > repr();
+ %extend {
+ std::string _ResolveInternal(const char *Path)
+ {
+ CORBA::Object_var obj = self->Resolve(Path);
+ CORBA::ORB_ptr orb = KERNEL::getORB();
+ CORBA::String_var ior = orb->object_to_string(obj);
+ return std::string(ior);
+ }
+ void _RegisterInternal(const char *ior, const char* Path)
+ {
+ CORBA::ORB_ptr orb = KERNEL::getORB();
+ CORBA::Object_var obj = orb->string_to_object(ior);
+ self->Register(obj,Path);
+ }
+ }
+};
+
+%pythoncode %{
+def NamingService_Resolve(self,Path):
+ ret = self._ResolveInternal(Path)
+ import CORBA
+ orb=CORBA.ORB_init([''])
+ return orb.string_to_object(ret)
+def NamingService_Register(self,obj,Path):
+ import CORBA
+ orb=CORBA.ORB_init([''])
+ self._RegisterInternal( orb.object_to_string(obj) , Path)
+NamingService.Resolve = NamingService_Resolve
+NamingService.Register = NamingService_Register
+%}
{
}
-std::string SALOME_Fake_NamingService::repr()
+std::vector< std::string > SALOME_Fake_NamingService::repr()
{
std::lock_guard<std::mutex> g(_mutex);
- std::ostringstream oss;
+ std::vector< std::string > ret;
for(auto it : _map)
{
- oss << it.first << std::endl;
+ ret.push_back( it.first );
}
- return oss.str();
+ return ret;
}
void SALOME_Fake_NamingService::init_orb(CORBA::ORB_ptr orb)
public:
SALOME_Fake_NamingService(CORBA::ORB_ptr orb);
SALOME_Fake_NamingService() = default;
- std::string repr() override;
+ std::vector< std::string > repr() override;
void init_orb(CORBA::ORB_ptr orb=0) override;
void Register(CORBA::Object_ptr ObjRef, const char* Path) override;
CORBA::Object_ptr Resolve(const char* Path) override;
//MESSAGE("SALOME_NamingService destruction");
}
-std::string SALOME_NamingService::repr()
+std::vector< std::string > SALOME_NamingService::repr()
{
- return std::string();
+ return std::vector< std::string >();
}
// ============================================================================
SALOME_NamingService(CORBA::ORB_ptr orb);
virtual ~SALOME_NamingService();
- std::string repr() override;
+ std::vector< std::string > repr() override;
void init_orb(CORBA::ORB_ptr orb=0) override;
void Register(CORBA::Object_ptr ObjRef, const char* Path) override;
CORBA::Object_ptr Resolve(const char* Path) override;
+++ /dev/null
-// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 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, or (at your option) any later version.
-//
-// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// SALOME NamingService : wrapping NamingService services
-// File : SALOME_NamingService.i
-// Author : Paul RASCLE, EDF
-// Module : SALOME
-// $Header$
-//
-%{
-#include "SALOME_NamingService.hxx"
-//#include <omniORB4/CORBA.h>
-#include <omniORB3/CORBA.h>
-#include "ServiceUnreachable.hxx"
-%}
-
-%except(python)
-{
- try
- {
- $function
- }
- catch (ServiceUnreachable)
- {
- PyErr_SetString(PyExc_IndexError,"Naming Service Unreacheable");
- return NULL;
- }
-}
-
-class SALOME_NamingService
-{
-public:
-
- //! standard constructor
- SALOME_NamingService();
-
- //! standard destructor
- virtual ~SALOME_NamingService();
-
- //! initialize ORB reference after default constructor
- void init_orb(CORBA::ORB_ptr orb);
-
- //! method to create an association in the NamingService between an object reference and a path
- void Register(CORBA::Object_ptr ObjRef, const char* Path)
- throw(ServiceUnreachable);
-
- //! method to get the ObjRef of a symbolic name
- CORBA::Object_ptr Resolve(const char* Path)
- throw( ServiceUnreachable);
-
- //! method to research a name from the naming service's current directory
- int Find(const char* name)
- throw(ServiceUnreachable);
-
- //! method to create a directory from the current directory
- bool Create_Directory(const char* Path)
- throw(ServiceUnreachable);
-
- //! method to change the current directory to the directory Path indicated in "in" Parameter
- bool Change_Directory(const char* Path)
- throw(ServiceUnreachable);
-
- //!method to get the current directory
- char* Current_Directory()
- throw(ServiceUnreachable);
-
- //!method to print all the contexts contained from the current directory
- void list()
- throw(ServiceUnreachable);
-
- //! method to destroy an association Path-Object Reference
- void Destroy_Name(const char* Path)
- throw(ServiceUnreachable);
-
- //! method to destroy a directory if it is empty
- virtual void Destroy_Directory(const char* Path)
- throw(ServiceUnreachable);
-};
-
{
public:
SALOME_NamingService_Abstract *cloneCoVar();
- virtual std::string repr() = 0;
+ virtual std::vector< std::string > repr() = 0;
virtual void Destroy_Directory(const char* Path) = 0;
virtual bool Change_Directory(const char* Path) = 0;
virtual std::vector<std::string> list_subdirs() = 0;