changeset 1632:eb8fbcf008b5

fix build with plugins disabled
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 21 Sep 2015 14:05:06 +0200
parents 0d074f5f6069
children b7dfb048b2f3 c095b0ddeea6
files OrthancServer/OrthancRestApi/OrthancRestSystem.cpp OrthancServer/ServerContext.cpp OrthancServer/ServerContext.h OrthancServer/main.cpp Plugins/Engine/IPluginServiceProvider.h Plugins/Engine/OrthancPluginDatabase.cpp Plugins/Engine/OrthancPluginDatabase.h Plugins/Engine/OrthancPlugins.cpp Plugins/Engine/OrthancPlugins.h Plugins/Engine/PluginsEnumerations.cpp Plugins/Engine/PluginsEnumerations.h Plugins/Engine/PluginsManager.cpp Plugins/Engine/PluginsManager.h Plugins/Engine/SharedLibrary.cpp Plugins/Engine/SharedLibrary.h
diffstat 15 files changed, 103 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestSystem.cpp	Mon Sep 21 13:33:50 2015 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestSystem.cpp	Mon Sep 21 14:05:06 2015 +0200
@@ -65,6 +65,8 @@
     result["StorageAreaPlugin"] = Json::nullValue;
     result["DatabaseBackendPlugin"] = Json::nullValue;
 
+#if ORTHANC_PLUGINS_ENABLED == 1
+    result["PluginsEnabled"] = true;
     const OrthancPlugins& plugins = OrthancRestApi::GetContext(call).GetPlugins();
 
     if (plugins.HasStorageArea())
@@ -78,6 +80,9 @@
       std::string p = plugins.GetDatabaseBackendLibrary().GetPath();
       result["DatabaseBackendPlugin"] = boost::filesystem::canonical(p).string();     
     }
+#else
+    result["PluginsEnabled"] = false;
+#endif
 
     call.GetOutput().AnswerJson(result);
   }
@@ -150,6 +155,7 @@
 
     if (OrthancRestApi::GetContext(call).HasPlugins())
     {
+#if ORTHANC_PLUGINS_ENABLED == 1
       std::list<std::string> plugins;
       OrthancRestApi::GetContext(call).GetPlugins().GetManager().ListPlugins(plugins);
 
@@ -158,6 +164,7 @@
       {
         v.append(*it);
       }
+#endif
     }
 
     call.GetOutput().AnswerJson(v);
@@ -171,6 +178,7 @@
       return;
     }
 
+#if ORTHANC_PLUGINS_ENABLED == 1
     const PluginsManager& manager = OrthancRestApi::GetContext(call).GetPlugins().GetManager();
     std::string id = call.GetUriComponent("id", "");
 
@@ -208,6 +216,7 @@
 
       call.GetOutput().AnswerJson(v);
     }
+#endif
   }
 
 
@@ -217,6 +226,7 @@
 
     if (OrthancRestApi::GetContext(call).HasPlugins())
     {
+#if ORTHANC_PLUGINS_ENABLED == 1
       const OrthancPlugins& plugins = OrthancRestApi::GetContext(call).GetPlugins();
       const PluginsManager& manager = plugins.GetManager();
 
@@ -233,6 +243,7 @@
           s += std::string(tmp) + "\n\n";
         }
       }
+#endif
     }
 
     call.GetOutput().AnswerBuffer(s, "application/javascript");
--- a/OrthancServer/ServerContext.cpp	Mon Sep 21 13:33:50 2015 +0200
+++ b/OrthancServer/ServerContext.cpp	Mon Sep 21 14:05:06 2015 +0200
@@ -108,7 +108,9 @@
     dicomCache_(provider_, DICOM_CACHE_SIZE),
     scheduler_(Configuration::GetGlobalIntegerParameter("LimitJobs", 10)),
     lua_(*this),
+#if ORTHANC_PLUGINS_ENABLED == 1
     plugins_(NULL),
+#endif
     done_(false),
     queryRetrieveArchive_(Configuration::GetGlobalIntegerParameter("QueryRetrieveSize", 10)),
     defaultLocalAet_(Configuration::GetGlobalStringParameter("DicomAet", "ORTHANC"))
@@ -435,6 +437,7 @@
   }
 
 
+#if ORTHANC_PLUGINS_ENABLED == 1
   void ServerContext::SetPlugins(OrthancPlugins& plugins)
   {
     boost::recursive_mutex::scoped_lock lock(listenersMutex_);
@@ -460,12 +463,6 @@
   }
 
 
-  bool ServerContext::HasPlugins() const
-  {
-    return (plugins_ != NULL);
-  }
-
-
   const OrthancPlugins& ServerContext::GetPlugins() const
   {
     if (HasPlugins())
@@ -477,4 +474,16 @@
       throw OrthancException(ErrorCode_InternalError);
     }
   }
+
+#endif
+
+
+  bool ServerContext::HasPlugins() const
+  {
+#if ORTHANC_PLUGINS_ENABLED == 1
+    return (plugins_ != NULL);
+#else
+    return false;
+#endif
+  }
 }
