diff options
author | Nao Pross <naopross@thearcway.org> | 2019-01-26 23:32:43 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2019-01-26 23:32:43 +0100 |
commit | bb6beb5feadfd3ac252fb0bd0b533ceda960c7e7 (patch) | |
tree | 614cada7598eb7219fb3bcf1a1bdf5052a3d9457 /engine/include/core | |
parent | Restore old files to ease merge (flatland, signal, window) (diff) | |
parent | Testing signal (diff) | |
download | flatland-bb6beb5feadfd3ac252fb0bd0b533ceda960c7e7.tar.gz flatland-bb6beb5feadfd3ac252fb0bd0b533ceda960c7e7.zip |
Merge remote-tracking branch 'raffa/master'
Diffstat (limited to 'engine/include/core')
-rw-r--r-- | engine/include/core/object.hpp | 12 | ||||
-rw-r--r-- | engine/include/core/signal.hpp | 22 |
2 files changed, 17 insertions, 17 deletions
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..606d61a 100644 --- a/engine/include/core/signal.hpp +++ b/engine/include/core/signal.hpp @@ -4,9 +4,9 @@ #include <list> #include <set> #include <initializer_list> -#include "object.hpp" #include "task.hpp" #include "types.hpp" +#include "object.hpp" #include <functional> #include <memory> #include "priority.hpp" @@ -14,6 +14,8 @@ namespace flat { + //class object; + namespace core { @@ -29,7 +31,7 @@ namespace flat template<class T> T * get() { - return dynamic_cast<T>(data); + return reinterpret_cast<T*>(data); } void * data; @@ -70,8 +72,7 @@ namespace flat template<typename R, typename T> static ptr create( R T::*mf, T& obj, - const std::initializer_list<std::string>& filters = {}) - { + const std::initializer_list<std::string>& filters = {}) { return std::make_shared<listener>(std::bind(mf, obj), filters); } @@ -118,10 +119,21 @@ namespace flat bool connect(listener* l); void disconnect(listener* l); + + listener::ptr connect(listener::callback f, + const std::initializer_list<std::string>& filters = {}); + + template<typename R, typename T> + inline listener::ptr connect(R T::*mf, T& obj, + const std::initializer_list<std::string>& filters = {}) + { + using namespace std::placeholders; + return connect(std::bind(mf, obj, _1, _2), filters); + } 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(); }; |