#pragma once #include #include #include using namespace boost::signals2; // Base adapter interface exposing a typed callback signal and name. template class AdapterBase { using cbk_ret_type_t_ = typename CallbackRetTypeTag::type; // If return type is not void we combine all callback invocation results. class CollectAllCombiner_ { public: using result_type = std::conditional_t, std::vector, std::false_type>; template result_type operator()(InputIterator first, InputIterator last) const { result_type results; if constexpr (!std::is_same_v) { for (; first != last; ++first) { results.push_back(*first); } } return results; } }; public: // Use combiner if return type is not void using signature_t = std::conditional_t, void(const InType &, CbkAargs &&...), cbk_ret_type_t_(const InType &, CbkAargs &&...)>; using callback_type_t = std::conditional_t, signal, signal>; AdapterBase(const std::string &name) : mc_name_(name) {} virtual callback_type_t &callback() const = 0; inline const auto &name() const { return mc_name_; } private: const std::string mc_name_; };