Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi.cpp @ 745:9076a986c451
code clarification
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 01 Apr 2014 16:29:41 +0200 |
parents | 696dbb4fd390 |
children | 478f4f9de9eb |
comparison
equal
deleted
inserted
replaced
744:ec69658b031b | 745:9076a986c451 |
---|---|
53 static const uint64_t MEGA_BYTES = 1024 * 1024; | 53 static const uint64_t MEGA_BYTES = 1024 * 1024; |
54 static const uint64_t GIGA_BYTES = 1024 * 1024 * 1024; | 54 static const uint64_t GIGA_BYTES = 1024 * 1024 * 1024; |
55 | 55 |
56 | 56 |
57 #define RETRIEVE_CONTEXT(call) \ | 57 #define RETRIEVE_CONTEXT(call) \ |
58 OrthancRestApi& contextApi = \ | 58 OrthancRestApi& that = \ |
59 dynamic_cast<OrthancRestApi&>(call.GetContext()); \ | 59 dynamic_cast<OrthancRestApi&>(call.GetContext()); \ |
60 ServerContext& context = contextApi.GetContext() | 60 ServerContext& context = that.GetContext() |
61 | 61 |
62 #define RETRIEVE_MODALITIES(call) \ | 62 #define RETRIEVE_THAT(call) \ |
63 const OrthancRestApi::SetOfStrings& modalities = \ | 63 OrthancRestApi& that = \ |
64 dynamic_cast<OrthancRestApi&>(call.GetContext()).GetModalities(); | 64 dynamic_cast<OrthancRestApi&>(call.GetContext()); |
65 | |
66 #define RETRIEVE_PEERS(call) \ | |
67 const OrthancRestApi::SetOfStrings& peers = \ | |
68 dynamic_cast<OrthancRestApi&>(call.GetContext()).GetPeers(); | |
69 | |
70 | 65 |
71 | 66 |
72 namespace Orthanc | 67 namespace Orthanc |
73 { | 68 { |
74 // TODO IMPROVE MULTITHREADING | 69 // TODO IMPROVE MULTITHREADING |
985 return modalities.find(id) != modalities.end(); | 980 return modalities.find(id) != modalities.end(); |
986 } | 981 } |
987 | 982 |
988 static void ListModalities(RestApi::GetCall& call) | 983 static void ListModalities(RestApi::GetCall& call) |
989 { | 984 { |
990 RETRIEVE_MODALITIES(call); | 985 RETRIEVE_THAT(call); |
991 | 986 |
992 Json::Value result = Json::arrayValue; | 987 Json::Value result = Json::arrayValue; |
993 for (OrthancRestApi::SetOfStrings::const_iterator | 988 for (OrthancRestApi::SetOfStrings::const_iterator |
994 it = modalities.begin(); it != modalities.end(); ++it) | 989 it = that.GetModalities().begin(); |
990 it != that.GetModalities().end(); ++it) | |
995 { | 991 { |
996 result.append(*it); | 992 result.append(*it); |
997 } | 993 } |
998 | 994 |
999 call.GetOutput().AnswerJson(result); | 995 call.GetOutput().AnswerJson(result); |
1000 } | 996 } |
1001 | 997 |
1002 | 998 |
1003 static void ListModalityOperations(RestApi::GetCall& call) | 999 static void ListModalityOperations(RestApi::GetCall& call) |
1004 { | 1000 { |
1005 RETRIEVE_MODALITIES(call); | 1001 RETRIEVE_THAT(call); |
1006 | 1002 |
1007 std::string id = call.GetUriComponent("id", ""); | 1003 std::string id = call.GetUriComponent("id", ""); |
1008 if (IsExistingModality(modalities, id)) | 1004 if (IsExistingModality(that.GetModalities(), id)) |
1009 { | 1005 { |
1010 Json::Value result = Json::arrayValue; | 1006 Json::Value result = Json::arrayValue; |
1011 result.append("find-patient"); | 1007 result.append("find-patient"); |
1012 result.append("find-study"); | 1008 result.append("find-study"); |
1013 result.append("find-series"); | 1009 result.append("find-series"); |
1757 return peers.find(id) != peers.end(); | 1753 return peers.find(id) != peers.end(); |
1758 } | 1754 } |
1759 | 1755 |
1760 static void ListPeers(RestApi::GetCall& call) | 1756 static void ListPeers(RestApi::GetCall& call) |
1761 { | 1757 { |
1762 RETRIEVE_PEERS(call); | 1758 RETRIEVE_THAT(call); |
1763 | 1759 |
1764 Json::Value result = Json::arrayValue; | 1760 Json::Value result = Json::arrayValue; |
1765 for (OrthancRestApi::SetOfStrings::const_iterator | 1761 for (OrthancRestApi::SetOfStrings::const_iterator |
1766 it = peers.begin(); it != peers.end(); ++it) | 1762 it = that.GetPeers().begin(); |
1763 it != that.GetPeers().end(); ++it) | |
1767 { | 1764 { |
1768 result.append(*it); | 1765 result.append(*it); |
1769 } | 1766 } |
1770 | 1767 |
1771 call.GetOutput().AnswerJson(result); | 1768 call.GetOutput().AnswerJson(result); |
1772 } | 1769 } |
1773 | 1770 |
1774 static void ListPeerOperations(RestApi::GetCall& call) | 1771 static void ListPeerOperations(RestApi::GetCall& call) |
1775 { | 1772 { |
1776 RETRIEVE_PEERS(call); | 1773 RETRIEVE_THAT(call); |
1777 | 1774 |
1778 std::string id = call.GetUriComponent("id", ""); | 1775 std::string id = call.GetUriComponent("id", ""); |
1779 if (IsExistingPeer(peers, id)) | 1776 if (IsExistingPeer(that.GetPeers(), id)) |
1780 { | 1777 { |
1781 Json::Value result = Json::arrayValue; | 1778 Json::Value result = Json::arrayValue; |
1782 result.append("store"); | 1779 result.append("store"); |
1783 call.GetOutput().AnswerJson(result); | 1780 call.GetOutput().AnswerJson(result); |
1784 } | 1781 } |