changeset 193:a1b9d1e1497b

failed attempt to compile with linux standard base
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 13 Nov 2012 14:02:28 +0100
parents c56dc32266e0
children 0186ac92810c
files OrthancServer/DatabaseWrapper.cpp OrthancServer/DatabaseWrapper.h OrthancServer/OrthancRestApi.cpp OrthancServer/ServerIndex.cpp OrthancServer/ServerIndex.h Resources/CMake/BoostConfiguration.cmake Resources/CMake/Compiler.cmake Resources/CMake/DcmtkConfiguration.cmake Resources/LinuxStandardBaseToolchain.cmake UnitTests/ServerIndex.cpp
diffstat 10 files changed, 125 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/DatabaseWrapper.cpp	Tue Nov 13 11:29:43 2012 +0100
+++ b/OrthancServer/DatabaseWrapper.cpp	Tue Nov 13 14:02:28 2012 +0100
@@ -240,6 +240,20 @@
     s.Run();
   }
 
+  void DatabaseWrapper::GetChildren(Json::Value& childrenPublicIds,
+                                    int64_t id)
+  {
+    SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT publicId FROM Resources WHERE parentId=?");
+    s.BindInt(0, id);
+
+    childrenPublicIds = Json::arrayValue;
+    while (s.Step())
+    {
+      childrenPublicIds.append(s.ColumnString(0));
+    }
+  }
+
+
   void DatabaseWrapper::DeleteResource(int64_t id)
   {
     signalRemainingAncestor_->Reset();
--- a/OrthancServer/DatabaseWrapper.h	Tue Nov 13 11:29:43 2012 +0100
+++ b/OrthancServer/DatabaseWrapper.h	Tue Nov 13 14:02:28 2012 +0100
@@ -81,6 +81,9 @@
     void AttachChild(int64_t parent,
                      int64_t child);
 
+    void GetChildren(Json::Value& childrenPublicIds,
+                     int64_t id);
+
     void DeleteResource(int64_t id);
 
     void SetMetadata(int64_t id,
--- a/OrthancServer/OrthancRestApi.cpp	Tue Nov 13 11:29:43 2012 +0100
+++ b/OrthancServer/OrthancRestApi.cpp	Tue Nov 13 14:02:28 2012 +0100
@@ -568,17 +568,18 @@
               uri[2] == "tags" || 
               uri[2] == "simplified-tags"))
     {
+      CompressionType compressionType;
       std::string fileUuid, contentType, filename;
       if (uri[2] == "file")
       {
-        existingResource = index_.GetFile(fileUuid, uri[1], "dicom");
+        existingResource = index_.GetFile(fileUuid, compressionType, uri[1], "dicom");
         contentType = "application/dicom";
         filename = fileUuid + ".dcm";
       }
       else if (uri[2] == "tags" ||
                uri[2] == "simplified-tags")
       {
-        existingResource = index_.GetFile(fileUuid, uri[1], "json");
+        existingResource = index_.GetFile(fileUuid, compressionType, uri[1], "json");
         contentType = "application/json";
         filename = fileUuid + ".json";
       }
@@ -642,7 +643,8 @@
                 uri[4] == "image-uint16"))))
     {
       std::string uuid;
-      existingResource = index_.GetFile(uuid, uri[1], "dicom");
+      CompressionType compressionType;
+      existingResource = index_.GetFile(uuid, compressionType, uri[1], "dicom");
 
       std::string action = uri[2];
 
--- a/OrthancServer/ServerIndex.cpp	Tue Nov 13 11:29:43 2012 +0100
+++ b/OrthancServer/ServerIndex.cpp	Tue Nov 13 14:02:28 2012 +0100
@@ -943,59 +943,24 @@
   }
 
 
