comparison OrthancServer/OrthancConfiguration.h @ 2940:4767d36679ed

refactoring access to Orthanc configuration
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Nov 2018 11:47:00 +0100
parents 4a38d7d4f0e0
children e292798f9980
comparison
equal deleted inserted replaced
2939:577786f59252 2940:4767d36679ed
39 39
40 #include <EmbeddedResources.h> 40 #include <EmbeddedResources.h>
41 41
42 #include <boost/filesystem.hpp> 42 #include <boost/filesystem.hpp>
43 #include <boost/thread/shared_mutex.hpp> 43 #include <boost/thread/shared_mutex.hpp>
44 #include <boost/thread/lock_types.hpp>
44 45
45 namespace Orthanc 46 namespace Orthanc
46 { 47 {
47 class MongooseServer; 48 class MongooseServer;
48 49
64 void ValidateConfiguration() const; 65 void ValidateConfiguration() const;
65 66
66 static OrthancConfiguration& GetInstance(); 67 static OrthancConfiguration& GetInstance();
67 68
68 public: 69 public:
69 class Reader : public boost::noncopyable 70 class ReaderLock : public boost::noncopyable
70 { 71 {
71 private: 72 private:
72 OrthancConfiguration& configuration_; 73 OrthancConfiguration& configuration_;
73 boost::shared_lock<boost::shared_mutex> lock_; 74 boost::shared_lock<boost::shared_mutex> lock_;
74 75
75 public: 76 public:
76 Reader() : 77 ReaderLock() :
77 configuration_(GetInstance()), 78 configuration_(GetInstance()),
78 lock_(configuration_.mutex_) 79 lock_(configuration_.mutex_)
79 { 80 {
80 } 81 }
81 82
89 return configuration_.json_; 90 return configuration_.json_;
90 } 91 }
91 }; 92 };
92 93
93 94
94 class Writer : public boost::noncopyable 95 class WriterLock : public boost::noncopyable
95 { 96 {
96 private: 97 private:
97 OrthancConfiguration& configuration_; 98 OrthancConfiguration& configuration_;
98 boost::unique_lock<boost::shared_mutex> lock_; 99 boost::unique_lock<boost::shared_mutex> lock_;
99 100
100 public: 101 public:
101 Writer() : 102 WriterLock() :
102 configuration_(GetInstance()), 103 configuration_(GetInstance()),
103 lock_(configuration_.mutex_) 104 lock_(configuration_.mutex_)
104 { 105 {
105 } 106 }
106 107
118 { 119 {
119 return configuration_.json_; 120 return configuration_.json_;
120 } 121 }
121 }; 122 };
122 123
123
124 const Json::Value& GetContent() const
125 {
126 return json_;
127 }
128 124
129 const std::string& GetConfigurationAbsolutePath() const 125 const std::string& GetConfigurationAbsolutePath() const
130 { 126 {
131 return configurationAbsolutePath_; 127 return configurationAbsolutePath_;
132 } 128 }
171 167
172 void SetupRegisteredUsers(MongooseServer& httpServer) const; 168 void SetupRegisteredUsers(MongooseServer& httpServer) const;
173 169
174 std::string InterpretStringParameterAsPath(const std::string& parameter) const; 170 std::string InterpretStringParameterAsPath(const std::string& parameter) const;
175 171
176 void GetGlobalListOfStringsParameter(std::list<std::string>& target, 172 void GetListOfStringsParameter(std::list<std::string>& target,
177 const std::string& key) const; 173 const std::string& key) const;
178 174
179 bool IsSameAETitle(const std::string& aet1, 175 bool IsSameAETitle(const std::string& aet1,
180 const std::string& aet2) const; 176 const std::string& aet2) const;
181 177
182 bool LookupDicomModalityUsingAETitle(RemoteModalityParameters& modality, 178 bool LookupDicomModalityUsingAETitle(RemoteModalityParameters& modality,