--- a/OrthancServer/ServerContext.h	Mon Sep 21 13:33:50 2015 +0200
+++ b/OrthancServer/ServerContext.h	Mon Sep 21 14:05:06 2015 +0200
@@ -119,7 +119,11 @@
     ServerScheduler scheduler_;
 
     LuaScripting lua_;
+
+#if ORTHANC_PLUGINS_ENABLED == 1
     OrthancPlugins* plugins_;
+#endif
+
     ServerListeners listeners_;
     boost::recursive_mutex listenersMutex_;
 
@@ -242,12 +246,15 @@
      * Management of the plugins
      **/
 
+#if ORTHANC_PLUGINS_ENABLED == 1
     void SetPlugins(OrthancPlugins& plugins);
 
     void ResetPlugins();
 
+    const OrthancPlugins& GetPlugins() const;
+#endif
+
     bool HasPlugins() const;
 
-    const OrthancPlugins& GetPlugins() const;
   };
 }
--- a/OrthancServer/main.cpp	Mon Sep 21 13:33:50 2015 +0200
+++ b/OrthancServer/main.cpp	Mon Sep 21 14:05:06 2015 +0200
@@ -368,6 +368,8 @@
 }
 
 
+
+#if ORTHANC_PLUGINS_ENABLED == 1
 static void LoadPlugins(OrthancPlugins& plugins)
 {
   std::list<std::string> path;
@@ -380,6 +382,7 @@
     plugins.GetManager().RegisterPlugin(path);
   }  
 }
+#endif
 
 
 
@@ -496,6 +499,7 @@
 static bool ConfigureHttpHandler(ServerContext& context,
                                  OrthancPlugins *plugins)
 {
+#if ORTHANC_PLUGINS_ENABLED == 1
   // By order of priority, first apply the "plugins" layer, so that
   // plugins can overwrite the built-in REST API of Orthanc
   if (plugins)
@@ -503,6 +507,7 @@
     assert(context.HasPlugins());
     context.GetHttpHandler().Register(*plugins, false);
   }
+#endif
 
   // Secondly, apply the "static resources" layer
 #if ORTHANC_STANDALONE == 1
@@ -593,19 +598,23 @@
 
   LoadLuaScripts(context);
 
+#if ORTHANC_PLUGINS_ENABLED == 1
   if (plugins)
   {
     plugins->SetServerContext(context);
     context.SetPlugins(*plugins);
   }
+#endif
 
   bool restart = ConfigureHttpHandler(context, plugins);
   context.Stop();
 
+#if ORTHANC_PLUGINS_ENABLED == 1
   if (plugins)
   {
     context.ResetPlugins();
   }
+#endif
 
   return restart;
 }
--- a/Plugins/Engine/IPluginServiceProvider.h	Mon Sep 21 13:33:50 2015 +0200
+++ b/Plugins/Engine/IPluginServiceProvider.h	Mon Sep 21 14:05:06 2015 +0200
@@ -32,6 +32,8 @@
 
 #pragma once
 
+#if ORTHANC_PLUGINS_ENABLED == 1
+
 #include "../Include/orthanc/OrthancCPlugin.h"
 
 #include "SharedLibrary.h"
@@ -50,3 +52,5 @@
                                const void* parameters) = 0;
   };
 }
+
+#endif
--- a/Plugins/Engine/OrthancPluginDatabase.cpp	Mon Sep 21 13:33:50 2015 +0200
+++ b/Plugins/Engine/OrthancPluginDatabase.cpp	Mon Sep 21 14:05:06 2015 +0200
@@ -33,6 +33,11 @@
 #include "../../OrthancServer/PrecompiledHeadersServer.h"
 #include "OrthancPluginDatabase.h"
 
+#if ORTHANC_PLUGINS_ENABLED != 1
+#error The plugin support is disabled
+#endif
+
+
 #include "../../Core/OrthancException.h"
 #include "../../Core/Logging.h"
 #include "PluginsEnumerations.h"
--- a/Plugins/Engine/OrthancPluginDatabase.h	Mon Sep 21 13:33:50 2015 +0200
+++ b/Plugins/Engine/OrthancPluginDatabase.h	Mon Sep 21 14:05:06 2015 +0200
@@ -32,6 +32,8 @@
 
 #pragma once
 
+#if ORTHANC_PLUGINS_ENABLED == 1
+
 #include "../../OrthancServer/IDatabaseWrapper.h"
 #include "../Include/orthanc/OrthancCDatabasePlugin.h"
 #include "SharedLibrary.h"
@@ -238,3 +240,5 @@
     void AnswerReceived(const _OrthancPluginDatabaseAnswer& answer);
   };
 }
+
+#endif
--- a/Plugins/Engine/OrthancPlugins.cpp	Mon Sep 21 13:33:50 2015 +0200
+++ b/Plugins/Engine/OrthancPlugins.cpp	Mon Sep 21 14:05:06 2015 +0200
@@ -33,6 +33,11 @@
 #include "../../OrthancServer/PrecompiledHeadersServer.h"
 #include "OrthancPlugins.h"
 
