]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
merged with KERNEL from current dev version.
authorasv <asv@opencascade.com>
Mon, 6 Mar 2006 12:38:15 +0000 (12:38 +0000)
committerasv <asv@opencascade.com>
Mon, 6 Mar 2006 12:38:15 +0000 (12:38 +0000)
src/SALOMEDS/SALOMEDS.cxx
src/SALOMEDSClient/Makefile.in
src/SALOMEDSClient/SALOMEDSClient_ClientFactory.cxx [new file with mode: 0644]
src/SALOMEDSClient/SALOMEDSClient_ClientFactory.hxx [new file with mode: 0644]

index ae488ad0a7421c26faf12a33d44c5e809a4a9310..4a35577e12f33e2a9988df814177a7faed6b20ac 100644 (file)
 //  Module : SALOME
 //  $Header$
 
-
 #ifndef WNT
 #include <SALOMEDS.hxx>
+#include <SALOMEDS_StudyManager.hxx>
+#include <SALOMEDS_Study.hxx>
+#include <SALOMEDS_SObject.hxx>
+#include <SALOMEDS_SComponent.hxx>
+#include <SALOMEDSClient.hxx>
+#include <SALOMEDS_StudyManager_i.hxx>
 #else
 #include "SALOMEDS.hxx"
+#include "SALOMEDS_StudyManager.hxx"
+#include "SALOMEDS_Study.hxx"
+#include "SALOMEDS_SObject.hxx"
+#include "SALOMEDS_SComponent.hxx"
+#include "SALOMEDSClient.hxx"
+#include "SALOMEDS_StudyManager_i.hxx"
 #endif
 
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
 using namespace SALOMEDS;
 
 // PAL8065: san -- Global recursive mutex for SALOMEDS methods
@@ -55,3 +70,48 @@ void SALOMEDS::unlock()
 {
   Locker::MutexDS.unlock();
 }
+
+
+
+// srn: Added new library methods that create basic SALOMEDS objects (StudyManager, Study, SComponent, SObject)
+
+//=============================================================================
+/*!
+ * C factory, accessible with dlsym, after dlopen
+ */
+//=============================================================================
+
+
+extern "C"
+{
+
+SALOMEDSClient_StudyManager* StudyManagerFactory()
+{
+  return new SALOMEDS_StudyManager();
+}
+
+SALOMEDSClient_Study* StudyFactory(SALOMEDS::Study_ptr theStudy)
+{
+  return new SALOMEDS_Study(theStudy);
+}
+
+SALOMEDSClient_SObject* SObjectFactory(SALOMEDS::SObject_ptr theSObject)
+{
+  return new SALOMEDS_SObject(theSObject);
+}
+
+SALOMEDSClient_SComponent* SComponentFactory(SALOMEDS::SComponent_ptr theSComponent)
+{
+  return new SALOMEDS_SComponent(theSComponent);
+}
+
+SALOMEDSClient_StudyManager* CreateStudyManager(CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa)
+{
+  SALOMEDS_StudyManager_i * aStudyManager_i = new  SALOMEDS_StudyManager_i(orb, root_poa);
+  // Activate the objects.  This tells the POA that the objects are ready to accept requests.
+  PortableServer::ObjectId_var aStudyManager_iid =  root_poa->activate_object(aStudyManager_i);
+  aStudyManager_i->register_name("/myStudyManager");
+  return new SALOMEDS_StudyManager();
+}
+
+}
index b29a1d0e396fbf71fa0bd0417659c3cba3c4411d..c7cbfedae616327d5ccc61f395697189f5aa6382 100644 (file)
@@ -50,7 +50,35 @@ EXPORT_HEADERS= SALOMEDSClient_definitions.hxx \
                 SALOMEDSClient_StudyManager.hxx \
                 SALOMEDSClient_UseCaseBuilder.hxx \
                 SALOMEDSClient_UseCaseIterator.hxx \
+               SALOMEDSClient_ClientFactory.hxx \
                SALOMEDSClient.hxx
 
+# Libraries targets
+
+LIB = libSalomeDSClient.la
+LIB_SRC = SALOMEDSClient_ClientFactory.cxx
+
+LIB_CLIENT_IDL = SALOMEDS.idl \
+                SALOME_Exception.idl \
+                SALOME_GenericObj.idl
+
+CPPFLAGS+=$(BOOST_CPPFLAGS)
+CXXFLAGS+=$(BOOST_CPPFLAGS)
+#LDFLAGS+= -lSalomeNS
+
+# _CS_gbo_090604 Ajout Spécifique Calibre 3, pour l'utilisation de la version 5.12 de la bibliothèque OCC.
+# La bibliothèque OCC5.12 a été compilée sur Calibre 3 avec l'extention Xmu (impossible de compiler sans).
+# On est donc obligé ici, pour permettre l'édition de lien avec les bibliothèques OCC, de spécifier le
+# chemin d'accès aux bibliothèques Xmu
+#
+
+# _CS_gbo_090604 Ajout Sp.cifique Calibre 3, pour l'utilisation de la version 5.12 de la biblioth.que OCC.
+# La biblioth.que OCC5.12 a .t. compil.e sur Calibre 3 avec l'extention Xmu (impossible de compiler sans).
+# On est donc oblig. ici, pour permettre l'.dition de lien avec les biblioth.ques OCC, de sp.cifier le
+# chemin d'acc.s aux biblioth.ques Xmu
+#
+LDXMUFLAGS= -L/usr/X11R6/lib -lXmu
+LDFLAGS+=$(LDXMUFLAGS)
+
 @CONCLUDE@
 
