简介
signal2实现了信号槽机制,即事件总线EventBus
signal
信号的模板为
template<
typename Signature, typename Combiner = optional_last_value<typename boost::function_traits<Signature>::result_type>, typename Group = int, typename GroupCompare = std::less<Group>, typename SlotFunction = boost::function<Signature>, typename ExtendedSlotFunction = typename detail::variadic_extended_signature<Signature>::function_type, typename Mutex = signals2::mutex>
class signal
信号的特例化为
template<
typename Combiner, typename Group, typename GroupCompare, typename SlotFunction, typename ExtendedSlotFunction, typename Mutex, typename R, typename ... Args>
class signal<
R (Args...), Combiner, Group, GroupCompare, SlotFunction, ExtendedSlotFunction, Mutex>
Sinagure
:定义函数返回值,参数类型,typename R, typename T1, typename T2, …, typename TN
Combiner
:默认值为optional_last_value<函数签名的返回值>
Group
:默认值为int
GroupCompare
:默认值为less
SlotFunction
:默认值为function
ExtenedSlotFunction
:默认值为typename detail::extended_signature<function_traits::arity, Signature>::function_type
Mutex
:默认值为mutex
signal_impl
connection_list_type:其类型为grouped_list<Group, GroupCompare, connection_body_type>,而connection_body_type类型为shared_ptr<connection_body<group_key_type, slot_type, Mutex>>
SlotType:为slot<R (Args…), SlotFunction>
group_key_type类型为
enum slot_meta_group {front_ungrouped_slots, grouped_slots, back_ungrouped_slots};
template<typename Group>
struct group_key
{typedef std::pair<enum slot_meta_group, boost::optional<Group>> type;
};
slot
slot对于普通函数的特例化为slot<R (Args…), SlotFunction>,其结构为