diff Core/RestApi/RestApiHierarchy.h @ 973:ab6475e33473 plugins

integration mainline->plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 30 Jun 2014 14:08:51 +0200
parents 2047e6f033bd
children 83622b0f544c
line wrap: on
line diff
--- a/Core/RestApi/RestApiHierarchy.h	Mon Jun 30 13:36:01 2014 +0200
+++ b/Core/RestApi/RestApiHierarchy.h	Mon Jun 30 14:08:51 2014 +0200
@@ -34,48 +34,55 @@
 
 #include "RestApi.h"
 
+#include "../OrthancException.h"
+
 #include <list>
+#include <set>
 
 namespace Orthanc
 {
   class RestApiHierarchy
   {
   private:
-    struct Handlers
+    class Handlers
     {
-      typedef std::list<RestApi::GetHandler>  GetHandlers;
-      typedef std::list<RestApi::PostHandler>  PostHandlers;
-      typedef std::list<RestApi::PutHandler>  PutHandlers;
-      typedef std::list<RestApi::DeleteHandler>  DeleteHandlers;
+    private:
+      RestApi::GetHandler  getHandler_;
+      RestApi::PostHandler  postHandler_;
+      RestApi::PutHandler  putHandler_;
+      RestApi::DeleteHandler  deleteHandler_;
 
-      GetHandlers  getHandlers_;
-      PostHandlers  postHandlers_;
-      PutHandlers  putHandlers_;
-      DeleteHandlers  deleteHandlers_;
+    public:
+      Handlers();
+
+      bool HasHandler(HttpMethod method) const;
 
-      bool HasGet() const
-      {
-        return getHandlers_.size() > 0;
-      }
+      RestApi::GetHandler GetGetHandler() const;
+
+      RestApi::PutHandler GetPutHandler() const;
+
+      RestApi::PostHandler GetPostHandler() const;
+
+      RestApi::DeleteHandler GetDeleteHandler() const;
 
       void Register(RestApi::GetHandler handler)
       {
-        getHandlers_.push_back(handler);
+        getHandler_ = handler;
       }
 
       void Register(RestApi::PutHandler handler)
       {
-        putHandlers_.push_back(handler);
+        putHandler_ = handler;
       }
 
       void Register(RestApi::PostHandler handler)
       {
-        postHandlers_.push_back(handler);
+        postHandler_ = handler;
       }
 
       void Register(RestApi::DeleteHandler handler)
       {
-        deleteHandlers_.push_back(handler);
+        deleteHandler_ = handler;
       }
 
       bool IsEmpty() const;