From fe75db9167f4327d2bb2353f94d84047666bb440 Mon Sep 17 00:00:00 2001 From: ancarola Date: Fri, 25 Jan 2019 22:05:15 +0100 Subject: Core channel in flatland and signal test --- engine/include/core/object.hpp | 12 ------------ engine/include/core/signal.hpp | 15 +++++++++++---- 2 files changed, 11 insertions(+), 16 deletions(-) delete mode 100644 engine/include/core/object.hpp (limited to 'engine/include/core') diff --git a/engine/include/core/object.hpp b/engine/include/core/object.hpp deleted file mode 100644 index cd5da5e..0000000 --- a/engine/include/core/object.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -namespace flat -{ - namespace core - { - struct object - { - // it exists - }; - } -} diff --git a/engine/include/core/signal.hpp b/engine/include/core/signal.hpp index 8a3d639..7d91150 100644 --- a/engine/include/core/signal.hpp +++ b/engine/include/core/signal.hpp @@ -4,7 +4,6 @@ #include #include #include -#include "object.hpp" #include "task.hpp" #include "types.hpp" #include @@ -14,6 +13,8 @@ namespace flat { + class object; + namespace core { @@ -70,8 +71,7 @@ namespace flat template static ptr create( R T::*mf, T& obj, - const std::initializer_list& filters = {}) - { + const std::initializer_list& filters = {}) { return std::make_shared(std::bind(mf, obj), filters); } @@ -118,10 +118,17 @@ namespace flat bool connect(listener* l); void disconnect(listener* l); + + listener::ptr connect(listener::callback f, const std::initializer_list& filters = {}); + + template + inline listener::ptr connect(R T::*mf, T& obj, const std::initializer_list& filters = {}) { + return connect(std::bind(mf, obj)); + } static ptr find(const std::string&); - static ptr create(const std::string& id, priority_t prior); + static ptr create(const std::string& id, priority_t prior = priority_t::none); void check_and_call(); }; -- cgit v1.2.1 From 351f83b6d331eef1fb5e1cbfa8bed25da8f96a57 Mon Sep 17 00:00:00 2001 From: ancarola Date: Fri, 25 Jan 2019 23:47:41 +0100 Subject: Template error on compile signal test --- engine/include/core/signal.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engine/include/core') diff --git a/engine/include/core/signal.hpp b/engine/include/core/signal.hpp index 7d91150..a420989 100644 --- a/engine/include/core/signal.hpp +++ b/engine/include/core/signal.hpp @@ -6,6 +6,7 @@ #include #include "task.hpp" #include "types.hpp" +#include "object.hpp" #include #include #include "priority.hpp" @@ -13,7 +14,7 @@ namespace flat { - class object; + //class object; namespace core { @@ -30,7 +31,7 @@ namespace flat template T * get() { - return dynamic_cast(data); + return reinterpret_cast(data); } void * data; @@ -123,7 +124,7 @@ namespace flat template inline listener::ptr connect(R T::*mf, T& obj, const std::initializer_list& filters = {}) { - return connect(std::bind(mf, obj)); + return connect(std::bind(mf, obj), filters); } static ptr find(const std::string&); -- cgit v1.2.1 From 81284cb0ee2ff7b3051d30f6c2d2f4536f6b3e66 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sat, 26 Jan 2019 18:36:26 +0100 Subject: Fix signal template error --- engine/include/core/signal.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'engine/include/core') diff --git a/engine/include/core/signal.hpp b/engine/include/core/signal.hpp index a420989..606d61a 100644 --- a/engine/include/core/signal.hpp +++ b/engine/include/core/signal.hpp @@ -120,11 +120,15 @@ namespace flat bool connect(listener* l); void disconnect(listener* l); - listener::ptr connect(listener::callback f, const std::initializer_list& filters = {}); + listener::ptr connect(listener::callback f, + const std::initializer_list& filters = {}); template - inline listener::ptr connect(R T::*mf, T& obj, const std::initializer_list& filters = {}) { - return connect(std::bind(mf, obj), filters); + inline listener::ptr connect(R T::*mf, T& obj, + const std::initializer_list& filters = {}) + { + using namespace std::placeholders; + return connect(std::bind(mf, obj, _1, _2), filters); } static ptr find(const std::string&); -- cgit v1.2.1