diff --git a/include/Base.h b/include/Base.h new file mode 100644 index 0000000..c7efc30 --- /dev/null +++ b/include/Base.h @@ -0,0 +1,40 @@ +#pragma once + +#include + +//template< class RT, class CallableT, class... ArgTypes > +template +class Callable { + static_assert(std::is_invocable_v); + using invoke = CallableT; +public: + invoke; + //CallableT invoke = CallableT(); + //ArgTypes... args + //invoke() { /*return CallableT(args...);*/ return CallableT(RT()); } +}; + +template< class R, class Fn, class... ArgTypes > +class Cunt { + static_assert(std::is_invocable_r_v); +}; + + + + +template< class RT, class... ArgTypes> +class EventBase { +public: + //using delegate = CallableT; + using delegate = std::function; +public: + RT Invoke(ArgTypes... args); + RT operator()(ArgTypes... args); +protected: + delegate callback; + +}; + + +}; + diff --git a/include/Event.h b/include/Event.h index fef37d3..a9c25f0 100644 --- a/include/Event.h +++ b/include/Event.h @@ -29,14 +29,14 @@ public: using event_ptr = std::shared_ptr; public: void Await(Args& ... arg); - void Invoke(Args... args); + virtual void Invoke(Args... args); void operator()(Args... args); connection Connect(delegate callback); void Disconnect(connection &conn); connection operator+=(delegate callback); -private: +protected: std::vector listeners; - uint64_t listenerCounter = 0; + //uint64_t listenerCounter = 0; }; template diff --git a/include/EventConnection.h b/include/EventConnection.h index 5c74acf..f410a2d 100644 --- a/include/EventConnection.h +++ b/include/EventConnection.h @@ -21,9 +21,11 @@ public: Connection(BasicEvent *creator, delegate cb); bool Disconnect(); // Breaks the event connection, but does not destroy the instance void Invoke(Args... e); +protected: + delegate callback; private: BasicEvent * owner; - delegate callback; + //delegate callback; bool active = true; };