File indexing completed on 2021-02-14 13:29:20
0001 #ifndef FWCore_ServiceRegistry_Signal_h
0002 #define FWCore_ServiceRegistry_Signal_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #include <vector>
0026 #include <functional>
0027
0028
0029
0030
0031
0032 namespace edm {
0033 namespace signalslot {
0034 template <typename T>
0035 class Signal {
0036 public:
0037 typedef std::function<T> slot_type;
0038 typedef std::vector<slot_type> slot_list_type;
0039
0040 Signal() = default;
0041 ~Signal() = default;
0042 Signal(Signal&&) = default;
0043 Signal(const Signal&) = delete;
0044 Signal& operator=(const Signal&) = delete;
0045
0046
0047 template <typename... Args>
0048 void emit(Args&&... args) const {
0049 for (auto& slot : m_slots) {
0050 slot(std::forward<Args>(args)...);
0051 }
0052 }
0053
0054 template <typename... Args>
0055 void operator()(Args&&... args) const {
0056 emit(std::forward<Args>(args)...);
0057 }
0058
0059 slot_list_type const& slots() const { return m_slots; }
0060
0061
0062
0063 template <typename U>
0064 void connect(U iFunc) {
0065 m_slots.push_back(std::function<T>(iFunc));
0066 }
0067
0068 template <typename U>
0069 void connect_front(U iFunc) {
0070 m_slots.insert(m_slots.begin(), std::function<T>(iFunc));
0071 }
0072
0073 private:
0074
0075 slot_list_type m_slots;
0076 };
0077 }
0078 }
0079
0080 #endif