Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Viewport/ViewportLocker.h @ 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 #pragma once | |
25 | |
26 #include "IViewport.h" | |
27 | |
28 namespace OrthancStone | |
29 { | |
30 class ViewportLocker : public boost::noncopyable | |
31 { | |
32 private: | |
33 boost::shared_ptr<IViewport> lock1_; | |
34 std::unique_ptr<IViewport::ILock> lock2_; | |
35 | |
36 IViewport::ILock& GetLock() const; | |
37 | |
38 public: | |
39 ViewportLocker(IViewport& viewport) : | |
40 lock2_(viewport.Lock()) | |
41 { | |
42 } | |
43 | |
44 ViewportLocker(boost::weak_ptr<IViewport> viewport); | |
45 | |
46 bool IsValid() const | |
47 { | |
48 return (lock2_.get() != NULL); | |
49 } | |
50 | |
51 ViewportController& GetController() const | |
52 { | |
53 return GetLock().GetController(); | |
54 } | |
55 | |
56 void Invalidate() const | |
57 { | |
58 return GetLock().Invalidate(); | |
59 } | |
60 }; | |
61 } |