Salome HOME
0020523: String notebook support
[modules/kernel.git] / src / SALOMEDS / SALOMEDS.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
23 //  File   : SALOMEDS.hxx
24 //  Author : Sergey ANIKIN
25 //  Module : SALOME
26 //  $Header$
27 //
28 #ifndef SALOMEDS_HeaderFile
29 #define SALOMEDS_HeaderFile
30
31 #include "SALOMEDS_Defines.hxx"
32
33 #include <Utils_Mutex.hxx>
34
35 namespace SALOMEDS
36 {
37   // PAL8065: san -- Implementation of convenient locker based on simple recursive 
38   // mutex for POSIX platforms.
39   // This class is to protect SALOMEDS CORBA methods which deal with OCC calls from 
40   // parallel access by several threads
41   // To protect some method, an instance of Locker class should be created
42   // on the stack at the beginning of guarded code:
43   //
44   //    Locker lock;
45   //
46   class SALOMEDS_EXPORT Locker : public Utils_Locker
47   {
48   public:
49     Locker();
50     virtual ~Locker();
51
52   private:
53     static Utils_Mutex MutexDS;
54
55     friend void lock();
56     friend void unlock();
57   };
58
59   // Convenient functions to lock/unlock the global SALOMEDS mutex temporarily.
60   // In particular, "unlock-dosomething-lock" scheme should be used, when some non-SALOMEDS
61   // CORBA interface is called (component's engine), to avoid deadlocks in case of 
62   // indirect recursion.
63   void lock();
64   void unlock();
65 };
66
67 #endif