Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomNetworking/TimeoutDicomConnectionManager.h @ 4981:d0c34145320c
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 25 Apr 2022 17:32:58 +0200 |
parents | 43e613a7756b |
children | 0ea402b4d901 |
rev | line source |
---|---|
2603 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
2603 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
11 * the License, or (at your option) any later version. |
2603 | 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 | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
16 * Lesser General Public License for more details. |
2603 | 17 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
2603 | 21 **/ |
22 | |
23 | |
24 #pragma once | |
25 | |
3850
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
26 #if !defined(ORTHANC_ENABLE_DCMTK_NETWORKING) |
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
27 # error The macro ORTHANC_ENABLE_DCMTK_NETWORKING must be defined |
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
28 #endif |
2603 | 29 |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
30 #if ORTHANC_ENABLE_DCMTK_NETWORKING != 1 |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
31 # error The macro ORTHANC_ENABLE_DCMTK_NETWORKING must be 1 to use this file |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
32 #endif |
2644
5b3bfdf6b790
fix Orthanc framework without DICOM support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2608
diff
changeset
|
33 |
5b3bfdf6b790
fix Orthanc framework without DICOM support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2608
diff
changeset
|
34 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
35 #include "../Compatibility.h" |
3863
9973d10bc5c4
switch to DicomStoreUserConnection in Lua routing, C-MOVE handler and straight C-STORE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
36 #include "DicomStoreUserConnection.h" |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
37 |
2608
25225f0b4f33
simplification wrt. dicom connection manager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
38 #include <boost/date_time/posix_time/posix_time.hpp> |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
39 #include <boost/thread/mutex.hpp> |
2603 | 40 |
41 namespace Orthanc | |
42 { | |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
43 /** |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
44 * This class corresponds to a singleton to a DICOM SCU connection. |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
45 **/ |
3850
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
46 class TimeoutDicomConnectionManager : public boost::noncopyable |
2603 | 47 { |
48 private: | |
3863
9973d10bc5c4
switch to DicomStoreUserConnection in Lua routing, C-MOVE handler and straight C-STORE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
49 boost::mutex mutex_; |
9973d10bc5c4
switch to DicomStoreUserConnection in Lua routing, C-MOVE handler and straight C-STORE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
50 std::unique_ptr<DicomStoreUserConnection> connection_; |
9973d10bc5c4
switch to DicomStoreUserConnection in Lua routing, C-MOVE handler and straight C-STORE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
51 boost::posix_time::ptime lastUse_; |
9973d10bc5c4
switch to DicomStoreUserConnection in Lua routing, C-MOVE handler and straight C-STORE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
52 boost::posix_time::time_duration timeout_; |
2603 | 53 |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
54 // Mutex must be locked |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
55 void TouchInternal(); |
2603 | 56 |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
57 // Mutex must be locked |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
58 void OpenInternal(const std::string& localAet, |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
59 const RemoteModalityParameters& remote); |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
60 |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
61 // Mutex must be locked |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
62 void CloseInternal(); |
2603 | 63 |
64 public: | |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
65 class Lock : public boost::noncopyable |
3850
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
66 { |
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
67 private: |
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
68 TimeoutDicomConnectionManager& that_; |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
69 boost::mutex::scoped_lock lock_; |
3850
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
70 |
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
71 public: |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
72 Lock(TimeoutDicomConnectionManager& that, |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
73 const std::string& localAet, |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
74 const RemoteModalityParameters& remote); |
3850
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
75 |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
76 ~Lock(); |
3850
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
77 |
3863
9973d10bc5c4
switch to DicomStoreUserConnection in Lua routing, C-MOVE handler and straight C-STORE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
78 DicomStoreUserConnection& GetConnection(); |
3850
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
79 }; |
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
80 |
2603 | 81 TimeoutDicomConnectionManager() : |
82 timeout_(boost::posix_time::milliseconds(1000)) | |
83 { | |
84 } | |
85 | |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
86 void SetInactivityTimeout(unsigned int milliseconds); |
2603 | 87 |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
88 unsigned int GetInactivityTimeout(); // In milliseconds |
2603 | 89 |
90 void Close(); | |
91 | |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
92 void CloseIfInactive(); |
2603 | 93 }; |
94 } |