Mercurial > hg > orthanc-stone
comparison Applications/Generic/NativeStoneApplicationContext.h @ 385:6cc3ce74dc05
using message broker in widgets
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 07 Nov 2018 20:49:41 +0100 |
parents | c34784e5f299 |
children | c23df8b3433b |
comparison
equal
deleted
inserted
replaced
384:d20d75f20c5d | 385:6cc3ce74dc05 |
---|---|
32 namespace OrthancStone | 32 namespace OrthancStone |
33 { | 33 { |
34 class NativeStoneApplicationContext : public StoneApplicationContext | 34 class NativeStoneApplicationContext : public StoneApplicationContext |
35 { | 35 { |
36 private: | 36 private: |
37 | |
38 static void UpdateThread(NativeStoneApplicationContext* that); | 37 static void UpdateThread(NativeStoneApplicationContext* that); |
39 | 38 |
40 boost::mutex globalMutex_; | 39 boost::mutex globalMutex_; |
41 std::auto_ptr<WidgetViewport> centralViewport_; | 40 MessageBroker& broker_; |
42 boost::thread updateThread_; | 41 WidgetViewport centralViewport_; |
43 bool stopped_; | 42 boost::thread updateThread_; |
44 unsigned int updateDelayInMs_; | 43 bool stopped_; |
44 unsigned int updateDelayInMs_; | |
45 | 45 |
46 public: | 46 public: |
47 class GlobalMutexLocker: public boost::noncopyable | 47 class GlobalMutexLocker: public boost::noncopyable |
48 { | 48 { |
49 boost::mutex::scoped_lock lock_; | 49 private: |
50 NativeStoneApplicationContext& that_; | |
51 boost::mutex::scoped_lock lock_; | |
52 | |
50 public: | 53 public: |
51 GlobalMutexLocker(NativeStoneApplicationContext& that): | 54 GlobalMutexLocker(NativeStoneApplicationContext& that) : |
55 that_(that), | |
52 lock_(that.globalMutex_) | 56 lock_(that.globalMutex_) |
53 { | 57 { |
54 } | 58 } |
59 | |
60 IWidget& SetCentralWidget(IWidget* widget); // Takes ownership | |
61 | |
62 MessageBroker& GetMessageBroker() const | |
63 { | |
64 return that_.broker_; | |
65 } | |
66 | |
67 IViewport& GetCentralViewport() | |
68 { | |
69 return that_.centralViewport_; | |
70 } | |
71 | |
72 void SetUpdateDelay(unsigned int delayInMs) | |
73 { | |
74 that_.updateDelayInMs_ = delayInMs; | |
75 } | |
55 }; | 76 }; |
56 | 77 |
57 NativeStoneApplicationContext(); | 78 NativeStoneApplicationContext(MessageBroker& broker); |
58 | |
59 virtual ~NativeStoneApplicationContext() | |
60 { | |
61 } | |
62 | |
63 virtual IWidget& SetCentralWidget(IWidget* widget); // Takes ownership | |
64 | |
65 IViewport& GetCentralViewport() | |
66 { | |
67 return *(centralViewport_.get()); | |
68 } | |
69 | 79 |
70 void Start(); | 80 void Start(); |
71 | 81 |
72 void Stop(); | 82 void Stop(); |
73 | |
74 void SetUpdateDelay(unsigned int delayInMs) | |
75 { | |
76 updateDelayInMs_ = delayInMs; | |
77 } | |
78 }; | 83 }; |
79 } | 84 } |