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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
1 /**
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
2 * Stone of Orthanc
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
6 *
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
10 * the License, or (at your option) any later version.
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
11 *
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
15 * Affero General Public License for more details.
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
16 *
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
19 **/
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
20
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
21
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
22 #pragma once
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
23
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
24 #include "../../Framework/Viewport/WidgetViewport.h"
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
25 #include "../../Framework/Volumes/ISlicedVolume.h"
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
26 #include "../../Framework/Volumes/IVolumeLoader.h"
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
27 #include "../../Framework/Widgets/IWorldSceneInteractor.h"
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
28
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
29 #include <list>
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
30 #include <boost/thread.hpp>
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
31 #include "../BasicApplicationContext.h"
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
32
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
33 namespace OrthancStone
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
34 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
35 class BasicSdlApplicationContext : public BasicApplicationContext
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
36 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
37 private:
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
38
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
39 static void UpdateThread(BasicSdlApplicationContext* that);
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
40
271
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
41 boost::mutex globalMutex_;
233
68856534f005 added layout to VSOL, SDL & wasm working
am@osimis.io
parents: 222
diff changeset
42 std::unique_ptr<WidgetViewport> centralViewport_;
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
43 boost::thread updateThread_;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
44 bool stopped_;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
45 unsigned int updateDelay_;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
46
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
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
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
49 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
50 boost::mutex::scoped_lock lock_;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
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
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
55 };
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
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
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
76
271
46c5296d867e OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents: 242
diff changeset
77 BasicSdlApplicationContext();
222
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
78
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
79 virtual ~BasicSdlApplicationContext() {}
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
80
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
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
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
83
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
84 void Start();
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
85
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
86 void Stop();
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
87
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
88 void SetUpdateDelay(unsigned int delay) // In milliseconds
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
89 {
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
90 updateDelay_ = delay;
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
91 }
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
92 };
84844649a8fd continued: reusable applications
am@osimis.io
parents:
diff changeset
93 }