Orthanc Client
Documentation of the client library of Orthanc
OrthancCppClient.h
Go to the documentation of this file.
1 
37 #pragma once
38 
39 #include <stdexcept>
40 #include <memory>
41 #include <string>
42 #include <string.h>
43 
44 #if defined(_WIN32)
45 
46 /********************************************************************
47  ** This is the Windows-specific section
48  ********************************************************************/
49 
50 #include <windows.h>
51 
52 /* cf. http://sourceforge.net/p/predef/wiki/Architectures/ */
53 #ifdef _M_X64
54 /* 64 bits target */
55 #define LAAW_ORTHANC_CLIENT_CALL_CONV __fastcall
56 #define LAAW_ORTHANC_CLIENT_CALL_DECORATION(Name, StdCallSuffix) Name
57 #define LAAW_ORTHANC_CLIENT_DEFAULT_PATH "OrthancClient_Windows64.dll"
58 #else
59 /* 32 bits target */
60 #define LAAW_ORTHANC_CLIENT_CALL_CONV __stdcall
61 #define LAAW_ORTHANC_CLIENT_CALL_DECORATION(Name, StdCallSuffix) "_" Name "@" StdCallSuffix
62 #define LAAW_ORTHANC_CLIENT_DEFAULT_PATH "OrthancClient_Windows32.dll"
63 #endif
64 
65 #define LAAW_ORTHANC_CLIENT_HANDLE_TYPE HINSTANCE
66 #define LAAW_ORTHANC_CLIENT_HANDLE_NULL 0
67 #define LAAW_ORTHANC_CLIENT_FUNCTION_TYPE FARPROC
68 #define LAAW_ORTHANC_CLIENT_LOADER(path) LoadLibraryA(path)
69 #define LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle, name, decoration) GetProcAddress(handle, LAAW_ORTHANC_CLIENT_CALL_DECORATION(name, decoration))
70 #define LAAW_ORTHANC_CLIENT_CLOSER(handle) FreeLibrary(handle)
71 
72 
73 /********************************************************************
74  ** This is the Linux-specific section
75  ********************************************************************/
76 
77 #elif defined (__linux)
78 
79 #include <stdlib.h>
80 #include <dlfcn.h>
81 
82 /* cf. http://sourceforge.net/p/predef/wiki/Architectures/ */
83 #ifdef __amd64__
84 #define LAAW_ORTHANC_CLIENT_DEFAULT_PATH "libOrthancClient.so.0.7"
85 #else
86 #define LAAW_ORTHANC_CLIENT_DEFAULT_PATH "libOrthancClient.so.0.7"
87 #endif
88 
89 #define LAAW_ORTHANC_CLIENT_CALL_CONV
90 #define LAAW_ORTHANC_CLIENT_HANDLE_TYPE void*
91 #define LAAW_ORTHANC_CLIENT_HANDLE_NULL NULL
92 #define LAAW_ORTHANC_CLIENT_FUNCTION_TYPE intptr_t
93 #define LAAW_ORTHANC_CLIENT_LOADER(path) dlopen(path, RTLD_LAZY)
94 #define LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle, name, decoration) (LAAW_ORTHANC_CLIENT_FUNCTION_TYPE) dlsym(handle, name)
95 #define LAAW_ORTHANC_CLIENT_CLOSER(handle) dlclose(handle)
96 
97 
98 #else
99 #error Please support your platform here
100 #endif
101 
102 
103 /********************************************************************
104  ** Definition of the integer types
105  ********************************************************************/
106 
107 #ifndef LAAW_INT8 // Only define the integer types once
108 
109 #if defined(__GNUC__)
110 
111 // Under GCC (including MinGW), the stdint.h standard header is used.
112 
113 #include <stdint.h>
114 
115 #define LAAW_INT8 int8_t
116 #define LAAW_UINT8 uint8_t
117 #define LAAW_INT16 int16_t
118 #define LAAW_UINT16 uint16_t
119 #define LAAW_INT32 int32_t
120 #define LAAW_UINT32 uint32_t
121 #define LAAW_INT64 int64_t
122 #define LAAW_UINT64 uint64_t
123 
124 #elif defined(_MSC_VER)
125 
126 // Under Visual Studio, it is required to define the various integer
127 // types by hand.
128 
129 #if (_MSC_VER < 1300)
130 typedef signed char LAAW_INT8;
131 typedef signed short LAAW_INT16;
132 typedef signed int LAAW_INT32;
133 typedef unsigned char LAAW_UINT8;
134 typedef unsigned short LAAW_UINT16;
135 typedef unsigned int LAAW_UINT32;
136 #else
137 typedef signed __int8 LAAW_INT8;
138 typedef signed __int16 LAAW_INT16;
139 typedef signed __int32 LAAW_INT32;
140 typedef unsigned __int8 LAAW_UINT8;
141 typedef unsigned __int16 LAAW_UINT16;
142 typedef unsigned __int32 LAAW_UINT32;
143 #endif
144 
145 typedef signed __int64 LAAW_INT64;
146 typedef unsigned __int64 LAAW_UINT64;
147 
148 #else
149 #error "Please support your compiler here"
150 #endif
151 
152 #endif
153 
154 
155 
156 
157 
158 /********************************************************************
159  ** This is a shared section between Windows and Linux
160  ********************************************************************/
161 
162 namespace OrthancClient {
166 class OrthancClientException : public std::exception
167  {
168  private:
169  std::string message_;
170 
171  public:
176  OrthancClientException(std::string message) : message_(message)
177  {
178  }
179 
180  ~OrthancClientException() throw()
181  {
182  }
183 
188  const std::string& What() const throw()
189  {
190  return message_;
191  }
192 };
193 }
194 
195 
196 namespace OrthancClient { namespace Internals {
202 class Library
203  {
204  private:
205  LAAW_ORTHANC_CLIENT_HANDLE_TYPE handle_;
206  LAAW_ORTHANC_CLIENT_FUNCTION_TYPE functionsIndex_[62 + 1];
207 
208 
209 
210  void Load(const char* sharedLibraryPath)
211  {
212 
213  if (handle_ != LAAW_ORTHANC_CLIENT_HANDLE_NULL)
214  {
215  // Do nothing if the library is already loaded
216  return;
217  }
218 
219  /* Setup the path to the default shared library if not provided */
220  if (sharedLibraryPath == NULL)
221  {
222  sharedLibraryPath = LAAW_ORTHANC_CLIENT_DEFAULT_PATH;
223  }
224 
225  /* Load the shared library */
226  handle_ = LAAW_ORTHANC_CLIENT_LOADER(sharedLibraryPath);
227 
228 
229  if (handle_ == LAAW_ORTHANC_CLIENT_HANDLE_NULL)
230  {
231  throw ::OrthancClient::OrthancClientException("Error loading shared library");
232  }
233 
234  LoadFunctions();
235  }
236 
237  inline void LoadFunctions();
238 
239  void FreeString(char* str)
240  {
241  typedef void (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (char*);
242  Function function = (Function) GetFunction(62);
243  function(str);
244  }
245 
246  Library()
247  {
248  handle_ = LAAW_ORTHANC_CLIENT_HANDLE_NULL;
249  }
250 
251  ~Library()
252  {
253  Finalize();
254  }
255 
256  public:
257  LAAW_ORTHANC_CLIENT_FUNCTION_TYPE GetFunction(unsigned int index)
258  {
264  if (handle_ == NULL)
265  {
266  Load(NULL);
267  }
268 
269  return functionsIndex_[index];
270  }
271 
272  void ThrowExceptionIfNeeded(char* message)
273  {
274  if (message != NULL)
275  {
276  std::string tmp(message);
277  FreeString(message);
278  throw ::OrthancClient::OrthancClientException(tmp);
279  }
280  }
281 
282  static inline Library& GetInstance()
283  {
292  static Library singleton;
293  return singleton;
294  }
295 
296  static void Initialize(const char* sharedLibraryPath)
297  {
298  GetInstance().Load(sharedLibraryPath);
299  }
300 
301  void Finalize()
302  {
303  if (handle_ != LAAW_ORTHANC_CLIENT_HANDLE_NULL)
304  {
305  LAAW_ORTHANC_CLIENT_CLOSER(handle_);
306  handle_ = LAAW_ORTHANC_CLIENT_HANDLE_NULL;
307  }
308  }
309 };
310 }}
311 
312 
320 namespace OrthancClient {
334 inline void Initialize()
335 {
337 }
338 
350 inline void Initialize(const std::string& sharedLibraryPath)
351 {
352  ::OrthancClient::Internals::Library::Initialize(sharedLibraryPath.c_str());
353 }
354 
363 inline void Finalize()
364 {
365  ::OrthancClient::Internals::Library::GetInstance().Finalize();
366 }
367 
368 
372 }
373 
374 
375 namespace OrthancClient { namespace Internals {
376 inline void Library::LoadFunctions()
377 {
378  typedef const char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) ();
379  Function getVersion = (Function) LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_GetVersion", "0");
380  if (getVersion == NULL)
381  {
382  throw ::OrthancClient::OrthancClientException("Unable to get the library version");
383  }
384 
389  if (strcmp(getVersion(), "0.7"))
390  {
391  throw ::OrthancClient::OrthancClientException("Mismatch between the C++ header and the library version");
392  }
393 
394  functionsIndex_[62] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_FreeString", "4");
395  functionsIndex_[3] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_557aee7b61817292a0f31269d3c35db7", "8");
396  functionsIndex_[4] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_0b8dff0ce67f10954a49b059e348837e", "8");
397  functionsIndex_[5] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_e05097c153f676e5a5ee54dcfc78256f", "4");
398  functionsIndex_[6] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_e840242bf58d17d3c1d722da09ce88e0", "8");
399  functionsIndex_[7] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_c9af31433001b5dfc012a552dc6d0050", "8");
400  functionsIndex_[8] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_3fba4d6b818180a44cd1cae6046334dc", "12");
401  functionsIndex_[9] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_aeb20dc75b9246188db857317e5e0ce7", "8");
402  functionsIndex_[10] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_62689803d9871e4d9c51a648640b320b", "8");
403  functionsIndex_[11] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_2fb64c9e5a67eccd413b0e913469a421", "16");
404  functionsIndex_[0] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_1f1acb322ea4d0aad65172824607673c", "8");
405  functionsIndex_[1] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_f3fd272e4636f6a531aabb72ee01cd5b", "16");
406  functionsIndex_[2] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_12d3de0a96e9efb11136a9811bb9ed38", "4");
407  functionsIndex_[14] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_f756172daf04516eec3a566adabb4335", "4");
408  functionsIndex_[15] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_ddb68763ec902a97d579666a73a20118", "8");
409  functionsIndex_[16] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_fba3c68b4be7558dbc65f7ce1ab57d63", "12");
410  functionsIndex_[17] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_b4ca99d958f843493e58d1ef967340e1", "8");
411  functionsIndex_[18] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_78d5cc76d282437b6f93ec3b82c35701", "16");
412  functionsIndex_[12] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_6cf0d7268667f9b0aa4511bacf184919", "12");
413  functionsIndex_[13] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_7d81cd502ee27e859735d0ea7112b5a1", "4");
414  functionsIndex_[21] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_48a2a1a9d68c047e22bfba23014643d2", "4");
415  functionsIndex_[22] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_852bf8296ca21c5fde5ec565cc10721d", "8");
416  functionsIndex_[23] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_efd04574e0779faa83df1f2d8f9888db", "12");
417  functionsIndex_[24] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_736247ff5e8036dac38163da6f666ed5", "8");
418  functionsIndex_[25] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_d82d2598a7a73f4b6fcc0c09c25b08ca", "8");
419  functionsIndex_[26] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_88134b978f9acb2aecdadf54aeab3c64", "16");
420  functionsIndex_[27] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_152cb1b704c053d24b0dab7461ba6ea3", "8");
421  functionsIndex_[28] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_eee03f337ec81d9f1783cd41e5238757", "8");
422  functionsIndex_[29] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_006f08237bd7611636fc721baebfb4c5", "8");
423  functionsIndex_[30] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_b794f5cd3dad7d7b575dd1fd902afdd0", "8");
424  functionsIndex_[31] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_8ee2e50dd9df8f66a3c1766090dd03ab", "8");
425  functionsIndex_[32] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_046aed35bbe4751691f4c34cc249a61d", "8");
426  functionsIndex_[33] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_4dcc7a0fd025efba251ac6e9b701c2c5", "28");
427  functionsIndex_[34] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_b2601a161c24ad0a1d3586246f87452c", "32");
428  functionsIndex_[19] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_193599b9e345384fcdfcd47c29c55342", "12");
429  functionsIndex_[20] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_7c97f17063a357d38c5fab1136ad12a0", "4");
430  functionsIndex_[37] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_e65b20b7e0170b67544cd6664a4639b7", "4");
431  functionsIndex_[38] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_470e981b0e41f17231ba0ae6f3033321", "8");
432  functionsIndex_[39] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_04cefd138b6ea15ad909858f2a0a8f05", "12");
433  functionsIndex_[40] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_aee5b1f6f0c082f2c3b0986f9f6a18c7", "8");
434  functionsIndex_[41] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_93965682bace75491413e1f0b8d5a654", "16");
435  functionsIndex_[35] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_b01c6003238eb46c8db5dc823d7ca678", "12");
436  functionsIndex_[36] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_0147007fb99bad8cd95a139ec8795376", "4");
437  functionsIndex_[44] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_236ee8b403bc99535a8a4695c0cd45cb", "8");
438  functionsIndex_[45] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_2a437b7aba6bb01e81113835be8f0146", "8");
439  functionsIndex_[46] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_2bcbcb850934ae0bb4c6f0cc940e6cda", "8");
440  functionsIndex_[47] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_8d415c3a78a48e7e61d9fd24e7c79484", "12");
441  functionsIndex_[48] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_70d2f8398bbc63b5f792b69b4ad5fecb", "12");
442  functionsIndex_[49] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_1729a067d902771517388eedd7346b23", "12");
443  functionsIndex_[50] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_72e2aeee66cd3abd8ab7e987321c3745", "8");
444  functionsIndex_[51] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_1ea3df5a1ac1a1a687fe7325adddb6f0", "8");
445  functionsIndex_[52] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_99b4f370e4f532d8b763e2cb49db92f8", "8");
446  functionsIndex_[53] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_c41c742b68617f1c0590577a0a5ebc0c", "8");
447  functionsIndex_[54] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_142dd2feba0fc1d262bbd0baeb441a8b", "8");
448  functionsIndex_[55] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_5f5c9f81a4dff8daa6c359f1d0488fef", "12");
449  functionsIndex_[56] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_9ca979fffd08fa256306d4e68d8b0e91", "8");
450  functionsIndex_[57] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_6f2d77a26edc91c28d89408dbc3c271e", "8");
451  functionsIndex_[58] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_c0f494b80d4ff8b232df7a75baa0700a", "4");
452  functionsIndex_[59] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_d604f44bd5195e082e745e9cbc164f4c", "4");
453  functionsIndex_[60] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_1710299d1c5f3b1f2b7cf3962deebbfd", "8");
454  functionsIndex_[61] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_bb55aaf772ddceaadee36f4e54136bcb", "8");
455  functionsIndex_[42] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_6c5ad02f91b583e29cebd0bd319ce21d", "12");
456  functionsIndex_[43] = LAAW_ORTHANC_CLIENT_GET_FUNCTION(handle_, "LAAW_EXTERNC_4068241c44a9c1367fe0e57be523f207", "4");
457 
458  /* Check whether the functions were properly loaded */
459  for (unsigned int i = 0; i <= 62; i++)
460  {
461  if (functionsIndex_[i] == (LAAW_ORTHANC_CLIENT_FUNCTION_TYPE) NULL)
462  {
463  throw ::OrthancClient::OrthancClientException("Unable to load the functions of the shared library");
464  }
465  }
466 }
467 }}
468 namespace OrthancClient
469 {
470  class OrthancConnection;
471 }
472 
473 namespace OrthancClient
474 {
475  class Patient;
476 }
477 
478 namespace OrthancClient
479 {
480  class Series;
481 }
482 
483 namespace OrthancClient
484 {
485  class Study;
486 }
487 
488 namespace OrthancClient
489 {
490  class Instance;
491 }
492 
493 namespace Orthanc
494 {
503  {
532  };
533 }
534 
535 namespace Orthanc
536 {
545  {
574  };
575 }
576 
577 namespace OrthancClient
578 {
586  {
587  friend class ::OrthancClient::Patient;
588  friend class ::OrthancClient::Series;
589  friend class ::OrthancClient::Study;
590  friend class ::OrthancClient::Instance;
591  private:
592  bool isReference_;
593  OrthancConnection& operator= (const OrthancConnection&); // Assignment is forbidden
594  void* pimpl_;
595  OrthancConnection(void* pimpl) : isReference_(true), pimpl_(pimpl) {}
596  public:
604  OrthancConnection(const OrthancConnection& other) : isReference_(true), pimpl_(other.pimpl_) { }
605  inline OrthancConnection(const ::std::string& orthancUrl);
606  inline OrthancConnection(const ::std::string& orthancUrl, const ::std::string& username, const ::std::string& password);
607  inline ~OrthancConnection();
608  inline LAAW_UINT32 GetThreadCount() const;
609  inline void SetThreadCount(LAAW_UINT32 threadCount);
610  inline void Reload();
611  inline ::std::string GetOrthancUrl() const;
612  inline LAAW_UINT32 GetPatientCount();
613  inline ::OrthancClient::Patient GetPatient(LAAW_UINT32 index);
614  inline void DeletePatient(LAAW_UINT32 index);
615  inline void StoreFile(const ::std::string& filename);
616  inline void Store(const void* dicom, LAAW_UINT64 size);
617  };
618 }
619 
620 namespace OrthancClient
621 {
628  class Patient
629  {
630  friend class ::OrthancClient::OrthancConnection;
631  friend class ::OrthancClient::Series;
632  friend class ::OrthancClient::Study;
633  friend class ::OrthancClient::Instance;
634  private:
635  bool isReference_;
636  Patient& operator= (const Patient&); // Assignment is forbidden
637  void* pimpl_;
638  Patient(void* pimpl) : isReference_(true), pimpl_(pimpl) {}
639  public:
647  Patient(const Patient& other) : isReference_(true), pimpl_(other.pimpl_) { }
648  inline Patient(::OrthancClient::OrthancConnection& connection, const ::std::string& id);
649  inline ~Patient();
650  inline void Reload();
651  inline LAAW_UINT32 GetStudyCount();
652  inline ::OrthancClient::Study GetStudy(LAAW_UINT32 index);
653  inline ::std::string GetId() const;
654  inline ::std::string GetMainDicomTag(const ::std::string& tag, const ::std::string& defaultValue) const;
655  };
656 }
657 
658 namespace OrthancClient
659 {
666  class Series
667  {
668  friend class ::OrthancClient::OrthancConnection;
669  friend class ::OrthancClient::Patient;
670  friend class ::OrthancClient::Study;
671  friend class ::OrthancClient::Instance;
672  private:
673  bool isReference_;
674  Series& operator= (const Series&); // Assignment is forbidden
675  void* pimpl_;
676  Series(void* pimpl) : isReference_(true), pimpl_(pimpl) {}
677  public:
685  Series(const Series& other) : isReference_(true), pimpl_(other.pimpl_) { }
686  inline Series(::OrthancClient::OrthancConnection& connection, const ::std::string& id);
687  inline ~Series();
688  inline void Reload();
689  inline LAAW_UINT32 GetInstanceCount();
690  inline ::OrthancClient::Instance GetInstance(LAAW_UINT32 index);
691  inline ::std::string GetId() const;
692  inline ::std::string GetUrl() const;
693  inline ::std::string GetMainDicomTag(const ::std::string& tag, const ::std::string& defaultValue) const;
694  inline bool Is3DImage();
695  inline LAAW_UINT32 GetWidth();
696  inline LAAW_UINT32 GetHeight();
697  inline float GetVoxelSizeX();
698  inline float GetVoxelSizeY();
699  inline float GetVoxelSizeZ();
700  inline void Load3DImage(void* target, ::Orthanc::PixelFormat format, LAAW_INT64 lineStride, LAAW_INT64 stackStride);
701  inline void Load3DImage(void* target, ::Orthanc::PixelFormat format, LAAW_INT64 lineStride, LAAW_INT64 stackStride, float progress[]);
702  };
703 }
704 
705 namespace OrthancClient
706 {
713  class Study
714  {
715  friend class ::OrthancClient::OrthancConnection;
716  friend class ::OrthancClient::Patient;
717  friend class ::OrthancClient::Series;
718  friend class ::OrthancClient::Instance;
719  private:
720  bool isReference_;
721  Study& operator= (const Study&); // Assignment is forbidden
722  void* pimpl_;
723  Study(void* pimpl) : isReference_(true), pimpl_(pimpl) {}
724  public:
732  Study(const Study& other) : isReference_(true), pimpl_(other.pimpl_) { }
733  inline Study(::OrthancClient::OrthancConnection& connection, const ::std::string& id);
734  inline ~Study();
735  inline void Reload();
736  inline LAAW_UINT32 GetSeriesCount();
737  inline ::OrthancClient::Series GetSeries(LAAW_UINT32 index);
738  inline ::std::string GetId() const;
739  inline ::std::string GetMainDicomTag(const ::std::string& tag, const ::std::string& defaultValue) const;
740  };
741 }
742 
743 namespace OrthancClient
744 {
751  class Instance
752  {
753  friend class ::OrthancClient::OrthancConnection;
754  friend class ::OrthancClient::Patient;
755  friend class ::OrthancClient::Series;
756  friend class ::OrthancClient::Study;
757  private:
758  bool isReference_;
759  Instance& operator= (const Instance&); // Assignment is forbidden
760  void* pimpl_;
761  Instance(void* pimpl) : isReference_(true), pimpl_(pimpl) {}
762  public:
770  Instance(const Instance& other) : isReference_(true), pimpl_(other.pimpl_) { }
771  inline Instance(::OrthancClient::OrthancConnection& connection, const ::std::string& id);
772  inline ~Instance();
773  inline ::std::string GetId() const;
776  inline ::std::string GetTagAsString(const ::std::string& tag) const;
777  inline float GetTagAsFloat(const ::std::string& tag) const;
778  inline LAAW_INT32 GetTagAsInt(const ::std::string& tag) const;
779  inline LAAW_UINT32 GetWidth();
780  inline LAAW_UINT32 GetHeight();
781  inline LAAW_UINT32 GetPitch();
783  inline const void* GetBuffer();
784  inline const void* GetBuffer(LAAW_UINT32 y);
785  inline LAAW_UINT64 GetDicomSize();
786  inline const void* GetDicom();
787  inline void DiscardImage();
788  inline void DiscardDicom();
789  inline void LoadTagContent(const ::std::string& path);
790  inline ::std::string GetLoadedTagContent() const;
791  };
792 }
793 
794 namespace OrthancClient
795 {
803  inline OrthancConnection::OrthancConnection(const ::std::string& orthancUrl)
804  {
805  isReference_ = false;
806  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void**, const char*);
807  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(0);
808  char* error = function(&pimpl_, orthancUrl.c_str());
809  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
810  }
820  inline OrthancConnection::OrthancConnection(const ::std::string& orthancUrl, const ::std::string& username, const ::std::string& password)
821  {
822  isReference_ = false;
823  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void**, const char*, const char*, const char*);
824  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(1);
825  char* error = function(&pimpl_, orthancUrl.c_str(), username.c_str(), password.c_str());
826  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
827  }
835  {
836  if (isReference_) return;
837  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*);
838  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(2);
839  char* error = function(pimpl_);
840  error = error; // Remove warning about unused variable
841  }
849  inline LAAW_UINT32 OrthancConnection::GetThreadCount() const
850  {
851  LAAW_UINT32 result_;
852  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, LAAW_UINT32*);
853  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(3);
854  char* error = function(pimpl_, &result_);
855  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
856  return result_;
857  }
865  inline void OrthancConnection::SetThreadCount(LAAW_UINT32 threadCount)
866  {
867  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_UINT32);
868  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(4);
869  char* error = function(pimpl_, threadCount);
870  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
871  }
879  {
880  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*);
881  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(5);
882  char* error = function(pimpl_);
883  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
884  }
892  inline ::std::string OrthancConnection::GetOrthancUrl() const
893  {
894  const char* result_;
895  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, const char**);
896  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(6);
897  char* error = function(pimpl_, &result_);
898  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
899  return std::string(result_);
900  }
909  {
910  LAAW_UINT32 result_;
911  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_UINT32*);
912  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(7);
913  char* error = function(pimpl_, &result_);
914  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
915  return result_;
916  }
925  inline ::OrthancClient::Patient OrthancConnection::GetPatient(LAAW_UINT32 index)
926  {
927  void* result_;
928  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, void**, LAAW_UINT32);
929  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(8);
930  char* error = function(pimpl_, &result_, index);
931  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
932  return ::OrthancClient::Patient(result_);
933  }
942  inline void OrthancConnection::DeletePatient(LAAW_UINT32 index)
943  {
944  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_UINT32);
945  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(9);
946  char* error = function(pimpl_, index);
947  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
948  }
956  inline void OrthancConnection::StoreFile(const ::std::string& filename)
957  {
958  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, const char*);
959  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(10);
960  char* error = function(pimpl_, filename.c_str());
961  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
962  }
971  inline void OrthancConnection::Store(const void* dicom, LAAW_UINT64 size)
972  {
973  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, const void*, LAAW_UINT64);
974  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(11);
975  char* error = function(pimpl_, dicom, size);
976  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
977  }
978 }
979 
980 namespace OrthancClient
981 {
990  inline Patient::Patient(::OrthancClient::OrthancConnection& connection, const ::std::string& id)
991  {
992  isReference_ = false;
993  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void**, void*, const char*);
994  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(12);
995  char* error = function(&pimpl_, connection.pimpl_, id.c_str());
996  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
997  }
1005  {
1006  if (isReference_) return;
1007  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*);
1008  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(13);
1009  char* error = function(pimpl_);
1010  error = error; // Remove warning about unused variable
1011  }
1018  inline void Patient::Reload()
1019  {
1020  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*);
1021  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(14);
1022  char* error = function(pimpl_);
1023  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1024  }
1032  inline LAAW_UINT32 Patient::GetStudyCount()
1033  {
1034  LAAW_UINT32 result_;
1035  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_UINT32*);
1036  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(15);
1037  char* error = function(pimpl_, &result_);
1038  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1039  return result_;
1040  }
1049  inline ::OrthancClient::Study Patient::GetStudy(LAAW_UINT32 index)
1050  {
1051  void* result_;
1052  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, void**, LAAW_UINT32);
1053  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(16);
1054  char* error = function(pimpl_, &result_, index);
1055  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1056  return ::OrthancClient::Study(result_);
1057  }
1065  inline ::std::string Patient::GetId() const
1066  {
1067  const char* result_;
1068  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, const char**);
1069  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(17);
1070  char* error = function(pimpl_, &result_);
1071  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1072  return std::string(result_);
1073  }
1083  inline ::std::string Patient::GetMainDicomTag(const ::std::string& tag, const ::std::string& defaultValue) const
1084  {
1085  const char* result_;
1086  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, const char**, const char*, const char*);
1087  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(18);
1088  char* error = function(pimpl_, &result_, tag.c_str(), defaultValue.c_str());
1089  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1090  return std::string(result_);
1091  }
1092 }
1093 
1094 namespace OrthancClient
1095 {
1104  inline Series::Series(::OrthancClient::OrthancConnection& connection, const ::std::string& id)
1105  {
1106  isReference_ = false;
1107  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void**, void*, const char*);
1108  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(19);
1109  char* error = function(&pimpl_, connection.pimpl_, id.c_str());
1110  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1111  }
1119  {
1120  if (isReference_) return;
1121  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*);
1122  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(20);
1123  char* error = function(pimpl_);
1124  error = error; // Remove warning about unused variable
1125  }
1132  inline void Series::Reload()
1133  {
1134  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*);
1135  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(21);
1136  char* error = function(pimpl_);
1137  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1138  }
1146  inline LAAW_UINT32 Series::GetInstanceCount()
1147  {
1148  LAAW_UINT32 result_;
1149  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_UINT32*);
1150  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(22);
1151  char* error = function(pimpl_, &result_);
1152  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1153  return result_;
1154  }
1163  inline ::OrthancClient::Instance Series::GetInstance(LAAW_UINT32 index)
1164  {
1165  void* result_;
1166  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, void**, LAAW_UINT32);
1167  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(23);
1168  char* error = function(pimpl_, &result_, index);
1169  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1170  return ::OrthancClient::Instance(result_);
1171  }
1179  inline ::std::string Series::GetId() const
1180  {
1181  const char* result_;
1182  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, const char**);
1183  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(24);
1184  char* error = function(pimpl_, &result_);
1185  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1186  return std::string(result_);
1187  }
1195  inline ::std::string Series::GetUrl() const
1196  {
1197  const char* result_;
1198  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, const char**);
1199  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(25);
1200  char* error = function(pimpl_, &result_);
1201  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1202  return std::string(result_);
1203  }
1213  inline ::std::string Series::GetMainDicomTag(const ::std::string& tag, const ::std::string& defaultValue) const
1214  {
1215  const char* result_;
1216  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, const char**, const char*, const char*);
1217  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(26);
1218  char* error = function(pimpl_, &result_, tag.c_str(), defaultValue.c_str());
1219  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1220  return std::string(result_);
1221  }
1229  inline bool Series::Is3DImage()
1230  {
1231  LAAW_INT32 result_;
1232  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_INT32*);
1233  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(27);
1234  char* error = function(pimpl_, &result_);
1235  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1236  return result_ != 0;
1237  }
1245  inline LAAW_UINT32 Series::GetWidth()
1246  {
1247  LAAW_UINT32 result_;
1248  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_UINT32*);
1249  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(28);
1250  char* error = function(pimpl_, &result_);
1251  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1252  return result_;
1253  }
1261  inline LAAW_UINT32 Series::GetHeight()
1262  {
1263  LAAW_UINT32 result_;
1264  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_UINT32*);
1265  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(29);
1266  char* error = function(pimpl_, &result_);
1267  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1268  return result_;
1269  }
1277  inline float Series::GetVoxelSizeX()
1278  {
1279  float result_;
1280  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, float*);
1281  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(30);
1282  char* error = function(pimpl_, &result_);
1283  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1284  return result_;
1285  }
1293  inline float Series::GetVoxelSizeY()
1294  {
1295  float result_;
1296  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, float*);
1297  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(31);
1298  char* error = function(pimpl_, &result_);
1299  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1300  return result_;
1301  }
1309  inline float Series::GetVoxelSizeZ()
1310  {
1311  float result_;
1312  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, float*);
1313  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(32);
1314  char* error = function(pimpl_, &result_);
1315  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1316  return result_;
1317  }
1328  inline void Series::Load3DImage(void* target, ::Orthanc::PixelFormat format, LAAW_INT64 lineStride, LAAW_INT64 stackStride)
1329  {
1330  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, void*, LAAW_INT32, LAAW_INT64, LAAW_INT64);
1331  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(33);
1332  char* error = function(pimpl_, target, format, lineStride, stackStride);
1333  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1334  }
1346  inline void Series::Load3DImage(void* target, ::Orthanc::PixelFormat format, LAAW_INT64 lineStride, LAAW_INT64 stackStride, float progress[])
1347  {
1348  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, void*, LAAW_INT32, LAAW_INT64, LAAW_INT64, float*);
1349  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(34);
1350  char* error = function(pimpl_, target, format, lineStride, stackStride, progress);
1351  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1352  }
1353 }
1354 
1355 namespace OrthancClient
1356 {
1365  inline Study::Study(::OrthancClient::OrthancConnection& connection, const ::std::string& id)
1366  {
1367  isReference_ = false;
1368  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void**, void*, const char*);
1369  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(35);
1370  char* error = function(&pimpl_, connection.pimpl_, id.c_str());
1371  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1372  }
1379  inline Study::~Study()
1380  {
1381  if (isReference_) return;
1382  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*);
1383  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(36);
1384  char* error = function(pimpl_);
1385  error = error; // Remove warning about unused variable
1386  }
1393  inline void Study::Reload()
1394  {
1395  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*);
1396  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(37);
1397  char* error = function(pimpl_);
1398  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1399  }
1407  inline LAAW_UINT32 Study::GetSeriesCount()
1408  {
1409  LAAW_UINT32 result_;
1410  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_UINT32*);
1411  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(38);
1412  char* error = function(pimpl_, &result_);
1413  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1414  return result_;
1415  }
1424  inline ::OrthancClient::Series Study::GetSeries(LAAW_UINT32 index)
1425  {
1426  void* result_;
1427  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, void**, LAAW_UINT32);
1428  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(39);
1429  char* error = function(pimpl_, &result_, index);
1430  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1431  return ::OrthancClient::Series(result_);
1432  }
1440  inline ::std::string Study::GetId() const
1441  {
1442  const char* result_;
1443  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, const char**);
1444  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(40);
1445  char* error = function(pimpl_, &result_);
1446  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1447  return std::string(result_);
1448  }
1458  inline ::std::string Study::GetMainDicomTag(const ::std::string& tag, const ::std::string& defaultValue) const
1459  {
1460  const char* result_;
1461  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, const char**, const char*, const char*);
1462  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(41);
1463  char* error = function(pimpl_, &result_, tag.c_str(), defaultValue.c_str());
1464  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1465  return std::string(result_);
1466  }
1467 }
1468 
1469 namespace OrthancClient
1470 {
1479  inline Instance::Instance(::OrthancClient::OrthancConnection& connection, const ::std::string& id)
1480  {
1481  isReference_ = false;
1482  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void**, void*, const char*);
1483  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(42);
1484  char* error = function(&pimpl_, connection.pimpl_, id.c_str());
1485  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1486  }
1494  {
1495  if (isReference_) return;
1496  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*);
1497  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(43);
1498  char* error = function(pimpl_);
1499  error = error; // Remove warning about unused variable
1500  }
1508  inline ::std::string Instance::GetId() const
1509  {
1510  const char* result_;
1511  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, const char**);
1512  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(44);
1513  char* error = function(pimpl_, &result_);
1514  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1515  return std::string(result_);
1516  }
1525  {
1526  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_INT32);
1527  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(45);
1528  char* error = function(pimpl_, mode);
1529  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1530  }
1539  {
1540  LAAW_INT32 result_;
1541  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, LAAW_INT32*);
1542  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(46);
1543  char* error = function(pimpl_, &result_);
1544  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1545  return static_cast< ::Orthanc::ImageExtractionMode >(result_);
1546  }
1555  inline ::std::string Instance::GetTagAsString(const ::std::string& tag) const
1556  {
1557  const char* result_;
1558  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, const char**, const char*);
1559  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(47);
1560  char* error = function(pimpl_, &result_, tag.c_str());
1561  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1562  return std::string(result_);
1563  }
1572  inline float Instance::GetTagAsFloat(const ::std::string& tag) const
1573  {
1574  float result_;
1575  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, float*, const char*);
1576  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(48);
1577  char* error = function(pimpl_, &result_, tag.c_str());
1578  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1579  return result_;
1580  }
1589  inline LAAW_INT32 Instance::GetTagAsInt(const ::std::string& tag) const
1590  {
1591  LAAW_INT32 result_;
1592  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, LAAW_INT32*, const char*);
1593  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(49);
1594  char* error = function(pimpl_, &result_, tag.c_str());
1595  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1596  return result_;
1597  }
1605  inline LAAW_UINT32 Instance::GetWidth()
1606  {
1607  LAAW_UINT32 result_;
1608  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_UINT32*);
1609  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(50);
1610  char* error = function(pimpl_, &result_);
1611  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1612  return result_;
1613  }
1621  inline LAAW_UINT32 Instance::GetHeight()
1622  {
1623  LAAW_UINT32 result_;
1624  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_UINT32*);
1625  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(51);
1626  char* error = function(pimpl_, &result_);
1627  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1628  return result_;
1629  }
1637  inline LAAW_UINT32 Instance::GetPitch()
1638  {
1639  LAAW_UINT32 result_;
1640  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_UINT32*);
1641  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(52);
1642  char* error = function(pimpl_, &result_);
1643  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1644  return result_;
1645  }
1654  {
1655  LAAW_INT32 result_;
1656  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_INT32*);
1657  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(53);
1658  char* error = function(pimpl_, &result_);
1659  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1660  return static_cast< ::Orthanc::PixelFormat >(result_);
1661  }
1669  inline const void* Instance::GetBuffer()
1670  {
1671  const void* result_;
1672  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, const void**);
1673  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(54);
1674  char* error = function(pimpl_, &result_);
1675  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1676  return reinterpret_cast< const void* >(result_);
1677  }
1686  inline const void* Instance::GetBuffer(LAAW_UINT32 y)
1687  {
1688  const void* result_;
1689  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, const void**, LAAW_UINT32);
1690  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(55);
1691  char* error = function(pimpl_, &result_, y);
1692  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1693  return reinterpret_cast< const void* >(result_);
1694  }
1702  inline LAAW_UINT64 Instance::GetDicomSize()
1703  {
1704  LAAW_UINT64 result_;
1705  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, LAAW_UINT64*);
1706  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(56);
1707  char* error = function(pimpl_, &result_);
1708  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1709  return result_;
1710  }
1718  inline const void* Instance::GetDicom()
1719  {
1720  const void* result_;
1721  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, const void**);
1722  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(57);
1723  char* error = function(pimpl_, &result_);
1724  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1725  return reinterpret_cast< const void* >(result_);
1726  }
1734  {
1735  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*);
1736  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(58);
1737  char* error = function(pimpl_);
1738  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1739  }
1747  {
1748  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*);
1749  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(59);
1750  char* error = function(pimpl_);
1751  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1752  }
1760  inline void Instance::LoadTagContent(const ::std::string& path)
1761  {
1762  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (void*, const char*);
1763  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(60);
1764  char* error = function(pimpl_, path.c_str());
1765  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1766  }
1774  inline ::std::string Instance::GetLoadedTagContent() const
1775  {
1776  const char* result_;
1777  typedef char* (LAAW_ORTHANC_CLIENT_CALL_CONV* Function) (const void*, const char**);
1778  Function function = (Function) ::OrthancClient::Internals::Library::GetInstance().GetFunction(61);
1779  char* error = function(pimpl_, &result_);
1780  ::OrthancClient::Internals::Library::GetInstance().ThrowExceptionIfNeeded(error);
1781  return std::string(result_);
1782  }
1783 }
1784 
float GetVoxelSizeX()
Get the physical size of a voxel along the X-axis.
Definition: OrthancCppClient.h:1277
float GetVoxelSizeZ()
Get the physical size of a voxel along the Z-axis.
Definition: OrthancCppClient.h:1309
Connection to a study stored in Orthanc.
Definition: OrthancCppClient.h:713
LAAW_UINT32 GetHeight()
Get the height of the 3D image.
Definition: OrthancCppClient.h:1261
LAAW_UINT32 GetPatientCount()
Returns the number of patients.
Definition: OrthancCppClient.h:908
~Series()
Destructs the object.
Definition: OrthancCppClient.h:1118
LAAW_UINT32 GetInstanceCount()
Return the number of instances for this series.
Definition: OrthancCppClient.h:1146
void Store(const void *dicom, LAAW_UINT64 size)
Send a DICOM file that is contained inside a memory buffer.
Definition: OrthancCppClient.h:971
Graylevel, signed 16bpp image.
Definition: OrthancCppClient.h:510
Graylevel, unsigned 16bpp image.
Definition: OrthancCppClient.h:531
bool Is3DImage()
Test whether this series encodes a 3D image that can be downloaded from Orthanc.
Definition: OrthancCppClient.h:1229
const void * GetBuffer()
Access the memory buffer in which the raw pixels of the 2D image are stored.
Definition: OrthancCppClient.h:1669
PixelFormat
The memory layout of the pixels (resp. voxels) of a 2D (resp. 3D) image.
Definition: OrthancCppClient.h:502
Instance(const Instance &other)
Construct a new reference to this object.
Definition: OrthancCppClient.h:770
inline::std::string GetMainDicomTag(const ::std::string &tag, const ::std::string &defaultValue) const
Get the value of one of the main DICOM tags for this series.
Definition: OrthancCppClient.h:1213
Connection to an instance stored in Orthanc.
Definition: OrthancCppClient.h:751
inline::std::string GetId() const
Get the Orthanc identifier of this study.
Definition: OrthancCppClient.h:1440
Patient(const Patient &other)
Construct a new reference to this object.
Definition: OrthancCppClient.h:647
void SetImageExtractionMode(::Orthanc::ImageExtractionMode mode)
Set the extraction mode for the 2D image corresponding to this instance.
Definition: OrthancCppClient.h:1524
Truncation to the [0, 65535] range.
Definition: OrthancCppClient.h:573
inline::std::string GetUrl() const
Returns the URL to this series.
Definition: OrthancCppClient.h:1195
Truncation to the [-32768, 32767] range.
Definition: OrthancCppClient.h:552
inline::std::string GetLoadedTagContent() const
Return the value of the raw tag that was loaded by LoadContent.
Definition: OrthancCppClient.h:1774
inline::std::string GetId() const
Get the Orthanc identifier of this patient.
Definition: OrthancCppClient.h:1065
void Load3DImage(void *target,::Orthanc::PixelFormat format, LAAW_INT64 lineStride, LAAW_INT64 stackStride)
Load the 3D image into a memory buffer.
Definition: OrthancCppClient.h:1328
LAAW_UINT64 GetDicomSize()
Get the size of the DICOM file corresponding to this instance.
Definition: OrthancCppClient.h:1702
LAAW_UINT32 GetWidth()
Get the width of the 2D image.
Definition: OrthancCppClient.h:1605
const std::string & What() const
Get the error message associated with this exception.
Definition: OrthancCppClient.h:188
Connection to a patient stored in Orthanc.
Definition: OrthancCppClient.h:628
inline::OrthancClient::Instance GetInstance(LAAW_UINT32 index)
Get some instance of this series.
Definition: OrthancCppClient.h:1163
inline::std::string GetId() const
Get the Orthanc identifier of this series.
Definition: OrthancCppClient.h:1179
void Reload()
Reload the instances of this series.
Definition: OrthancCppClient.h:1132
LAAW_UINT32 GetThreadCount() const
Returns the number of threads for this connection.
Definition: OrthancCppClient.h:849
inline::OrthancClient::Patient GetPatient(LAAW_UINT32 index)
Get some patient.
Definition: OrthancCppClient.h:925
void LoadTagContent(const ::std::string &path)
Load a raw tag from the DICOM file.
Definition: OrthancCppClient.h:1760
inline::std::string GetMainDicomTag(const ::std::string &tag, const ::std::string &defaultValue) const
Get the value of one of the main DICOM tags for this study.
Definition: OrthancCppClient.h:1458
~Instance()
Destructs the object.
Definition: OrthancCppClient.h:1493
void DiscardImage()
Discard the downloaded 2D image, so as to make room in memory.
Definition: OrthancCppClient.h:1733
void DeletePatient(LAAW_UINT32 index)
Delete some patient.
Definition: OrthancCppClient.h:942
void DiscardDicom()
Discard the downloaded DICOM file, so as to make room in memory.
Definition: OrthancCppClient.h:1746
LAAW_UINT32 GetStudyCount()
Return the number of studies for this patient.
Definition: OrthancCppClient.h:1032
Exception class that is thrown by the functions of this shared library.
Definition: OrthancCppClient.h:166
LAAW_UINT32 GetSeriesCount()
Return the number of series for this study.
Definition: OrthancCppClient.h:1407
inline::Orthanc::ImageExtractionMode GetImageExtractionMode() const
Get the extraction mode for the 2D image corresponding to this instance.
Definition: OrthancCppClient.h:1538
void Finalize()
Manually finalize the shared library.
Definition: OrthancCppClient.h:363
inline::OrthancClient::Series GetSeries(LAAW_UINT32 index)
Get some series of this study.
Definition: OrthancCppClient.h:1424
Color image in RGB24 format.
Definition: OrthancCppClient.h:517
Truncation to the [0, 255] range.
Definition: OrthancCppClient.h:566
float GetTagAsFloat(const ::std::string &tag) const
Get the floating point value that is stored in some DICOM tag of this instance.
Definition: OrthancCppClient.h:1572
Graylevel 8bpp image.
Definition: OrthancCppClient.h:524
inline::Orthanc::PixelFormat GetPixelFormat()
Get the format of the pixels of the 2D image.
Definition: OrthancCppClient.h:1653
inline::std::string GetTagAsString(const ::std::string &tag) const
Get the string value of some DICOM tag of this instance.
Definition: OrthancCppClient.h:1555
Series(const Series &other)
Construct a new reference to this object.
Definition: OrthancCppClient.h:685
LAAW_UINT32 GetPitch()
Get the number of bytes between two lines of the image (pitch).
Definition: OrthancCppClient.h:1637
OrthancConnection(const OrthancConnection &other)
Construct a new reference to this object.
Definition: OrthancCppClient.h:604
ImageExtractionMode
The extraction mode specifies the way the values of the pixels are scaled when downloading a 2D image...
Definition: OrthancCppClient.h:544
~OrthancConnection()
Destructs the object.
Definition: OrthancCppClient.h:834
LAAW_UINT32 GetHeight()
Get the height of the 2D image.
Definition: OrthancCppClient.h:1621
OrthancClientException(std::string message)
Constructs an exception.
Definition: OrthancCppClient.h:176
void Initialize(const std::string &sharedLibraryPath)
Manually initialize the shared library.
Definition: OrthancCppClient.h:350
~Patient()
Destructs the object.
Definition: OrthancCppClient.h:1004
void SetThreadCount(LAAW_UINT32 threadCount)
Sets the number of threads for this connection.
Definition: OrthancCppClient.h:865
~Study()
Destructs the object.
Definition: OrthancCppClient.h:1379
Connection to a series stored in Orthanc.
Definition: OrthancCppClient.h:666
void StoreFile(const ::std::string &filename)
Send a DICOM file.
Definition: OrthancCppClient.h:956
inline::std::string GetId() const
Get the Orthanc identifier of this identifier.
Definition: OrthancCppClient.h:1508
LAAW_INT32 GetTagAsInt(const ::std::string &tag) const
Get the integer value that is stored in some DICOM tag of this instance.
Definition: OrthancCppClient.h:1589
void Reload()
Reload the list of the patients.
Definition: OrthancCppClient.h:878
LAAW_UINT32 GetWidth()
Get the width of the 3D image.
Definition: OrthancCppClient.h:1245
Rescaled to 8bpp.
Definition: OrthancCppClient.h:559
inline::std::string GetOrthancUrl() const
Returns the URL of this instance of Orthanc.
Definition: OrthancCppClient.h:892
float GetVoxelSizeY()
Get the physical size of a voxel along the Y-axis.
Definition: OrthancCppClient.h:1293
inline::OrthancClient::Study GetStudy(LAAW_UINT32 index)
Get some study of this patient.
Definition: OrthancCppClient.h:1049
inline::std::string GetMainDicomTag(const ::std::string &tag, const ::std::string &defaultValue) const
Get the value of one of the main DICOM tags for this patient.
Definition: OrthancCppClient.h:1083
Connection to an instance of Orthanc.
Definition: OrthancCppClient.h:585
const void * GetDicom()
Get a pointer to the content of the DICOM file corresponding to this instance.
Definition: OrthancCppClient.h:1718
Study(const Study &other)
Construct a new reference to this object.
Definition: OrthancCppClient.h:732
void Reload()
Reload the studies of this patient.
Definition: OrthancCppClient.h:1018
void Reload()
Reload the series of this study.
Definition: OrthancCppClient.h:1393