Salome HOME
4a35577e12f33e2a9988df814177a7faed6b20ac
[modules/yacs.git] / src / SALOMEDS / SALOMEDS.cxx
1 //  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOMEDS.cxx
25 //  Author : Sergey ANIKIN
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef WNT
30 #include <SALOMEDS.hxx>
31 #include <SALOMEDS_StudyManager.hxx>
32 #include <SALOMEDS_Study.hxx>
33 #include <SALOMEDS_SObject.hxx>
34 #include <SALOMEDS_SComponent.hxx>
35 #include <SALOMEDSClient.hxx>
36 #include <SALOMEDS_StudyManager_i.hxx>
37 #else
38 #include "SALOMEDS.hxx"
39 #include "SALOMEDS_StudyManager.hxx"
40 #include "SALOMEDS_Study.hxx"
41 #include "SALOMEDS_SObject.hxx"
42 #include "SALOMEDS_SComponent.hxx"
43 #include "SALOMEDSClient.hxx"
44 #include "SALOMEDS_StudyManager_i.hxx"
45 #endif
46
47 // IDL headers
48 #include <SALOMEconfig.h>
49 #include CORBA_SERVER_HEADER(SALOMEDS)
50
51 using namespace SALOMEDS;
52
53 // PAL8065: san -- Global recursive mutex for SALOMEDS methods
54 Utils_Mutex Locker::MutexDS;
55
56 // PAL8065: san -- Global SALOMEDS locker
57 Locker::Locker()
58 : Utils_Locker( &MutexDS )
59 {}
60
61 Locker::~Locker()
62 {}
63
64 void SALOMEDS::lock()
65 {
66   Locker::MutexDS.lock();
67 }
68
69 void SALOMEDS::unlock()
70 {
71   Locker::MutexDS.unlock();
72 }
73
74
75
76 // srn: Added new library methods that create basic SALOMEDS objects (StudyManager, Study, SComponent, SObject)
77
78 //=============================================================================
79 /*!
80  * C factory, accessible with dlsym, after dlopen
81  */
82 //=============================================================================
83
84
85 extern "C"
86 {
87
88 SALOMEDSClient_StudyManager* StudyManagerFactory()
89 {
90   return new SALOMEDS_StudyManager();
91 }
92
93 SALOMEDSClient_Study* StudyFactory(SALOMEDS::Study_ptr theStudy)
94 {
95   return new SALOMEDS_Study(theStudy);
96 }
97
98 SALOMEDSClient_SObject* SObjectFactory(SALOMEDS::SObject_ptr theSObject)
99 {
100   return new SALOMEDS_SObject(theSObject);
101 }
102
103 SALOMEDSClient_SComponent* SComponentFactory(SALOMEDS::SComponent_ptr theSComponent)
104 {
105   return new SALOMEDS_SComponent(theSComponent);
106 }
107
108 SALOMEDSClient_StudyManager* CreateStudyManager(CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa)
109 {
110   SALOMEDS_StudyManager_i * aStudyManager_i = new  SALOMEDS_StudyManager_i(orb, root_poa);
111   // Activate the objects.  This tells the POA that the objects are ready to accept requests.
112   PortableServer::ObjectId_var aStudyManager_iid =  root_poa->activate_object(aStudyManager_i);
113   aStudyManager_i->register_name("/myStudyManager");
114   return new SALOMEDS_StudyManager();
115 }
116
117 }