Mercurial > hg > orthanc
changeset 480:482cde3f3c14
sample of c++ client
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 16 Jul 2013 09:22:55 +0200 |
parents | 0cd977e94479 |
children | 4f5b4b0fa626 |
files | OrthancCppClient/Instance.h OrthancCppClient/OrthancConnection.h OrthancCppClient/Patient.h OrthancCppClient/Series.h OrthancCppClient/Study.h Resources/Samples/OrthancCppClient/Basic/CMakeLists.txt Resources/Samples/OrthancCppClient/Basic/main.cpp |
diffstat | 7 files changed, 59 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancCppClient/Instance.h Tue Jul 16 09:08:09 2013 +0200 +++ b/OrthancCppClient/Instance.h Tue Jul 16 09:22:55 2013 +0200 @@ -57,6 +57,11 @@ Instance(const OrthancConnection& connection, const std::string& id); + const std::string& GetId() const + { + return id_; + } + void SetImageExtractionMode(Orthanc::ImageExtractionMode mode); Orthanc::ImageExtractionMode GetImageExtractionMode() const
--- a/OrthancCppClient/OrthancConnection.h Tue Jul 16 09:08:09 2013 +0200 +++ b/OrthancCppClient/OrthancConnection.h Tue Jul 16 09:22:55 2013 +0200 @@ -38,7 +38,9 @@ namespace OrthancClient { - class OrthancConnection : public boost::noncopyable, private Orthanc::ArrayFilledByThreads::IFiller + class OrthancConnection : + public boost::noncopyable, + private Orthanc::ArrayFilledByThreads::IFiller { private: Orthanc::HttpClient client_;
--- a/OrthancCppClient/Patient.h Tue Jul 16 09:08:09 2013 +0200 +++ b/OrthancCppClient/Patient.h Tue Jul 16 09:22:55 2013 +0200 @@ -36,7 +36,9 @@ namespace OrthancClient { - class Patient : public Orthanc::IDynamicObject, private Orthanc::ArrayFilledByThreads::IFiller + class Patient : + public Orthanc::IDynamicObject, + private Orthanc::ArrayFilledByThreads::IFiller { private: const OrthancConnection& connection_;
--- a/OrthancCppClient/Series.h Tue Jul 16 09:08:09 2013 +0200 +++ b/OrthancCppClient/Series.h Tue Jul 16 09:22:55 2013 +0200 @@ -39,7 +39,9 @@ namespace OrthancClient { - class Series : public Orthanc::IDynamicObject, private Orthanc::ArrayFilledByThreads::IFiller + class Series : + public Orthanc::IDynamicObject, + private Orthanc::ArrayFilledByThreads::IFiller { private: enum Status3DImage
--- a/OrthancCppClient/Study.h Tue Jul 16 09:08:09 2013 +0200 +++ b/OrthancCppClient/Study.h Tue Jul 16 09:22:55 2013 +0200 @@ -36,7 +36,9 @@ namespace OrthancClient { - class Study : public Orthanc::IDynamicObject, private Orthanc::ArrayFilledByThreads::IFiller + class Study : + public Orthanc::IDynamicObject, + private Orthanc::ArrayFilledByThreads::IFiller { private: const OrthancConnection& connection_;
--- a/Resources/Samples/OrthancCppClient/Basic/CMakeLists.txt Tue Jul 16 09:08:09 2013 +0200 +++ b/Resources/Samples/OrthancCppClient/Basic/CMakeLists.txt Tue Jul 16 09:22:55 2013 +0200 @@ -12,6 +12,8 @@ include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake) include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake) include(${ORTHANC_ROOT}/Resources/CMake/LibCurlConfiguration.cmake) +include(${ORTHANC_ROOT}/Resources/CMake/LibPngConfiguration.cmake) +include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake) if (${CMAKE_COMPILER_IS_GNUCXX}) set(CMAKE_C_FLAGS "-Wall -pedantic -Wno-implicit-function-declaration") # --std=c99 makes libcurl not to compile @@ -27,7 +29,20 @@ ${THIRD_PARTY_SOURCES} ${ORTHANC_ROOT}/Core/OrthancException.cpp ${ORTHANC_ROOT}/Core/Enumerations.cpp + ${ORTHANC_ROOT}/Core/Toolbox.cpp ${ORTHANC_ROOT}/Core/HttpClient.cpp + ${ORTHANC_ROOT}/Core/MultiThreading/ArrayFilledByThreads.cpp + ${ORTHANC_ROOT}/Core/MultiThreading/ThreadedCommandProcessor.cpp + ${ORTHANC_ROOT}/Core/MultiThreading/SharedMessageQueue.cpp + ${ORTHANC_ROOT}/Core/FileFormats/PngReader.cpp + ${ORTHANC_ROOT}/OrthancCppClient/OrthancConnection.cpp + ${ORTHANC_ROOT}/OrthancCppClient/Series.cpp + ${ORTHANC_ROOT}/OrthancCppClient/Study.cpp + ${ORTHANC_ROOT}/OrthancCppClient/Instance.cpp + ${ORTHANC_ROOT}/OrthancCppClient/Patient.cpp + ${ORTHANC_ROOT}/Resources/sha1/sha1.cpp + ${ORTHANC_ROOT}/Resources/md5/md5.c + ${ORTHANC_ROOT}/Resources/base64/base64.cpp ) add_executable(Test
--- a/Resources/Samples/OrthancCppClient/Basic/main.cpp Tue Jul 16 09:08:09 2013 +0200 +++ b/Resources/Samples/OrthancCppClient/Basic/main.cpp Tue Jul 16 09:22:55 2013 +0200 @@ -28,6 +28,7 @@ #include <iostream> #include "../../../../Core/HttpClient.h" +#include "../../../../OrthancCppClient/OrthancConnection.h" int main() { @@ -42,5 +43,31 @@ // Display the JSON answer std::cout << result << std::endl; + // Display the content of the local Orthanc instance + OrthancClient::OrthancConnection orthanc("http://localhost:8042"); + + for (unsigned int i = 0; i < orthanc.GetPatientCount(); i++) + { + OrthancClient::Patient& patient = orthanc.GetPatient(i); + std::cout << "Patient: " << patient.GetId() << std::endl; + + for (unsigned int j = 0; j < patient.GetStudyCount(); j++) + { + OrthancClient::Study& study = patient.GetStudy(j); + std::cout << " Study: " << study.GetId() << std::endl; + + for (unsigned int k = 0; k < study.GetSeriesCount(); k++) + { + OrthancClient::Series& series = study.GetSeries(k); + std::cout << " Series: " << series.GetId() << std::endl; + + for (unsigned int l = 0; l < series.GetInstanceCount(); l++) + { + std::cout << " Instance: " << series.GetInstance(l).GetId() << std::endl; + } + } + } + } + return 0; }