27 #define MA_SLOT_CLASS \ 29 MAConnectionSet SignalConnections; \ 32 #define MA_SIGNAL_CONNECT(_signal, _slot) \ 33 SignalConnections.Add(_signal->Register(*this, &_slot)); 35 #define MAX_SIGNAL_ARGS 4 37 #include "3rdparty/FastDelegate.h" 39 #include <boost/noncopyable.hpp> 40 #include <boost/preprocessor/iteration.hpp> 41 #include <boost/preprocessor/repetition.hpp> 42 #include <boost/preprocessor/cat.hpp> 43 #include <boost/preprocessor/if.hpp> 44 #include <boost/preprocessor/comparison.hpp> 45 #include <boost/preprocessor/empty.hpp> 46 #include <boost/preprocessor/arithmetic.hpp> 47 #include <boost/preprocessor/logical.hpp> 48 #include <boost/preprocessor/comma_if.hpp> 56 MASignalNode(T
const& data, MASignalNode<T>* next) : next(next), refCount(0), data(data) { }
57 MASignalNode<T>* next;
66 class MASignalNullType{};
71 MAConnection() : m_node(0) { }
72 template<
typename DelegateType>
73 explicit MAConnection(MASignalNode<DelegateType>* m_node) :
74 m_node(reinterpret_cast<AnyNodeType*>(m_node))
82 MAConnection(MAConnection
const& c) : m_node(c.m_node && c.m_node->refCount > 0 ? c.m_node : 0)
90 MAConnection& operator=(MAConnection
const& c)
92 if(&c ==
this)
return *
this;
96 if(m_node->refCount > 0)
100 else if(m_node->refCount < 0)
103 if(m_node->refCount == 0)
110 m_node = c.m_node && c.m_node->refCount > 0 ? c.m_node : 0;
123 if(m_node->refCount > 0)
127 else if(m_node->refCount < 0)
130 if(m_node->refCount == 0)
140 return m_node !=
nullptr && m_node->refCount > 0;
143 typedef MASignalNode<MASignalNullType> AnyNodeType;
147 class MAConnectionSet
150 void Add(MAConnection
const& c)
152 m_connections.push_back(c);
157 m_connections.clear();
161 typedef std::vector<MAConnection> ConnectionContainer;
162 ConnectionContainer m_connections;
165 template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(MAX_SIGNAL_ARGS,
typename T, MASignalNullType)>
168 class AutoTracked :
private MAConnectionSet
171 template<BOOST_PP_ENUM_PARAMS(MAX_SIGNAL_ARGS,
typename T)>
172 friend class MASignal;
176 #define BOOST_PP_ITERATION_LIMITS (0, BOOST_PP_SUB(MAX_SIGNAL_ARGS,1)) 177 #define BOOST_PP_FILENAME_1 "core/MASignalImpl.hpp" 178 #include BOOST_PP_ITERATE() 179 #undef BOOST_PP_ITERATION_LIMITS 180 #undef BOOST_PP_FILENAME_1 181 #undef nullptrTYPE_MACRO 186 inline void swap<MAConnection>(MAConnection & left, MAConnection & right)
188 std::swap(left.m_node, right.m_node);