-  bool ServerIndex::GetJsonFile(std::string& fileUuid,
-                                const std::string& instanceUuid)
-  {
-    boost::mutex::scoped_lock scoped_lock(mutex_);
-
-    SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT jsonUuid FROM Instances WHERE uuid=?");
-    s.BindString(0, instanceUuid);
-    if (s.Step())
-    {
-      fileUuid = s.ColumnString(0);
-      return true;
-    }
-    else
-    {
-      return false;
-    }
-  }
-
-  bool ServerIndex::GetDicomFile(std::string& fileUuid,
-                                 const std::string& instanceUuid)
+  bool ServerIndex::GetFile(std::string& fileUuid,
+                            CompressionType& compressionType,
+                            const std::string& instanceUuid,
+                            const std::string& contentName)
   {
     boost::mutex::scoped_lock scoped_lock(mutex_);
 
-    SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT fileUuid FROM Instances WHERE uuid=?");
-    s.BindString(0, instanceUuid);
-    if (s.Step())
-    {
-      fileUuid = s.ColumnString(0);
-      return true;
-    }
-    else
-    {
-      return false;
-    }
-  }
-
-
-  bool ServerIndex::GetFile(std::string& fileUuid,
-                            const std::string& instanceUuid,
-                            const std::string& contentName)
-  {
-    if (contentName == "json")
-    {
-      return GetJsonFile(fileUuid, instanceUuid);
-    }
-    else if (contentName == "dicom")
-    {
-      return GetDicomFile(fileUuid, instanceUuid);
-    }
-    else
+    int64_t id;
+    ResourceType type;
+    if (!db2_->LookupResource(instanceUuid, id, type) ||
+        type != ResourceType_Instance)
     {
       throw OrthancException(ErrorCode_InternalError);
     }
+
+    uint64_t compressedSize, uncompressedSize;
+
+    return db2_->LookupFile(id, contentName, fileUuid, compressedSize, uncompressedSize, compressionType);
   }
 
 
--- a/OrthancServer/ServerIndex.h	Tue Nov 13 11:29:43 2012 +0100
+++ b/OrthancServer/ServerIndex.h	Tue Nov 13 14:02:28 2012 +0100
@@ -121,12 +121,6 @@
                        const std::string& jsonUuid,
                        const std::string& remoteAet);
 
-    bool GetJsonFile(std::string& fileUuid,
-                     const std::string& instanceUuid);
-
-    bool GetDicomFile(std::string& fileUuid,
-                      const std::string& instanceUuid);
-
   public:
     ServerIndex(const std::string& storagePath);
 
@@ -163,6 +157,7 @@
                     const std::string& patientUuid);
 
     bool GetFile(std::string& fileUuid,
+                 CompressionType& compressionType,
                  const std::string& instanceUuid,
                  const std::string& contentName);
 
--- a/Resources/CMake/BoostConfiguration.cmake	Tue Nov 13 11:29:43 2012 +0100
+++ b/Resources/CMake/BoostConfiguration.cmake	Tue Nov 13 14:02:28 2012 +0100
@@ -52,6 +52,11 @@
     add_definitions(
       -DBOOST_LOCALE_WITH_ICONV=1
       )
+
+    if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
+      add_definitions(-DBOOST_HAS_SCHED_YIELD=1)
+    endif()
+
   elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
     list(APPEND BOOST_SOURCES
       ${BOOST_SOURCES_DIR}/libs/thread/src/win32/tss_dll.cpp
--- a/Resources/CMake/Compiler.cmake	Tue Nov 13 11:29:43 2012 +0100
+++ b/Resources/CMake/Compiler.cmake	Tue Nov 13 14:02:28 2012 +0100
@@ -51,6 +51,10 @@
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DEBIAN_CXX_FLAGS} ${DEBIAN_CPP_FLAGS}")
   endif()
 
