e59975f3426dd3be8bbf891279e9bd21b9a970fd
[occt.git] / src / TopTools / TopTools_MutexForShapeProvider.hxx
1 // Created on: 2014-06-27
2 // Created by: Dmitry BOBYLEV
3 // Copyright (c) 2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and / or modify it
8 // under the terms of the GNU Lesser General Public version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _TopTools_MutexForShapeProvider_HeaderFile
17 #define _TopTools_MutexForShapeProvider_HeaderFile
18
19 #include <Handle_TopoDS_TShape.hxx>
20 #include <NCollection_DataMap.hxx>
21 #include <TopAbs_ShapeEnum.hxx>
22
23 class Standard_Mutex;
24 class TopoDS_Shape;
25
26 //! Class TopTools_MutexForShapeProvider 
27 //!   This class is used to create and store mutexes associated with shapes.
28 class TopTools_MutexForShapeProvider
29 {
30 public:
31   //! Constructor
32   Standard_EXPORT TopTools_MutexForShapeProvider();
33
34   //! Destructor
35   Standard_EXPORT ~TopTools_MutexForShapeProvider();
36
37   //! Creates and associates mutexes with each sub-shape of type theType in theShape.
38   Standard_EXPORT void CreateMutexesForSubShapes(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType);
39
40   //! Creates and associates mutex with theShape
41   Standard_EXPORT void CreateMutexForShape(const TopoDS_Shape& theShape);
42
43   //! Returns pointer to mutex associated with theShape.
44   //! In case when mutex not found returns NULL.
45   Standard_EXPORT Standard_Mutex* GetMutex(const TopoDS_Shape& theShape) const;
46
47   //! Removes all mutexes
48   Standard_EXPORT void RemoveAllMutexes();
49
50 private:
51   //! This method should not be called (prohibited).
52   TopTools_MutexForShapeProvider (const TopTools_MutexForShapeProvider &);
53   //! This method should not be called (prohibited).
54   TopTools_MutexForShapeProvider & operator = (const TopTools_MutexForShapeProvider &);
55
56
57   NCollection_DataMap<Handle_TopoDS_TShape, Standard_Mutex *> myMap;
58
59 };
60
61 #endif