siplasplas
A library for C++ reflection and introspection
syncsink.hpp
1 #ifndef SIPLASPLAS_SIGNALS_SYNCSINK_HPP
2 #define SIPLASPLAS_SIGNALS_SYNCSINK_HPP
3 
4 #include "sink.hpp"
5 #include <siplasplas/typeerasure/function.hpp>
6 #include <siplasplas/signals/export.hpp>
7 
8 namespace cpp
9 {
10 
20 class SIPLASPLAS_SIGNALS_EXPORT SyncSink : public SignalSink
21 {
22 public:
32  template<typename Caller, typename Function>
33  SyncSink(Caller& caller, Function function) :
34  SignalSink{caller},
35  _fptr{function}
36  {}
37 
48  template<typename Caller, typename Callee, typename Function>
49  SyncSink(Caller& caller, Callee& callee, Function function) :
50  SignalSink{caller, callee},
51  _fptr{function}
52  {}
53 
63  bool pull() override;
64 
65  virtual ~SyncSink() = default;
66 
67 protected:
68  void invoke(std::vector<cpp::SimpleAny32>&& args) override;
69  bool invokeWithoutCallee() const override;
70 
71 private:
73 };
74 
75 }
76 
77 #endif // SIPLASPLAS_SIGNALS_SYNCSINK_HPP
Implements a direct connection to the destination function.
Definition: syncsink.hpp:20
Definition: canary_allocator.hpp:7
SyncSink(Caller &caller, Function function)
Creates a synchronous sink given a caller and a destination function.
Definition: syncsink.hpp:33
Interface to the signals sink API.
Definition: sink.hpp:39
SyncSink(Caller &caller, Callee &callee, Function function)
Creates a synchronous sink given a caller, a callee, and a destination function.
Definition: syncsink.hpp:49
Stores a type-erased callable of any signature and kind.
Definition: function.hpp:58
decltype(auto) invoke(Callable &&callable, const ::cpp::SimpleAny< Storages > &...args)
Invokes a callable object with the given type-erased arguments.
Definition: invoke.hpp:214