1 /**
2  * Orthanc - A Lightweight, RESTful DICOM Store
3  * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4  * Department, University Hospital of Liege, Belgium
5  * Copyright (C) 2017-2020 Osimis S.A., Belgium
6  *
7  * This program is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation, either version 3 of
10  * the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this program. If not, see
19  * <http://www.gnu.org/licenses/>.
20  **/
21 
22 
23 #pragma once
24 
25 #include "RemoteModalityParameters.h"
26 
27 #include <json/value.h>
28 
29 class OFCondition;  // From DCMTK
30 
31 namespace Orthanc
32 {
33   class ORTHANC_PUBLIC DicomAssociationParameters
34   {
35   private:
36     std::string               localAet_;
37     RemoteModalityParameters  remote_;
38     uint32_t                  timeout_;
39 
40     static void CheckHost(const std::string& host);
41 
42   public:
43     DicomAssociationParameters();
44 
45     DicomAssociationParameters(const std::string& localAet,
46                                const RemoteModalityParameters& remote);
47 
48     const std::string& GetLocalApplicationEntityTitle() const;
49 
50     void SetLocalApplicationEntityTitle(const std::string& aet);
51 
52     const RemoteModalityParameters& GetRemoteModality() const;
53 
54     void SetRemoteModality(const RemoteModalityParameters& parameters);
55 
56     void SetRemoteApplicationEntityTitle(const std::string& aet);
57 
58     void SetRemoteHost(const std::string& host);
59 
60     void SetRemotePort(uint16_t port);
61 
62     void SetRemoteManufacturer(ModalityManufacturer manufacturer);
63 
64     bool IsEqual(const DicomAssociationParameters& other) const;
65 
66     // Setting it to "0" disables the timeout (infinite wait)
67     void SetTimeout(uint32_t seconds);
68 
69     uint32_t GetTimeout() const;
70 
71     bool HasTimeout() const;
72 
73     void SerializeJob(Json::Value& target) const;
74 
75     static DicomAssociationParameters UnserializeJob(const Json::Value& serialized);
76 
77     static void SetDefaultTimeout(uint32_t seconds);
78 
79     static uint32_t GetDefaultTimeout();
80   };
81 }
82