Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Viewport/ViewportLocker.cpp @ 1973:596f4752fa42
added ViewportLocker
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 28 Oct 2022 16:23:18 +0200 |
parents | |
children | b31e494e34c5 |
comparison
equal
deleted
inserted
replaced
1972:9c0adcc8feec | 1973:596f4752fa42 |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium | |
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
7 * | |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Lesser General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Lesser General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Lesser General Public | |
19 * License along with this program. If not, see | |
20 * <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #include "ViewportLocker.h" | |
25 | |
26 #include <OrthancException.h> | |
27 | |
28 namespace OrthancStone | |
29 { | |
30 IViewport::ILock& ViewportLocker::GetLock() const | |
31 { | |
32 if (lock2_.get() == NULL) | |
33 { | |
34 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
35 } | |
36 else | |
37 { | |
38 return *lock2_; | |
39 } | |
40 } | |
41 | |
42 | |
43 ViewportLocker::ViewportLocker(boost::weak_ptr<IViewport> viewport) | |
44 { | |
45 lock1_ = viewport.lock(); | |
46 if (lock1_) | |
47 { | |
48 lock2_.reset(lock1_->Lock()); | |
49 } | |
50 } | |
51 } |