+#if ORTHANC_PLUGINS_ENABLED != 1
+#error The plugin support is disabled
+#endif
+
+
 #include "../../Core/ChunkedBuffer.h"
 #include "../../Core/HttpServer/HttpToolbox.h"
 #include "../../Core/Logging.h"
--- a/Plugins/Engine/OrthancPlugins.h	Mon Sep 21 13:33:50 2015 +0200
+++ b/Plugins/Engine/OrthancPlugins.h	Mon Sep 21 14:05:06 2015 +0200
@@ -32,6 +32,19 @@
 
 #pragma once
 
+#if ORTHANC_PLUGINS_ENABLED != 1
+
+#include <boost/noncopyable.hpp>
+
+namespace Orthanc
+{
+  class OrthancPlugins : public boost::noncopyable
+  {
+  };
+}
+
+#else
+
 #include "../../Core/FileStorage/IStorageArea.h"
 #include "../../Core/HttpServer/IHttpHandler.h"
 #include "../../OrthancServer/IServerListener.h"
@@ -168,3 +181,5 @@
     const PluginsManager& GetManager() const;
   };
 }
+
+#endif
--- a/Plugins/Engine/PluginsEnumerations.cpp	Mon Sep 21 13:33:50 2015 +0200
+++ b/Plugins/Engine/PluginsEnumerations.cpp	Mon Sep 21 14:05:06 2015 +0200
@@ -33,6 +33,11 @@
 #include "../../OrthancServer/PrecompiledHeadersServer.h"
 #include "PluginsEnumerations.h"
 
+#if ORTHANC_PLUGINS_ENABLED != 1
+#error The plugin support is disabled
+#endif
+
+
 #include "../../Core/OrthancException.h"
 
 namespace Orthanc
--- a/Plugins/Engine/PluginsEnumerations.h	Mon Sep 21 13:33:50 2015 +0200
+++ b/Plugins/Engine/PluginsEnumerations.h	Mon Sep 21 14:05:06 2015 +0200
@@ -32,10 +32,11 @@
 
 #pragma once
 
+#if ORTHANC_PLUGINS_ENABLED == 1
+
 #include "../Include/orthanc/OrthancCPlugin.h"
 #include "../../OrthancServer/ServerEnumerations.h"
 
-
 namespace Orthanc
 {
   namespace Plugins
@@ -55,3 +56,5 @@
     FileContentType Convert(OrthancPluginContentType type);
   }
 }
+
+#endif
--- a/Plugins/Engine/PluginsManager.cpp	Mon Sep 21 13:33:50 2015 +0200
+++ b/Plugins/Engine/PluginsManager.cpp	Mon Sep 21 14:05:06 2015 +0200
@@ -33,6 +33,11 @@
 #include "../../OrthancServer/PrecompiledHeadersServer.h"
 #include "PluginsManager.h"
 
+#if ORTHANC_PLUGINS_ENABLED != 1
+#error The plugin support is disabled
+#endif
+
+
 #include "../../Core/Toolbox.h"
 #include "../../Core/HttpServer/HttpOutput.h"
 #include "../../Core/Logging.h"
--- a/Plugins/Engine/PluginsManager.h	Mon Sep 21 13:33:50 2015 +0200
+++ b/Plugins/Engine/PluginsManager.h	Mon Sep 21 14:05:06 2015 +0200
@@ -32,6 +32,8 @@
 
 #pragma once
 
+#if ORTHANC_PLUGINS_ENABLED == 1
+
 #include "SharedLibrary.h"
 #include "IPluginServiceProvider.h"
 
@@ -112,3 +114,5 @@
     const std::string& GetPluginVersion(const std::string& name) const;
   };
 }
+
+#endif
--- a/Plugins/Engine/SharedLibrary.cpp	Mon Sep 21 13:33:50 2015 +0200
+++ b/Plugins/Engine/SharedLibrary.cpp	Mon Sep 21 14:05:06 2015 +0200
@@ -33,6 +33,11 @@
 #include "../../OrthancServer/PrecompiledHeadersServer.h"
 #include "SharedLibrary.h"
 
+#if ORTHANC_PLUGINS_ENABLED != 1
+#error The plugin support is disabled
+#endif
+
+
 #include "../../Core/Logging.h"
 #include "../../Core/Toolbox.h"
 
--- a/Plugins/Engine/SharedLibrary.h	Mon Sep 21 13:33:50 2015 +0200
+++ b/Plugins/Engine/SharedLibrary.h	Mon Sep 21 14:05:06 2015 +0200
@@ -32,6 +32,8 @@
 
 #pragma once
 
+#if ORTHANC_PLUGINS_ENABLED == 1
+
 #include "../../Core/OrthancException.h"
 
 #include <boost/noncopyable.hpp>
@@ -72,3 +74,5 @@
     FunctionPointer GetFunction(const std::string& name);
   };
 }
+
+#endif