From 9a631c30c9c8792865ce2aa0ec06a1bb5fd16751 Mon Sep 17 00:00:00 2001 From: Loïc Collignon Date: Thu, 7 Jun 2018 15:05:53 +0200 Subject: Add some policy emulation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a very simplistic policy emulation just for demo. The real policy engine will be brought back soon. Change-Id: I6f77c8dc58ba335eabd1a1d858354a84559d9e7f Signed-off-by: Loïc Collignon --- ahl-binding/ahl-binding.hpp | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'ahl-binding/ahl-binding.hpp') diff --git a/ahl-binding/ahl-binding.hpp b/ahl-binding/ahl-binding.hpp index 34d6492..62a518e 100644 --- a/ahl-binding/ahl-binding.hpp +++ b/ahl-binding/ahl-binding.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "config_entry.hpp" #include "ahl-4a.hpp" @@ -37,19 +38,41 @@ extern "C" { #include #include - int afbBindingVdyn(afb_dynapi* handle); + int afbBindingVdyn(afb_dynapi* handle); + int ahl_api_create(void*, struct afb_dynapi*); }; +namespace ext +{ + template + typename T::iterator find(T& container, const typename T::value_type& value) + { + return std::find(std::begin(container), std::end(container), value); + } + + template + typename T::iterator find_if(T& container, UnaryPredicate pred) + { + return std::find_if(std::begin(container), std::end(container), pred); + } + + template + typename T::iterator cfind_if(T& container, UnaryPredicate pred) + { + return std::find_if(std::begin(container), std::end(container), pred); + } +} + class ahl_binding_t { using role_action = std::function; -private: +private: afb_dynapi* handle_; - afb_dynapi* apihandle_; ahl_4a_t config_; std::map actions_; + std::vector opened_roles_; explicit ahl_binding_t(); @@ -60,10 +83,13 @@ private: void volume(afb_request* req, std::string role, std::string stream, json_object* arg); void open(afb_request* req, std::string role, std::string stream, json_object* arg); + void close(afb_request* req, std::string role, std::string stream, json_object* arg); + void interrupt(afb_request* req, std::string role, std::string stream, json_object* arg); + + void policy_open(afb_request* req, const role_t& role); public: static ahl_binding_t& instance(); - int build(afb_dynapi* handle); int preinit(afb_dynapi* handle); int init(); void event(std::string name, json_object* arg); -- cgit 1.2.3-korg