comparison OrthancServer/ServerEnumerations.cpp @ 562:f64e3838d6e1 find-move-scp

refactoring enumerations
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 18 Sep 2013 16:49:48 +0200
parents e0cfb413c86b
children 4aa6f0d79947
comparison
equal deleted inserted replaced
559:e0cfb413c86b 562:f64e3838d6e1
81 { 81 {
82 boost::mutex::scoped_lock lock(enumerationsMutex_); 82 boost::mutex::scoped_lock lock(enumerationsMutex_);
83 return dictMetadataType_.Translate(str); 83 return dictMetadataType_.Translate(str);
84 } 84 }
85 85
86 const char* EnumerationToString(ResourceType type)
87 {
88 switch (type)
89 {
90 case ResourceType_Patient:
91 return "Patient";
92
93 case ResourceType_Study:
94 return "Study";
95
96 case ResourceType_Series:
97 return "Series";
98
99 case ResourceType_Instance:
100 return "Instance";
101
102 default:
103 throw OrthancException(ErrorCode_ParameterOutOfRange);
104 }
105 }
106
107 std::string GetBasePath(ResourceType type, 86 std::string GetBasePath(ResourceType type,
108 const std::string& publicId) 87 const std::string& publicId)
109 { 88 {
110 switch (type) 89 switch (type)
111 { 90 {
288 else 267 else
289 { 268 {
290 throw OrthancException(ErrorCode_ParameterOutOfRange); 269 throw OrthancException(ErrorCode_ParameterOutOfRange);
291 } 270 }
292 } 271 }
293
294
295 ResourceType StringToResourceType(const char* type)
296 {
297 std::string s(type);
298 Toolbox::ToUpperCase(s);
299
300 if (s == "PATIENT")
301 {
302 return ResourceType_Patient;
303 }
304 else if (s == "STUDY")
305 {
306 return ResourceType_Study;
307 }
308 else if (s == "SERIES")
309 {
310 return ResourceType_Series;
311 }
312 else if (s == "INSTANCE" || s == "IMAGE")
313 {
314 return ResourceType_Instance;
315 }
316 else
317 {
318 throw OrthancException(ErrorCode_ParameterOutOfRange);
319 }
320 }
321 } 272 }