comparison Applications/BasicApplicationContext.h @ 222:84844649a8fd am

continued: reusable applications
author am@osimis.io
date Tue, 12 Jun 2018 17:21:15 +0200
parents d7b2590744f8
children 5027cb2feb51
comparison
equal deleted inserted replaced
221:d7b2590744f8 222:84844649a8fd
19 **/ 19 **/
20 20
21 21
22 #pragma once 22 #pragma once
23 23
24 #include "../Platforms/Generic/OracleWebService.h"
24 #include "../Framework/Viewport/WidgetViewport.h" 25 #include "../Framework/Viewport/WidgetViewport.h"
25 #include "../Framework/Volumes/ISlicedVolume.h"
26 #include "../Framework/Volumes/IVolumeLoader.h"
27 #include "../Framework/Widgets/IWorldSceneInteractor.h"
28 #include "../Platforms/Generic/OracleWebService.h"
29 26
30 #include <list> 27 #include <list>
31 #include <boost/thread.hpp>
32 28
33 namespace OrthancStone 29 namespace OrthancStone
34 { 30 {
35 class BasicApplicationContext : public boost::noncopyable 31 class BasicApplicationContext : public boost::noncopyable
36 { 32 {
37 private:
38
39 static void UpdateThread(BasicApplicationContext* that);
40
41
42 Oracle oracle_;
43 OracleWebService webService_;
44 boost::mutex viewportMutex_;
45 WidgetViewport centralViewport_;
46 boost::thread updateThread_;
47 bool stopped_;
48 unsigned int updateDelay_;
49 33
50 public: 34 public:
51 class ViewportLocker : public boost::noncopyable 35 BasicApplicationContext() {}
52 {
53 private:
54 boost::mutex::scoped_lock lock_;
55 IViewport& viewport_;
56 36
57 public: 37 virtual IWebService& GetWebService() = 0;
58 ViewportLocker(BasicApplicationContext& that) : 38 virtual IWidget& SetCentralWidget(IWidget* widget) = 0; // Takes ownership
59 lock_(that.viewportMutex_),
60 viewport_(that.centralViewport_)
61 {
62 }
63
64 IViewport& GetViewport() const
65 {
66 return viewport_;
67 }
68 };
69
70
71 BasicApplicationContext(Orthanc::WebServiceParameters& orthanc);
72 39
73 virtual ~BasicApplicationContext() {} 40 virtual ~BasicApplicationContext() {}
74
75 IWidget& SetCentralWidget(IWidget* widget); // Takes ownership
76
77 IWebService& GetWebService()
78 {
79 return webService_;
80 }
81
82 void Start();
83
84 void Stop();
85
86 void SetUpdateDelay(unsigned int delay) // In milliseconds
87 {
88 updateDelay_ = delay;
89 }
90 }; 41 };
91 } 42 }