annotate OrthancFramework/Sources/DicomNetworking/TimeoutDicomConnectionManager.h @ 5317:9875e1f24394

added XC in the modality list
author Alain Mazy <am@osimis.io>
date Thu, 22 Jun 2023 21:30:45 +0200
parents 0ea402b4d901
children 48b8dae6dc77
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
5185
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
2603
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 namespace Orthanc
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 TimeoutDicomConnectionManager() :
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 timeout_(boost::posix_time::milliseconds(1000))
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 void Close();
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 };
988936118354 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }