| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_BASE_SIGSLOTREPEATER_H_ | |
| 6 #define CHROME_BROWSER_SYNC_NOTIFIER_BASE_SIGSLOTREPEATER_H_ | |
| 7 | |
| 8 // Repeaters are both signals and slots, which are designed as intermediate | |
| 9 // pass-throughs for signals and slots which don't know about each other (for | |
| 10 // modularity or encapsulation). This eliminates the need to declare a signal | |
| 11 // handler whose sole purpose is to fire another signal. The repeater connects | |
| 12 // to the originating signal using the 'repeat' method. When the repeated | |
| 13 // signal fires, the repeater will also fire. | |
| 14 | |
| 15 #include "talk/base/sigslot.h" | |
| 16 | |
| 17 namespace sigslot { | |
| 18 | |
| 19 template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> | |
| 20 class repeater0 : public signal0<mt_policy>, | |
| 21 public has_slots<mt_policy> { | |
| 22 public: | |
| 23 typedef signal0<mt_policy> base_type; | |
| 24 typedef repeater0<mt_policy> this_type; | |
| 25 | |
| 26 repeater0() { } | |
| 27 explicit repeater0(const this_type& s) : base_type(s) { } | |
| 28 | |
| 29 void reemit() { signal0<mt_policy>::emit(); } | |
| 30 void repeat(base_type &s) { s.connect(this, &this_type::reemit); } | |
| 31 }; | |
| 32 | |
| 33 template<class arg1_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> | |
| 34 class repeater1 : public signal1<arg1_type, mt_policy>, | |
| 35 public has_slots<mt_policy> { | |
| 36 public: | |
| 37 typedef signal1<arg1_type, mt_policy> base_type; | |
| 38 typedef repeater1<arg1_type, mt_policy> this_type; | |
| 39 | |
| 40 repeater1() { } | |
| 41 repeater1(const this_type& s) : base_type(s) { } | |
| 42 | |
| 43 void reemit(arg1_type a1) { signal1<arg1_type, mt_policy>::emit(a1); } | |
| 44 void repeat(base_type& s) { s.connect(this, &this_type::reemit); } | |
| 45 }; | |
| 46 | |
| 47 template<class arg1_type, class arg2_type, | |
| 48 class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> | |
| 49 class repeater2 : public signal2<arg1_type, arg2_type, mt_policy>, | |
| 50 public has_slots<mt_policy> { | |
| 51 public: | |
| 52 typedef signal2<arg1_type, arg2_type, mt_policy> base_type; | |
| 53 typedef repeater2<arg1_type, arg2_type, mt_policy> this_type; | |
| 54 | |
| 55 repeater2() { } | |
| 56 repeater2(const this_type& s) : base_type(s) { } | |
| 57 | |
| 58 void reemit(arg1_type a1, arg2_type a2) { | |
| 59 signal2<arg1_type, arg2_type, mt_policy>::emit(a1, a2); | |
| 60 } | |
| 61 void repeat(base_type& s) { s.connect(this, &this_type::reemit); } | |
| 62 }; | |
| 63 | |
| 64 template<class arg1_type, class arg2_type, class arg3_type, | |
| 65 class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> | |
| 66 class repeater3 : public signal3<arg1_type, arg2_type, arg3_type, mt_policy>, | |
| 67 public has_slots<mt_policy> { | |
| 68 public: | |
| 69 typedef signal3<arg1_type, arg2_type, arg3_type, mt_policy> base_type; | |
| 70 typedef repeater3<arg1_type, arg2_type, arg3_type, mt_policy> this_type; | |
| 71 | |
| 72 repeater3() { } | |
| 73 repeater3(const this_type& s) : base_type(s) { } | |
| 74 | |
| 75 void reemit(arg1_type a1, arg2_type a2, arg3_type a3) { | |
| 76 signal3<arg1_type, arg2_type, arg3_type, mt_policy>::emit(a1, a2, a3); | |
| 77 } | |
| 78 void repeat(base_type& s) { s.connect(this, &this_type::reemit); } | |
| 79 }; | |
| 80 | |
| 81 } // namespace sigslot | |
| 82 | |
| 83 #endif // CHROME_BROWSER_SYNC_NOTIFIER_BASE_SIGSLOTREPEATER_H_ | |
| OLD | NEW |