Mercurial > hg > orthanc-stone
annotate Applications/Generic/NativeStoneApplicationContext.cpp @ 291:87376a645ee1 am-2
renaming
author | am@osimis.io |
---|---|
date | Thu, 30 Aug 2018 17:06:22 +0200 |
parents | Applications/Generic/BasicNativeApplicationContext.cpp@a38465cc909f |
children | 8eb4fe74000f |
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 |
291 | 22 #include "NativeStoneApplicationContext.h" |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
23 #include "../../Platforms/Generic/OracleWebService.h" |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
24 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
25 namespace OrthancStone |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
26 { |
291 | 27 IWidget& NativeStoneApplicationContext::SetCentralWidget(IWidget* widget) // Takes ownership |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
28 { |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
29 centralViewport_->SetCentralWidget(widget); |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
30 return *widget; |
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 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
33 |
291 | 34 void NativeStoneApplicationContext::UpdateThread(NativeStoneApplicationContext* that) |
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 while (!that->stopped_) |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
37 { |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
38 { |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
39 GlobalMutexLocker locker(*that); |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
40 that->GetCentralViewport().UpdateContent(); |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
41 } |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
42 |
277 | 43 boost::this_thread::sleep(boost::posix_time::milliseconds(that->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 } |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
46 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
47 |
291 | 48 NativeStoneApplicationContext::NativeStoneApplicationContext() : |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
49 centralViewport_(new OrthancStone::WidgetViewport()), |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
50 stopped_(true), |
277 | 51 updateDelayInMs_(100) // By default, 100ms between each refresh of the content |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
52 { |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
53 srand(time(NULL)); |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
54 } |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
55 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
56 |
291 | 57 void NativeStoneApplicationContext::Start() |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
58 { |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
59 dynamic_cast<OracleWebService*>(webService_)->Start(); |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
60 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
61 if (centralViewport_->HasUpdateContent()) |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
62 { |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
63 stopped_ = false; |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
64 updateThread_ = boost::thread(UpdateThread, this); |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
65 } |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
66 } |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
67 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
68 |
291 | 69 void NativeStoneApplicationContext::Stop() |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
70 { |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
71 stopped_ = true; |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
72 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
73 if (updateThread_.joinable()) |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
74 { |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
75 updateThread_.join(); |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
76 } |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
77 |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
78 dynamic_cast<OracleWebService*>(webService_)->Stop(); |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
79 } |
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
diff
changeset
|
80 } |