+  if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdinc++ -I${LSB_PATH}/include -I${LSB_PATH}/include/c++ -I${LSB_PATH}/include/c++/backward -fpermissive")
+  endif()
+
   add_definitions(
     -D_LARGEFILE64_SOURCE=1 
     -D_FILE_OFFSET_BITS=64
--- a/Resources/CMake/DcmtkConfiguration.cmake	Tue Nov 13 11:29:43 2012 +0100
+++ b/Resources/CMake/DcmtkConfiguration.cmake	Tue Nov 13 14:02:28 2012 +0100
@@ -12,7 +12,22 @@
   SET(DCMTK_SOURCE_DIR ${CMAKE_BINARY_DIR}/dcmtk-3.6.0)
   include(${DCMTK_SOURCES_DIR}/CMake/CheckFunctionWithHeaderExists.cmake)
   include(${DCMTK_SOURCES_DIR}/CMake/GenerateDCMTKConfigure.cmake)
-  CONFIGURE_FILE(${DCMTK_SOURCES_DIR}/CMake/osconfig.h.in
+
+  if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
+    set(HAVE_SSTREAM 1)
+    set(HAVE_PROTOTYPE_BZERO 1)
+    set(HAVE_PROTOTYPE_GETHOSTNAME 1)
+    set(HAVE_PROTOTYPE_GETSOCKOPT 1)
+    set(HAVE_PROTOTYPE_SETSOCKOPT 1)
+    set(HAVE_PROTOTYPE_CONNECT 1)
+    set(HAVE_PROTOTYPE_BIND 1)
+    set(HAVE_PROTOTYPE_ACCEPT 1)
+    set(HAVE_PROTOTYPE_SETSOCKNAME 1)
+    set(HAVE_PROTOTYPE_GETSOCKNAME 1)
+  endif()
+
+  CONFIGURE_FILE(
+    ${DCMTK_SOURCES_DIR}/CMake/osconfig.h.in
     ${DCMTK_SOURCES_DIR}/config/include/dcmtk/config/osconfig.h)
 
   AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmnet/libsrc THIRD_PARTY_SOURCES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/LinuxStandardBaseToolchain.cmake	Tue Nov 13 14:02:28 2012 +0100
@@ -0,0 +1,41 @@
+INCLUDE(CMakeForceCompiler)
+
+SET(LSB_PATH $ENV{LSB_PATH})
+SET(LSB_TARGET_VERSION "4.0")
+
+IF ("${LSB_PATH}" STREQUAL "")
+  SET(LSB_PATH "/opt/lsb")
+ENDIF()
+
+message("Using the following Linux Standard Base: ${LSB_PATH}")
+
+IF (EXISTS ${LSB_PATH}/lib64)
+  SET(LSB_TARGET_PROCESSOR "x86_64")
+ELSEIF (EXISTS ${LSB_PATH}/lib)
+  SET(LSB_TARGET_PROCESSOR "x86")
+ELSE()
+  MESSAGE(FATAL_ERROR "Unable to detect the target processor architecture. Check the LSB_PATH environment variable.")
+ENDIF()
+
+SET(LSB_CPPPATH ${LSB_PATH}/include)
+SET(LSB_LIBPATH ${LSB_PATH}/lib-${LSB_TARGET_VERSION})
+SET(PKG_CONFIG_PATH ${LSB_LIBPATH}/pkgconfig/)
+
+# the name of the target operating system
+SET(CMAKE_SYSTEM_NAME Linux)
+SET(CMAKE_SYSTEM_VERSION LinuxStandardBase)
+SET(CMAKE_SYSTEM_PROCESSOR ${LSB_TARGET_PROCESSOR})
+
+# which compilers to use for C and C++
+SET(CMAKE_C_COMPILER ${LSB_PATH}/bin/lsbcc)
+CMAKE_FORCE_CXX_COMPILER(${LSB_PATH}/bin/lsbc++ GNU)
+
+# here is the target environment located
+SET(CMAKE_FIND_ROOT_PATH ${LSB_PATH})
+
+# adjust the default behaviour of the FIND_XXX() commands:
+# search headers and libraries in the target environment, search 
+# programs in the host environment
+SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
--- a/UnitTests/ServerIndex.cpp	Tue Nov 13 11:29:43 2012 +0100
+++ b/UnitTests/ServerIndex.cpp	Tue Nov 13 14:02:28 2012 +0100
@@ -198,6 +198,30 @@
   index.AttachChild(a[0], a[5]);
   index.AttachChild(a[5], a[7]);
 
+  {
+    Json::Value j;
+    index.GetChildren(j, a[0]);
+    ASSERT_EQ(2, j.size());
+    ASSERT_TRUE((j[0u] == "b" && j[1u] == "f") ||
+                (j[1u] == "b" && j[0u] == "f"));
+
+    index.GetChildren(j, a[1]);
+    ASSERT_EQ(2, j.size());
+    ASSERT_TRUE((j[0u] == "c" && j[1u] == "g") ||
+                (j[1u] == "c" && j[0u] == "g"));
+
+    index.GetChildren(j, a[2]);
+    ASSERT_EQ(2, j.size());
+    ASSERT_TRUE((j[0u] == "d" && j[1u] == "e") ||
+                (j[1u] == "d" && j[0u] == "e"));
+
+    index.GetChildren(j, a[3]); ASSERT_EQ(0, j.size());
+    index.GetChildren(j, a[4]); ASSERT_EQ(0, j.size());
+    index.GetChildren(j, a[5]); ASSERT_EQ(1, j.size()); ASSERT_EQ("h", j[0u].asString());
+    index.GetChildren(j, a[6]); ASSERT_EQ(0, j.size());
+    index.GetChildren(j, a[7]); ASSERT_EQ(0, j.size());
+  }
+
   listener.Reset();
   index.DeleteResource(a[3]);
   ASSERT_EQ("c", listener.ancestorId_);