29 #ifndef SIGNALER_PATRON_ACCEPTED 30 # error "This file should not be included directly. Please use signaler{x}.h" 31 #endif // SIGNALER_PATRON_ACCEPTED 35 #ifndef DOXYGEN_SHOULD_SKIP_THIS 41 template < LIST_DECL_CLASSES >
42 class MAKE_NAME(IConnector) {
46 virtual Listener* target()
const = 0;
50 Listener* target) = 0;
53 template < LIST_DECL_CLASSES >
54 class MAKE_NAME(BasicSignaler) :
public ISignaler {
56 typedef List< MAKE_NAME(IConnector) < LIST_CLASSES >* > ConnectorList;
57 typedef ListConstIteratorSafe<
MAKE_NAME(IConnector)
63 (
const MAKE_NAME(BasicSignaler) & s) : ISignaler(s) {
66 for (
const auto& connector : _connectors) {
67 connector->target()->attachSignal__(
this);
68 _connectors.pushBack(connector->clone());
76 for (
const auto& connector : _connectors) {
77 connector->target()->detachSignal__(
this);
84 bool hasListener() {
return (!(_connectors.empty())); }
86 void detach(Listener* target) {
87 for (ConnectorIterator it =
88 _connectors.reginSafe();
89 it != _connectors.rendSafe();
91 if ((*it)->target() == target) {
93 _connectors.erase(it);
94 target->detachSignal__(
this);
101 friend class Listener;
103 void duplicateTarget(
const Listener* oldtarget, Listener* newtarget) {
104 for (
const auto& connector : _connectors)
105 if (connector->target() == oldtarget) {
106 _connectors.pushBack(connector->duplicate(newtarget));
110 void detachFromTarget(Listener* target) {
111 ConnectorIterator itprev;
113 for (ConnectorIterator it =
114 _connectors.rbeginSafe();
115 it != _connectors.rendSafe();) {
119 if ((*itprev)->target() == target) {
121 _connectors.erase(itprev);
126 ConnectorList _connectors;
129 template <
class TargetClass, LIST_DECL_CLASSES >
130 class MAKE_NAME(Connector) :
public MAKE_NAME(IConnector)< LIST_CLASSES > {
139 (TargetClass* target,
140 void (TargetClass::*action)(
const void*,
LIST_CLASSES)) {
161 (TargetClass*)target, __action);
168 INLINE
virtual Listener* target()
const {
return __target; }
171 TargetClass* __target;
172 void (TargetClass::*__action)(
const void*,
LIST_CLASSES);
177 template < LIST_DECL_CLASSES >
178 class MAKE_NAME(Signaler) :
181 BasicSignaler)<
LIST_CLASSES >::ConnectorIterator ConnectorIterator;
196 template <
class TargetClass >
197 void attach(TargetClass* target,
198 void (TargetClass::*action)(
const void*,
LIST_CLASSES)) {
202 this->_connectors.pushBack(conn);
203 target->attachSignal__(
this);
207 for (
const auto& connector : this->_connectors) {
215 #endif // DOXYGEN_SHOULD_SKIP_THIS 218 #undef LIST_DECL_CLASSES 220 #undef LIST_DECL_ARGS 222 #undef SIGNALER_PATRON_ACCEPTED
gum is the global namespace for all aGrUM entities
Generic class for manipulating lists.