changeset 496:7f7a2d174acb laaw

preparing Laaw packaging
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 17 Jul 2013 17:07:12 +0200
parents 012b63028085
children ddeae3c3a8c2
files CMakeLists.txt Core/Enumerations.h OrthancCppClient/Instance.cpp OrthancCppClient/Instance.h OrthancCppClient/OrthancConnection.cpp OrthancCppClient/OrthancConnection.h OrthancCppClient/Package/ConfigurationCpp.json OrthancCppClient/Package/Laaw/laaw-exports.h OrthancCppClient/Package/Laaw/laaw.h OrthancCppClient/Package/Product.json OrthancCppClient/Package/Test.sh OrthancCppClient/Patient.cpp OrthancCppClient/Patient.h OrthancCppClient/Series.cpp OrthancCppClient/Series.h OrthancCppClient/Study.cpp OrthancCppClient/Study.h
diffstat 17 files changed, 258 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Wed Jul 17 13:45:28 2013 +0200
+++ b/CMakeLists.txt	Wed Jul 17 17:07:12 2013 +0200
@@ -104,7 +104,6 @@
 endif()
 
 
-
 # The main instructions to build the Orthanc binaries
 add_library(CoreLibrary
   STATIC
--- a/Core/Enumerations.h	Wed Jul 17 13:45:28 2013 +0200
+++ b/Core/Enumerations.h	Wed Jul 17 17:07:12 2013 +0200
@@ -32,6 +32,8 @@
 
 #pragma once
 
+#include "../OrthancCppClient/Package/Laaw/laaw.h"
+
 namespace Orthanc
 {
   enum Endianness
@@ -67,7 +69,7 @@
     ErrorCode_FullStorage
   };
 
-  enum PixelFormat
+  enum LAAW_API PixelFormat
   {
     PixelFormat_RGB24,
     PixelFormat_Grayscale8,
@@ -75,7 +77,7 @@
     PixelFormat_SignedGrayscale16
   };
 
-  enum ImageExtractionMode
+  enum LAAW_API ImageExtractionMode
   {
     ImageExtractionMode_Preview,
     ImageExtractionMode_UInt8,
--- a/OrthancCppClient/Instance.cpp	Wed Jul 17 13:45:28 2013 +0200
+++ b/OrthancCppClient/Instance.cpp	Wed Jul 17 17:07:12 2013 +0200
@@ -67,7 +67,7 @@
       }
 
       Orthanc::HttpClient client(connection_.GetHttpClient());
-      client.SetUrl(connection_.GetOrthancUrl() +  "/instances/" + id_ + "/" + suffix);
+      client.SetUrl(std::string(connection_.GetOrthancUrl()) +  "/instances/" + id_ + "/" + suffix);
       std::string png;
 
       if (!client.Apply(png))
@@ -81,14 +81,14 @@
   }
 
   Instance::Instance(const OrthancConnection& connection,
-                     const std::string& id) :
+                     const char* id) :
     connection_(connection),
     id_(id),
     mode_(Orthanc::ImageExtractionMode_Int16)
   {
     Orthanc::HttpClient client(connection_.GetHttpClient());
             
-    client.SetUrl(connection_.GetOrthancUrl() + "/instances/" + id_ + "/simplified-tags");
+    client.SetUrl(std::string(connection_.GetOrthancUrl()) + "/instances/" + id_ + "/simplified-tags");
     Json::Value v;
     if (!client.Apply(tags_))
     {
--- a/OrthancCppClient/Instance.h	Wed Jul 17 13:45:28 2013 +0200
+++ b/OrthancCppClient/Instance.h	Wed Jul 17 17:07:12 2013 +0200
@@ -35,6 +35,7 @@
 #include <string>
 #include <json/value.h>
 
+#include "Package/Laaw/laaw.h"
 #include "../Core/IDynamicObject.h"
 #include "../Core/FileFormats/PngReader.h"
 
@@ -42,7 +43,7 @@
 {
   class OrthancConnection;
 
-  class Instance : public Orthanc::IDynamicObject
+  class LAAW_API Instance : public Orthanc::IDynamicObject
   {
   private:
     const OrthancConnection& connection_;
@@ -55,11 +56,11 @@
 
   public:
     Instance(const OrthancConnection& connection,
-             const std::string& id);
+             const char* id);
 
-    const std::string& GetId() const
+    const char* GetId() const
     {
-      return id_;
+      return id_.c_str();
     }
 
     void SetImageExtractionMode(Orthanc::ImageExtractionMode mode);
@@ -73,23 +74,23 @@
 
     float GetTagAsFloat(const char* tag);
 
-    int GetTagAsInt(const char* tag);
+    int32_t GetTagAsInt(const char* tag);
 
-    unsigned int GetWidth();
+    uint32_t GetWidth();
 
-    unsigned int GetHeight();
+    uint32_t GetHeight();
 
-    unsigned int GetPitch();
+    uint32_t GetPitch();
 
     Orthanc::PixelFormat GetPixelFormat();
 
     const void* GetBuffer();
 
-    const void* GetBuffer(unsigned int y);
+    const void* GetBuffer(uint32_t y);
 
     void DiscardImage();
 
-    void SplitVectorOfFloats(std::vector<float>& target,
-                             const char* tag);
+    LAAW_API_INTERNAL void SplitVectorOfFloats(std::vector<float>& target,
+                                               const char* tag);
   };
 }
--- a/OrthancCppClient/OrthancConnection.cpp	Wed Jul 17 13:45:28 2013 +0200
+++ b/OrthancCppClient/OrthancConnection.cpp	Wed Jul 17 17:07:12 2013 +0200
@@ -49,7 +49,8 @@
   Orthanc::IDynamicObject* OrthancConnection::GetFillerItem(size_t index)
   {
     Json::Value::ArrayIndex tmp = static_cast<Json::Value::ArrayIndex>(index);
-    return new Patient(*this, content_[tmp].asString());
+    std::string id = content_[tmp].asString();
+    return new Patient(*this, id.c_str());
   }
 
   Patient& OrthancConnection::GetPatient(unsigned int index)
--- a/OrthancCppClient/OrthancConnection.h	Wed Jul 17 13:45:28 2013 +0200
+++ b/OrthancCppClient/OrthancConnection.h	Wed Jul 17 17:07:12 2013 +0200
@@ -38,7 +38,7 @@
 
 namespace OrthancClient
 {
-  class OrthancConnection : 
+  class LAAW_API OrthancConnection : 
     public boost::noncopyable,
     private Orthanc::ArrayFilledByThreads::IFiller
   {
@@ -64,12 +64,12 @@
                       const char* username, 
                       const char* password);
 
-    unsigned int GetThreadCount() const
+    uint32_t GetThreadCount() const
     {
       return patients_.GetThreadCount();
     }
 
-    void SetThreadCount(unsigned int threadCount)
+    void SetThreadCount(uint32_t threadCount)
     {
       patients_.SetThreadCount(threadCount);
     }
@@ -84,16 +84,16 @@
       return client_;
     }
 
-    const std::string& GetOrthancUrl() const
+    const char* GetOrthancUrl() const
     {
-      return orthancUrl_;
+      return orthancUrl_.c_str();
     }
 
-    unsigned int GetPatientCount()
+    uint32_t GetPatientCount()
     {
       return patients_.GetSize();
     }
 
-    Patient& GetPatient(unsigned int index);
+    Patient& GetPatient(uint32_t index);
   };
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancCppClient/Package/ConfigurationCpp.json	Wed Jul 17 17:07:12 2013 +0200
@@ -0,0 +1,5 @@
+{
+  "InternalsNamespace" : [ "OrthancClient", "Internals" ],
+  "PublicNamespace" : [ "OrthancClient" ],
+  "ExceptionClassName" : "OrthancException"
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancCppClient/Package/Laaw/laaw-exports.h	Wed Jul 17 17:07:12 2013 +0200
@@ -0,0 +1,85 @@
+/**
+ * Laaw - A Lightweight, Automated API Wrapper
+ * Copyright (C) 2010-2013 Alain Mazy, Benjamin Golinvaux, Sebastien
+ * Jodogne
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * In addition, as a special exception, the copyright holders of this
+ * program give permission to link the code of its release with the
+ * OpenSSL project's "OpenSSL" library (or with modified versions of it
+ * that use the same license as the "OpenSSL" library), and distribute
+ * the linked executables. You must obey the GNU General Public License
+ * in all respects for all of the code used other than "OpenSSL". If you
+ * modify file(s) with this exception, you may extend this exception to
+ * your version of the file(s), but you are not obligated to do so. If
+ * you do not wish to do so, delete this exception statement from your
+ * version. If you delete this exception statement from all source files
+ * in the program, then also delete it here.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+#pragma once
+
+/********************************************************************
+ ** Windows target
+ ********************************************************************/
+
+#if defined _WIN32
+
+#include <windows.h>
+
+#if defined(__GNUC__)
+// This is Mingw
+#define LAAW_EXPORT_DLL_API  // The exports are handled by the .DEF file
+#else
+// This is MSVC
+#define LAAW_EXPORT_DLL_API __declspec(dllexport)
+#endif
+
+#ifdef _M_X64
+// 64 bits target
+#define LAAW_CALL_CONVENTION
+#else
+// 32 bits target
+#define LAAW_CALL_CONVENTION  __stdcall  // Use the StdCall in Windows32 (for VB6)
+#endif
+
+
+/********************************************************************
+ ** Linux target
+ ********************************************************************/
+
+#elif defined(__linux)
+
+// Try the gcc visibility support
+// http://gcc.gnu.org/wiki/Visibility
+#if ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#define LAAW_EXPORT_DLL_API  __attribute__ ((visibility("default")))
+#define LAAW_CALL_CONVENTION
+#else
+#error No support for visibility in your version of GCC
+#endif
+
+
+/********************************************************************
+ ** Max OS X target
+ ********************************************************************/
+
+#else
+
+#define LAAW_EXPORT_DLL_API  __attribute__ ((visibility("default")))
+#define LAAW_CALL_CONVENTION
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancCppClient/Package/Laaw/laaw.h	Wed Jul 17 17:07:12 2013 +0200
@@ -0,0 +1,89 @@
+/**
+ * Laaw - A Lightweight, Automated API Wrapper
+ * Copyright (C) 2010-2013 Alain Mazy, Benjamin Golinvaux, Sebastien
+ * Jodogne
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * In addition, as a special exception, the copyright holders of this
+ * program give permission to link the code of its release with the
+ * OpenSSL project's "OpenSSL" library (or with modified versions of it
+ * that use the same license as the "OpenSSL" library), and distribute
+ * the linked executables. You must obey the GNU General Public License
+ * in all respects for all of the code used other than "OpenSSL". If you
+ * modify file(s) with this exception, you may extend this exception to
+ * your version of the file(s), but you are not obligated to do so. If
+ * you do not wish to do so, delete this exception statement from your
+ * version. If you delete this exception statement from all source files
+ * in the program, then also delete it here.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+#pragma once
+
+#include "laaw-exports.h"
+#include <stddef.h>
+#include <string>
+
+#if (LAAW_PARSING == 1)
+
+#define LAAW_API   __attribute__((deprecated("")))
+#define LAAW_API_INTERNAL  __attribute__((deprecated("")))
+#define LAAW_API_OVERLOAD(name)  __attribute__((deprecated("")))
+#define LAAW_API_PROPERTY  __attribute__((deprecated("")))
+#define LAAW_API_STATIC_CLASS  __attribute__((deprecated("")))
+#define LAAW_API_CUSTOM(name, value)  __attribute__((deprecated("")))
+
+#else
+
+#define LAAW_API
+#define LAAW_API_INTERNAL
+#define LAAW_API_OVERLOAD(name)
+#define LAAW_API_PROPERTY
+#define LAAW_API_STATIC_CLASS
+#define LAAW_API_CUSTOM(name, value)
+
+#endif
+
+
+namespace Laaw
+{
+  /**
+   * This is the base class from which all the public exceptions in
+   * the SDK should derive.
+   **/
+  class LaawException
+  {
+  private:
+    std::string what_;
+
+  public:
+    LaawException()
+    {
+    }
+
+    LaawException(const std::string& what) : what_(what)
+    {
+    }
+
+    LaawException(const char* what) : what_(what)
+    {
+    }
+
+    virtual const char* What() const
+    {
+      return what_.c_str();
+    }
+  };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancCppClient/Package/Product.json	Wed Jul 17 17:07:12 2013 +0200
@@ -0,0 +1,8 @@
+{
+  "Product" : "OrthancClient",
+  "Description" : "Native client to the REST API of Orthanc",
+  "Company" : "CHU of Liege",
+  "Copyright" : "(c) 2012-2013 CHU of Liege",
+  "Legal" : "Licensing information is available on https://code.google.com/p/orthanc/",
+  "Version" : "1.0.1"
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancCppClient/Package/Test.sh	Wed Jul 17 17:07:12 2013 +0200
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+mkdir -p Build
+LAAW_ROOT=~/Subversion/Jomago/Src/Labo/Laaw
+
+${LAAW_ROOT}/Parser/Build/LaawParser.exe Build/CodeModelRaw.json ../OrthancConnection.h -I`pwd`/../../s/jsoncpp-src-0.6.0-rc2/include -fms-extensions && \
+    python ${LAAW_ROOT}/Generators/CodeModelPostProcessing.py Build/CodeModel.json Build/CodeModelRaw.json Product.json && \
+    python ${LAAW_ROOT}/Generators/GenerateWrapperCpp.py Build/OrthancClient.h Build/CodeModel.json Product.json ConfigurationCpp.json
--- a/OrthancCppClient/Patient.cpp	Wed Jul 17 13:45:28 2013 +0200
+++ b/OrthancCppClient/Patient.cpp	Wed Jul 17 17:07:12 2013 +0200
@@ -40,7 +40,8 @@
   void Patient::ReadPatient()
   {
     Orthanc::HttpClient client(connection_.GetHttpClient());
-    client.SetUrl(connection_.GetOrthancUrl() + "/patients/" + id_);
+    client.SetUrl(std::string(connection_.GetOrthancUrl()) + "/patients/" + id_);
+
     Json::Value v;
     if (!client.Apply(patient_))
     {
@@ -55,7 +56,7 @@
   }
 
   Patient::Patient(const OrthancConnection& connection,
-                   const std::string& id) :
+                   const char* id) :
     connection_(connection),
     id_(id),
     studies_(*this)
--- a/OrthancCppClient/Patient.h	Wed Jul 17 13:45:28 2013 +0200
+++ b/OrthancCppClient/Patient.h	Wed Jul 17 17:07:12 2013 +0200
@@ -36,7 +36,7 @@
 
 namespace OrthancClient
 {
-  class Patient : 
+  class LAAW_API Patient : 
     public Orthanc::IDynamicObject, 
     private Orthanc::ArrayFilledByThreads::IFiller
   {
@@ -57,26 +57,26 @@
 
   public:
     Patient(const OrthancConnection& connection,
-            const std::string& id);
+            const char* id);
 
     void Reload()
     {
       studies_.Reload();
     }
 
-    unsigned int GetStudyCount()
+    uint32_t GetStudyCount()
     {
       return studies_.GetSize();
     }
 
-    Study& GetStudy(unsigned int index)
+    Study& GetStudy(uint32_t index)
     {
       return dynamic_cast<Study&>(studies_.GetItem(index));
     }
 
-    const std::string& GetId() const
+    const char* GetId() const
     {
-      return id_;
+      return id_.c_str();
     }
 
     std::string GetMainDicomTag(const char* tag, 
--- a/OrthancCppClient/Series.cpp	Wed Jul 17 13:45:28 2013 +0200
+++ b/OrthancCppClient/Series.cpp	Wed Jul 17 17:07:12 2013 +0200
@@ -205,7 +205,7 @@
   {
     Orthanc::HttpClient client(connection_.GetHttpClient());
 
-    client.SetUrl(connection_.GetOrthancUrl() + "/series/" + id_);
+    client.SetUrl(std::string(connection_.GetOrthancUrl()) + "/series/" + id_);
     Json::Value v;
     if (!client.Apply(series_))
     {
@@ -216,11 +216,12 @@
   Orthanc::IDynamicObject* Series::GetFillerItem(size_t index)
   {
     Json::Value::ArrayIndex tmp = static_cast<Json::Value::ArrayIndex>(index);
-    return new Instance(connection_, series_["Instances"][tmp].asString());
+    std::string id = series_["Instances"][tmp].asString();
+    return new Instance(connection_, id.c_str());
   }
 
   Series::Series(const OrthancConnection& connection,
-                 const std::string& id) :
+                 const char* id) :
     connection_(connection),
     id_(id),
     instances_(*this)
@@ -254,7 +255,7 @@
 
   std::string Series::GetUrl() const
   {
-    return connection_.GetOrthancUrl() + "/series/" + id_;
+    return std::string(connection_.GetOrthancUrl()) + "/series/" + id_;
   }
 
   unsigned int Series::GetWidth()
--- a/OrthancCppClient/Series.h	Wed Jul 17 13:45:28 2013 +0200
+++ b/OrthancCppClient/Series.h	Wed Jul 17 17:07:12 2013 +0200
@@ -39,7 +39,7 @@
 
 namespace OrthancClient
 {
-  class Series :
+  class LAAW_API Series :
     public Orthanc::IDynamicObject, 
     private Orthanc::ArrayFilledByThreads::IFiller
   {
@@ -78,7 +78,7 @@
 
   public:
     Series(const OrthancConnection& connection,
-           const std::string& id);
+           const char* id);
 
     void Reload()
     {
@@ -87,39 +87,39 @@
 
     bool Is3DImage();
 
-    unsigned int GetInstanceCount();
+    uint32_t GetInstanceCount();
 
-    Instance& GetInstance(unsigned int index);
+    Instance& GetInstance(uint32_t index);
 
-    const std::string& GetId() const
+    const char* GetId() const
     {
-      return id_;
+      return id_.c_str();
     }
 
     std::string GetUrl() const;
 
-    unsigned int GetWidth();
+    uint32_t GetWidth();
 
-    unsigned int GetHeight();
+    uint32_t GetHeight();
 
     void GetVoxelSize(float& sizeX, float& sizeY, float& sizeZ);  
 
     std::string GetMainDicomTag(const char* tag, 
                                 const char* defaultValue) const;
 
-    void Load3DImage(void* target,
-                     Orthanc::PixelFormat format,
-                     size_t lineStride,
-                     size_t stackStride,
-                     Orthanc::ThreadedCommandProcessor::IListener& listener)
+    LAAW_API_INTERNAL void Load3DImage(void* target,
+                                       Orthanc::PixelFormat format,
+                                       int64_t lineStride,
+                                       int64_t stackStride,
+                                       Orthanc::ThreadedCommandProcessor::IListener& listener)
     {
       Load3DImage(target, format, lineStride, stackStride, &listener);
     }
 
     void Load3DImage(void* target,
                      Orthanc::PixelFormat format,
-                     size_t lineStride,
-                     size_t stackStride)
+                     int64_t lineStride,
+                     int64_t stackStride)
     {
       Load3DImage(target, format, lineStride, stackStride, NULL);
     }
--- a/OrthancCppClient/Study.cpp	Wed Jul 17 13:45:28 2013 +0200
+++ b/OrthancCppClient/Study.cpp	Wed Jul 17 17:07:12 2013 +0200
@@ -40,7 +40,8 @@
   void Study::ReadStudy()
   {
     Orthanc::HttpClient client(connection_.GetHttpClient());
-    client.SetUrl(connection_.GetOrthancUrl() + "/studies/" + id_);
+    client.SetUrl(std::string(connection_.GetOrthancUrl()) + "/studies/" + id_);
+
     Json::Value v;
     if (!client.Apply(study_))
     {
@@ -51,7 +52,8 @@
   Orthanc::IDynamicObject* Study::GetFillerItem(size_t index)
   {
     Json::Value::ArrayIndex tmp = static_cast<Json::Value::ArrayIndex>(index);
-    return new Series(connection_, study_["Series"][tmp].asString());
+    std::string id = study_["Series"][tmp].asString();
+    return new Series(connection_, id.c_str());
   }
 
   Study::Study(const OrthancConnection& connection,
--- a/OrthancCppClient/Study.h	Wed Jul 17 13:45:28 2013 +0200
+++ b/OrthancCppClient/Study.h	Wed Jul 17 17:07:12 2013 +0200
@@ -64,12 +64,12 @@
       series_.Reload();
     }
 
-    unsigned int GetSeriesCount()
+    uint32_t GetSeriesCount()
     {
       return series_.GetSize();
     }
 
-    Series& GetSeries(unsigned int index)
+    Series& GetSeries(uint32_t index)
     {
       return dynamic_cast<Series&>(series_.GetItem(index));
     }