annotate Applications/Generic/NativeStoneApplicationContext.h @ 418:c23df8b3433b

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 15 Nov 2018 18:32:48 +0100
parents 6cc3ce74dc05
children 8999823db8b8 b70e9be013e4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
274
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
1 /**
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
2 * Stone of Orthanc
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
6 *
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
10 * the License, or (at your option) any later version.
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
11 *
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
15 * Affero General Public License for more details.
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
16 *
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
19 **/
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
20
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
21
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
22 #pragma once
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
23
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
24 #include "../../Framework/Viewport/WidgetViewport.h"
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
25 #include "../../Framework/Volumes/ISlicedVolume.h"
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
26 #include "../../Framework/Volumes/IVolumeLoader.h"
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
27
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
28 #include <list>
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
29 #include <boost/thread.hpp>
288
8c8da145fefa renamings and doc
am@osimis.io
parents: 277
diff changeset
30 #include "../StoneApplicationContext.h"
274
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
31
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
32 namespace OrthancStone
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
33 {
291
87376a645ee1 renaming
am@osimis.io
parents: 288
diff changeset
34 class NativeStoneApplicationContext : public StoneApplicationContext
274
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
35 {
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
36 private:
291
87376a645ee1 renaming
am@osimis.io
parents: 288
diff changeset
37 static void UpdateThread(NativeStoneApplicationContext* that);
274
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
38
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
39 boost::mutex globalMutex_;
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
40 WidgetViewport centralViewport_;
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
41 boost::thread updateThread_;
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
42 bool stopped_;
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
43 unsigned int updateDelayInMs_;
274
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
44
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
45 public:
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
46 class GlobalMutexLocker: public boost::noncopyable
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
47 {
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
48 private:
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
49 NativeStoneApplicationContext& that_;
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
50 boost::mutex::scoped_lock lock_;
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
51
274
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
52 public:
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
53 GlobalMutexLocker(NativeStoneApplicationContext& that) :
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
54 that_(that),
274
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
55 lock_(that.globalMutex_)
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
56 {
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
57 }
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
58
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
59 IWidget& SetCentralWidget(IWidget* widget); // Takes ownership
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
60
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
61 IViewport& GetCentralViewport()
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
62 {
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
63 return that_.centralViewport_;
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
64 }
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
65
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
66 void SetUpdateDelay(unsigned int delayInMs)
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
67 {
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
68 that_.updateDelayInMs_ = delayInMs;
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
69 }
418
c23df8b3433b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 385
diff changeset
70
c23df8b3433b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 385
diff changeset
71 MessageBroker& GetMessageBroker()
c23df8b3433b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 385
diff changeset
72 {
c23df8b3433b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 385
diff changeset
73 return that_.GetMessageBroker();
c23df8b3433b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 385
diff changeset
74 }
274
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
75 };
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
76
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
77 NativeStoneApplicationContext(MessageBroker& broker);
274
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
78
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
79 void Start();
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
80
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
81 void Stop();
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
82 };
dc1beee33134 split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff changeset
83 }