diff --git a/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.cxx b/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.cxx
new file mode 100644 (file)
index 0000000..4b5e23b
--- /dev/null
@@ -0,0 +1,112 @@
+#include "SALOMEDSClient_ClientFactory.hxx"
+
+#ifdef WIN32
+#include <windows.h>
+static HMODULE _libHandle = 0;
+#define SALOMEDS_LIB_NAME "SalomeDS.dll"
+#else
+#include <dlfcn.h>
+static void* _libHandle = NULL;
+#define SALOMEDS_LIB_NAME "libSalomeDS.so"
+#endif
+
+#define SOBJECT_FACTORY      "SObjectFactory"
+#define SCOMPONENT_FACTORY   "SComponentFactory"
+#define STUDY_FACTORY        "StudyFactory"
+#define STUDYMANAGER_FACTORY "StudyManagerFactory"
+#define STUDYMANAGER_CREATE  "CreateStudyManager"
+
+typedef SALOMEDSClient_SObject* (*SOBJECT_FACTORY_FUNCTION) (SALOMEDS::SObject_ptr);
+typedef SALOMEDSClient_SComponent* (*SCOMPONENT_FACTORY_FUNCTION) (SALOMEDS::SComponent_ptr);
+typedef SALOMEDSClient_Study* (*STUDY_FACTORY_FUNCTION) (SALOMEDS::Study_ptr);
+typedef SALOMEDSClient_StudyManager* (*STUDYMANAGER_FACTORY_FUNCTION) ();
+typedef SALOMEDSClient_StudyManager* (*STUDYMANAGER_CREATE_FUNCTION) (CORBA::ORB_ptr, PortableServer::POA_ptr);
+
+static SOBJECT_FACTORY_FUNCTION aSObjectFactory = NULL;
+static SCOMPONENT_FACTORY_FUNCTION aSComponentFactory = NULL;
+static STUDY_FACTORY_FUNCTION aStudyFactory = NULL;
+static STUDYMANAGER_FACTORY_FUNCTION aManagerFactory = NULL;
+static STUDYMANAGER_CREATE_FUNCTION aCreateFactory = NULL;
+
+using namespace std;
+
+_PTR(SObject) ClientFactory::SObject(SALOMEDS::SObject_ptr theSObject)
+{
+  SALOMEDSClient_SObject* so = NULL;
+
+#ifdef WIN32
+  if(!_libHandle) _libHandle = ::LoadLibrary(SALOMEDS_LIB_NAME);
+  if(!aSObjectFactory) aSObjectFactory = (SOBJECT_FACTORY_FUNCTION)::GetProcAddress(_libHandle, SOBJECT_FACTORY);
+#else
+  if(!_libHandle) _libHandle = dlopen(SALOMEDS_LIB_NAME, RTLD_LAZY | RTLD_GLOBAL);
+  if(!aSObjectFactory) aSObjectFactory = (SOBJECT_FACTORY_FUNCTION) dlsym(_libHandle, SOBJECT_FACTORY);
+#endif
+
+  if(aSObjectFactory) so = aSObjectFactory(theSObject); 
+  return _PTR(SObject)(so);
+}
+
+_PTR(SComponent) ClientFactory::SComponent(SALOMEDS::SComponent_ptr theSComponent)
+{
+  SALOMEDSClient_SComponent* sco = NULL; 
+
+#ifdef WIN32
+  if(!_libHandle) _libHandle = ::LoadLibrary(SALOMEDS_LIB_NAME);
+  if(!aSComponentFactory) aSComponentFactory = (SCOMPONENT_FACTORY_FUNCTION)::GetProcAddress(_libHandle, SCOMPONENT_FACTORY);
+#else
+  if(!_libHandle) _libHandle = dlopen(SALOMEDS_LIB_NAME, RTLD_LAZY | RTLD_GLOBAL);
+  if(!aSComponentFactory) aSComponentFactory = (SCOMPONENT_FACTORY_FUNCTION) dlsym(_libHandle, SCOMPONENT_FACTORY);
+#endif
+
+  if(aSComponentFactory) sco = aSComponentFactory(theSComponent); 
+  return _PTR(SComponent)(sco);
+}
+
+_PTR(Study) ClientFactory::Study(SALOMEDS::Study_ptr theStudy)
+{
+  SALOMEDSClient_Study* study = NULL;
+
+#ifdef WIN32
+  if(!_libHandle) _libHandle = ::LoadLibrary(SALOMEDS_LIB_NAME);
+  if(!aStudyFactory) aStudyFactory = (STUDY_FACTORY_FUNCTION)::GetProcAddress(_libHandle, STUDY_FACTORY);
+#else
+  if(!_libHandle) _libHandle = dlopen(SALOMEDS_LIB_NAME, RTLD_LAZY | RTLD_GLOBAL);
+  if(!aStudyFactory) aStudyFactory = (STUDY_FACTORY_FUNCTION) dlsym(_libHandle, STUDY_FACTORY);
+#endif
+
+  if(aStudyFactory) study = aStudyFactory(theStudy); 
+  return _PTR(Study)(study);
+}
+
+_PTR(StudyManager) ClientFactory::StudyManager()
+{
+  SALOMEDSClient_StudyManager* manager = NULL;
+
+#ifdef WIN32
+  if(!_libHandle) _libHandle = ::LoadLibrary(SALOMEDS_LIB_NAME);
+  if(!aManagerFactory) aManagerFactory = (STUDYMANAGER_FACTORY_FUNCTION)::GetProcAddress(_libHandle, STUDYMANAGER_FACTORY);
+#else
+  if(!_libHandle) _libHandle = dlopen(SALOMEDS_LIB_NAME, RTLD_LAZY | RTLD_GLOBAL);
+  if(!aManagerFactory) aManagerFactory = (STUDYMANAGER_FACTORY_FUNCTION) dlsym(_libHandle, STUDYMANAGER_FACTORY);
+#endif
+
+  if(aManagerFactory) manager = aManagerFactory(); 
+  return _PTR(StudyManager)(manager);
+}
+
+_PTR(StudyManager) ClientFactory::createStudyManager(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa)
+{
+  SALOMEDSClient_StudyManager* manager = NULL;
+
+#ifdef WIN32
+  if(!_libHandle) _libHandle = ::LoadLibrary(SALOMEDS_LIB_NAME);
+  if(!aCreateFactory) aCreateFactory = (STUDYMANAGER_CREATE_FUNCTION)::GetProcAddress(_libHandle, STUDYMANAGER_CREATE);
+#else
+  if(!_libHandle) _libHandle = dlopen(SALOMEDS_LIB_NAME, RTLD_LAZY | RTLD_GLOBAL);
+  if(!aCreateFactory) aCreateFactory = (STUDYMANAGER_CREATE_FUNCTION) dlsym(_libHandle, STUDYMANAGER_CREATE);
+#endif
+
+  if(aCreateFactory)  manager = aCreateFactory(orb, poa);
+  return _PTR(StudyManager)(manager);
+}
+
diff --git a/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.hxx b/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.hxx
new file mode 100644 (file)
index 0000000..8592929
--- /dev/null
@@ -0,0 +1,71 @@
+// Copyright (C) 2006  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.salome-platform.org/
+//
+//  File   : SALOMEDSClient_ClientFactory.hxx
+//  Author : Sergey RUIN
+//  Module : SALOME
+//  $Header:
+
+#ifndef SALOMEDSClient_ClientFactory_HeaderFile
+#define SALOMEDSClient_ClientFactory_HeaderFile
+
+#include "SALOMEDSClient_definitions.hxx" 
+#include "SALOMEDSClient_SObject.hxx"
+#include "SALOMEDSClient_SComponent.hxx"
+#include "SALOMEDSClient_Study.hxx"
+#include "SALOMEDSClient_StudyManager.hxx"
+
+#include <string>
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOMEDS)
+
+class ClientFactory {
+
+public:
+  /*!
+   *  Returns a client SObject wrapper that corresponds %theSObject
+   */
+  static _PTR(SObject) SObject(SALOMEDS::SObject_ptr theSObject);
+
+  /*!
+   *  Returns a client SComponent wrapper that corresponds %theSComponent
+   */
+  static _PTR(SComponent) SComponent(SALOMEDS::SComponent_ptr theSComponent);
+
+  /*!
+   *  Returns a client Study wrapper that corresponds %theStudy
+   */
+  static _PTR(Study) Study(SALOMEDS::Study_ptr theStudy);
+
+  /*!
+   *  Returns a client StudyManager wrapper
+   */
+  static _PTR(StudyManager) StudyManager();
+
+  /*!
+   *  Creates and returns a client StudyManager wrapper
+   */
+  static _PTR(StudyManager) createStudyManager(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa);
+
+  
+};
+
+#endif