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-2021 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 "../Enumerations.h"
26 
27 #include <stdint.h>
28 #include <string>
29 #include <json/value.h>
30 
31 namespace Orthanc
32 {
33   class ORTHANC_PUBLIC RemoteModalityParameters
34   {
35   private:
36     std::string           aet_;
37     std::string           host_;
38     uint16_t              port_;
39     ModalityManufacturer  manufacturer_;
40     bool                  allowEcho_;
41     bool                  allowStore_;
42     bool                  allowFind_;
43     bool                  allowMove_;
44     bool                  allowGet_;
45     bool                  allowNAction_;
46     bool                  allowNEventReport_;
47     bool                  allowTranscoding_;
48     bool                  useDicomTls_;
49     std::string           localAet_;
50     uint32_t              timeout_;
51 
52     void Clear();
53 
54     void UnserializeArray(const Json::Value& serialized);
55 
56     void UnserializeObject(const Json::Value& serialized);
57 
58   public:
59     RemoteModalityParameters();
60 
61     explicit RemoteModalityParameters(const Json::Value& serialized);
62 
63     RemoteModalityParameters(const std::string& aet,
64                              const std::string& host,
65                              uint16_t port,
66                              ModalityManufacturer manufacturer);
67 
68     const std::string& GetApplicationEntityTitle() const;
69 
70     void SetApplicationEntityTitle(const std::string& aet);
71 
72     const std::string& GetHost() const;
73 
74     void SetHost(const std::string& host);
75 
76     uint16_t GetPortNumber() const;
77 
78     void SetPortNumber(uint16_t port);
79 
80     ModalityManufacturer GetManufacturer() const;
81 
82     void SetManufacturer(ModalityManufacturer manufacturer);
83 
84     void SetManufacturer(const std::string& manufacturer);
85 
86     bool IsRequestAllowed(DicomRequestType type) const;
87 
88     void SetRequestAllowed(DicomRequestType type,
89                            bool allowed);
90 
91     void Unserialize(const Json::Value& modality);
92 
93     bool IsAdvancedFormatNeeded() const;
94 
95     void Serialize(Json::Value& target,
96                    bool forceAdvancedFormat) const;
97 
98     bool IsTranscodingAllowed() const;
99 
100     void SetTranscodingAllowed(bool allowed);
101 
102     bool IsDicomTlsEnabled() const;
103 
104     void SetDicomTlsEnabled(bool enabled);
105 
106     bool HasLocalAet() const;
107 
108     const std::string& GetLocalAet() const;
109 
110     void SetLocalAet(const std::string& aet);
111 
112     // Setting it to "0" will use "DicomAssociationParameters::GetDefaultTimeout()"
113     void SetTimeout(uint32_t seconds);
114 
115     uint32_t GetTimeout() const;
116 
117     bool HasTimeout() const;
118   };
119 }
120