Mercurial > hg > orthanc-stone
diff 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 |
line wrap: on
line diff
--- a/Applications/Generic/NativeStoneApplicationContext.h Wed Nov 07 16:17:02 2018 +0100 +++ b/Applications/Generic/NativeStoneApplicationContext.h Wed Nov 07 20:49:41 2018 +0100 @@ -34,46 +34,51 @@ class NativeStoneApplicationContext : public StoneApplicationContext { private: - static void UpdateThread(NativeStoneApplicationContext* that); - boost::mutex globalMutex_; - std::auto_ptr<WidgetViewport> centralViewport_; - boost::thread updateThread_; - bool stopped_; - unsigned int updateDelayInMs_; + boost::mutex globalMutex_; + MessageBroker& broker_; + WidgetViewport centralViewport_; + boost::thread updateThread_; + bool stopped_; + unsigned int updateDelayInMs_; public: class GlobalMutexLocker: public boost::noncopyable { - boost::mutex::scoped_lock lock_; + private: + NativeStoneApplicationContext& that_; + boost::mutex::scoped_lock lock_; + public: - GlobalMutexLocker(NativeStoneApplicationContext& that): + GlobalMutexLocker(NativeStoneApplicationContext& that) : + that_(that), lock_(that.globalMutex_) { } + + IWidget& SetCentralWidget(IWidget* widget); // Takes ownership + + MessageBroker& GetMessageBroker() const + { + return that_.broker_; + } + + IViewport& GetCentralViewport() + { + return that_.centralViewport_; + } + + void SetUpdateDelay(unsigned int delayInMs) + { + that_.updateDelayInMs_ = delayInMs; + } }; - NativeStoneApplicationContext(); - - virtual ~NativeStoneApplicationContext() - { - } - - virtual IWidget& SetCentralWidget(IWidget* widget); // Takes ownership - - IViewport& GetCentralViewport() - { - return *(centralViewport_.get()); - } + NativeStoneApplicationContext(MessageBroker& broker); void Start(); void Stop(); - - void SetUpdateDelay(unsigned int delayInMs) - { - updateDelayInMs_ = delayInMs; - } }; }