0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / BOPAlgo / BOPAlgo_Algo.cxx
1 // Created by: Peter KURNEV
2 // Copyright (c) 2010-2014 OPEN CASCADE SAS
3 // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
5 //                         EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 //
7 // This file is part of Open CASCADE Technology software library.
8 //
9 // This library is free software; you can redistribute it and/or modify it under
10 // the terms of the GNU Lesser General Public License version 2.1 as published
11 // by the Free Software Foundation, with special exception defined in the file
12 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
13 // distribution for complete text of the license and disclaimer of any warranty.
14 //
15 // Alternatively, this file may be used under the terms of Open CASCADE
16 // commercial license or contractual agreement.
17
18
19 #include <BOPAlgo_Algo.hxx>
20 #include <Message_ProgressIndicator.hxx>
21 #include <NCollection_BaseAllocator.hxx>
22 #include <Standard_NotImplemented.hxx>
23 #include <Standard_ProgramError.hxx>
24
25 namespace
26 {
27   Standard_Boolean myGlobalRunParallel = Standard_False;
28 }
29
30 //=======================================================================
31 // function: 
32 // purpose: 
33 //=======================================================================
34 void BOPAlgo_Algo::SetParallelMode(Standard_Boolean theNewMode)
35 {
36   myGlobalRunParallel = theNewMode;
37 }
38
39 //=======================================================================
40 // function: 
41 // purpose: 
42 //=======================================================================
43 Standard_Boolean BOPAlgo_Algo::GetParallelMode()
44 {
45   return myGlobalRunParallel;
46 }
47
48
49 //=======================================================================
50 // function: 
51 // purpose: 
52 //=======================================================================
53 BOPAlgo_Algo::BOPAlgo_Algo()
54 :
55   myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()),
56   myErrorStatus(1),
57   myWarningStatus(0),
58   myRunParallel(myGlobalRunParallel)
59 {}
60 //=======================================================================
61 // function: 
62 // purpose: 
63 //=======================================================================
64 BOPAlgo_Algo::BOPAlgo_Algo
65   (const Handle(NCollection_BaseAllocator)& theAllocator)
66 :
67   myAllocator(theAllocator),
68   myErrorStatus(1),
69   myWarningStatus(0),
70   myRunParallel(myGlobalRunParallel)
71 {}
72
73 //=======================================================================
74 // function: ~
75 // purpose: 
76 //=======================================================================
77 BOPAlgo_Algo::~BOPAlgo_Algo()
78 {
79 }
80 //=======================================================================
81 //function : Allocator
82 //purpose  : 
83 //=======================================================================
84 const Handle(NCollection_BaseAllocator)& BOPAlgo_Algo::Allocator()const
85 {
86   return myAllocator;
87 }
88 //=======================================================================
89 // function: CheckData
90 // purpose: 
91 //=======================================================================
92 void BOPAlgo_Algo::CheckData()
93 {
94   myErrorStatus=0;
95 }
96 //=======================================================================
97 // function: CheckResult
98 // purpose: 
99 //=======================================================================
100 void BOPAlgo_Algo::CheckResult()
101 {
102   myErrorStatus=0;
103 }
104 //=======================================================================
105 // function: ErrorStatus
106 // purpose: 
107 //=======================================================================
108 Standard_Integer BOPAlgo_Algo::ErrorStatus()const
109 {
110   return myErrorStatus;
111 }
112 //=======================================================================
113 // function: WarningStatus
114 // purpose: 
115 //=======================================================================
116 Standard_Integer BOPAlgo_Algo::WarningStatus()const
117 {
118   return myWarningStatus;
119 }
120 //=======================================================================
121 //function : SetRunParallel
122 //purpose  : 
123 //=======================================================================
124 void BOPAlgo_Algo::SetRunParallel(const Standard_Boolean theFlag)
125 {
126   myRunParallel=theFlag;
127 }
128 //=======================================================================
129 //function : RunParallel
130 //purpose  : 
131 //=======================================================================
132 Standard_Boolean BOPAlgo_Algo::RunParallel()const
133 {
134   return myRunParallel;
135 }
136 //=======================================================================
137 //function : SetProgressIndicator
138 //purpose  : 
139 //=======================================================================
140 void BOPAlgo_Algo::SetProgressIndicator
141   (const Handle(Message_ProgressIndicator)& theObj)
142 {
143   if (!theObj.IsNull()) {
144     myProgressIndicator=theObj;
145   }
146 }
147 //=======================================================================
148 //function : UserBreak
149 //purpose  : 
150 //=======================================================================
151 void BOPAlgo_Algo::UserBreak() const
152 {
153   if (myProgressIndicator.IsNull()) {
154     return;
155   }
156   if (myProgressIndicator->UserBreak()) {
157     Standard_NotImplemented::Raise("");
158   }
159
160 //  myErrorStatus
161 //
162 // 1 - object is just initialized