annotate OrthancFramework/Sources/DicomNetworking/TimeoutDicomConnectionManager.h @ 4281:d2f79a475b51

debug log for DCMTK SCU
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Nov 2020 13:48:42 +0100
parents bf7b9edf6b81
children d9473bd5ed43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * 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
8 * 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
9 * 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
10 * the License, or (at your option) any later version.
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * 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
15 * Lesser General Public License for more details.
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
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
17 * 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
18 * 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
19 * <http://www.gnu.org/licenses/>.
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #pragma once
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
3850
d729d6e8b484 removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
25 #if !defined(ORTHANC_ENABLE_DCMTK_NETWORKING)
d729d6e8b484 removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
26 # 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
27 #endif
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
29 #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
30 # 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
31 #endif
2644
5b3bfdf6b790 fix Orthanc framework without DICOM support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2608
diff changeset
32
5b3bfdf6b790 fix Orthanc framework without DICOM support
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2608
diff changeset
33
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
34 #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
35 #include "DicomStoreUserConnection.h"
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
36
2608
25225f0b4f33 simplification wrt. dicom connection manager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
37 #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
38 #include <boost/thread/mutex.hpp>
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 namespace Orthanc
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
42 /**
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
43 * 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
44 **/
3850
d729d6e8b484 removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
45 class TimeoutDicomConnectionManager : public boost::noncopyable
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 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
48 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
49 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
50 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
51 boost::posix_time::time_duration timeout_;
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
53 // Mutex must be locked
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
54 void TouchInternal();
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
56 // Mutex must be locked
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
57 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
58 const RemoteModalityParameters& remote);
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
59
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
60 // Mutex must be locked
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
61 void CloseInternal();
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 public:
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
64 class Lock : public boost::noncopyable
3850
d729d6e8b484 removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
65 {
d729d6e8b484 removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
66 private:
d729d6e8b484 removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
67 TimeoutDicomConnectionManager& that_;
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
68 boost::mutex::scoped_lock lock_;
3850
d729d6e8b484 removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
69
d729d6e8b484 removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
70 public:
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
71 Lock(TimeoutDicomConnectionManager& that,
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
72 const std::string& localAet,
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
73 const RemoteModalityParameters& remote);
3850
d729d6e8b484 removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
74
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
75 ~Lock();
3850
d729d6e8b484 removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
76
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
77 DicomStoreUserConnection& GetConnection();
3850
d729d6e8b484 removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
78 };
d729d6e8b484 removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
79
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 TimeoutDicomConnectionManager() :
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 timeout_(boost::posix_time::milliseconds(1000))
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
85 void SetInactivityTimeout(unsigned int milliseconds);
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
87 unsigned int GetInactivityTimeout(); // In milliseconds
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 void Close();
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3850
diff changeset
91 void CloseIfInactive();
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 };
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 }