diff options
Diffstat (limited to 'ahl-binding/ahl-binding.hpp')
-rw-r--r-- | ahl-binding/ahl-binding.hpp | 34 |
1 files changed, 30 insertions, 4 deletions
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 <sstream> #include <vector> #include <map> +#include <cassert> #include "config_entry.hpp" #include "ahl-4a.hpp" @@ -37,19 +38,41 @@ extern "C" { #include <string.h> #include <ctl-config.h> - int afbBindingVdyn(afb_dynapi* handle); + int afbBindingVdyn(afb_dynapi* handle); + int ahl_api_create(void*, struct afb_dynapi*); }; +namespace ext +{ + template<class T> + typename T::iterator find(T& container, const typename T::value_type& value) + { + return std::find(std::begin(container), std::end(container), value); + } + + template<class T, class UnaryPredicate> + typename T::iterator find_if(T& container, UnaryPredicate pred) + { + return std::find_if(std::begin(container), std::end(container), pred); + } + + template<class T, class UnaryPredicate> + 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<void(afb_request*, std::string, std::string, json_object*)>; -private: +private: afb_dynapi* handle_; - afb_dynapi* apihandle_; ahl_4a_t config_; std::map<std::string, role_action> actions_; + std::vector<role_t> 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); |