Mercurial > hg > orthanc-stone
annotate Applications/Sdl/BasicSdlApplicationContext.h @ 271:46c5296d867e am-2
OracleWebService and BasicSdlApplicationContext using the same global mutex
author | am@osimis.io |
---|---|
date | Thu, 23 Aug 2018 17:12:54 +0200 |
parents | 092db46c6291 |
children | f21ba2468570 |
rev | line source |
---|---|
222 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "../../Framework/Viewport/WidgetViewport.h" | |
25 #include "../../Framework/Volumes/ISlicedVolume.h" | |
26 #include "../../Framework/Volumes/IVolumeLoader.h" | |
27 #include "../../Framework/Widgets/IWorldSceneInteractor.h" | |
28 | |
29 #include <list> | |
30 #include <boost/thread.hpp> | |
31 #include "../BasicApplicationContext.h" | |
32 | |
33 namespace OrthancStone | |
34 { | |
35 class BasicSdlApplicationContext : public BasicApplicationContext | |
36 { | |
37 private: | |
38 | |
39 static void UpdateThread(BasicSdlApplicationContext* that); | |
40 | |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
41 boost::mutex globalMutex_; |
233 | 42 std::unique_ptr<WidgetViewport> centralViewport_; |
222 | 43 boost::thread updateThread_; |
44 bool stopped_; | |
45 unsigned int updateDelay_; | |
46 | |
47 public: | |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
48 class GlobalMutexLocker: public boost::noncopyable |
222 | 49 { |
50 boost::mutex::scoped_lock lock_; | |
51 public: | |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
52 GlobalMutexLocker(BasicSdlApplicationContext& that): |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
53 lock_(that.globalMutex_) |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
54 {} |
222 | 55 }; |
56 | |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
57 // class ViewportLocker : public boost::noncopyable |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
58 // { |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
59 // private: |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
60 // boost::mutex::scoped_lock lock_; |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
61 // IViewport& viewport_; |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
62 |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
63 // public: |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
64 // ViewportLocker(BasicSdlApplicationContext& that) : |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
65 // lock_(that.viewportMutex_), |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
66 // viewport_(*(that.centralViewport_.get())) |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
67 // { |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
68 // } |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
69 |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
70 // IViewport& GetViewport() const |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
71 // { |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
72 // return viewport_; |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
73 // } |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
74 // }; |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
75 |
222 | 76 |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
77 BasicSdlApplicationContext(); |
222 | 78 |
79 virtual ~BasicSdlApplicationContext() {} | |
80 | |
81 virtual IWidget& SetCentralWidget(IWidget* widget); // Takes ownership | |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
242
diff
changeset
|
82 IViewport& GetCentralViewport() {return *(centralViewport_.get());} |
222 | 83 |
84 void Start(); | |
85 | |
86 void Stop(); | |
87 | |
88 void SetUpdateDelay(unsigned int delay) // In milliseconds | |
89 { | |
90 updateDelay_ = delay; | |
91 } | |
92 }; | |
93 } |