fix doc example typo
[boost.git] / boost / signals2 / signal.hpp
blob3c6d313fadd337ea1bdd81dcddb847f9f6216bc3
1 /*
2 A thread-safe version of Boost.Signals.
4 Author: Frank Mori Hess <fmhess@users.sourceforge.net>
5 Begin: 2007-01-23
6 */
7 // Copyright Frank Mori Hess 2007-2008
8 // Use, modification and
9 // distribution is subject to the Boost Software License, Version
10 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
13 // For more information, see http://www.boost.org
15 #ifndef BOOST_SIGNALS2_SIGNAL_HPP
16 #define BOOST_SIGNALS2_SIGNAL_HPP
18 #include <algorithm>
19 #include <boost/assert.hpp>
20 #include <boost/config.hpp>
21 #include <boost/function.hpp>
22 #include <boost/preprocessor/arithmetic.hpp>
23 #include <boost/preprocessor/cat.hpp>
24 #include <boost/preprocessor/iteration.hpp>
25 #include <boost/preprocessor/repetition.hpp>
26 #include <boost/shared_ptr.hpp>
27 #include <boost/signals2/detail/unique_lock.hpp>
28 #include <boost/signals2/optional_last_value.hpp>
29 #include <boost/signals2/detail/result_type_wrapper.hpp>
30 #include <boost/signals2/detail/signals_common.hpp>
31 #include <boost/signals2/detail/signals_common_macros.hpp>
32 #include <boost/signals2/detail/slot_groups.hpp>
33 #include <boost/signals2/detail/slot_call_iterator.hpp>
34 #include <boost/signals2/mutex.hpp>
35 #include <boost/signals2/connection.hpp>
36 #include <boost/signals2/slot.hpp>
37 #include <boost/throw_exception.hpp>
38 #include <boost/type_traits.hpp>
39 #include <functional>
41 namespace boost
43 namespace signals2
45 namespace detail
47 template<typename ResultSlot, typename SlotIn, typename SlotFunction>
48 ResultSlot replace_slot_function(const SlotIn &slot_in, const SlotFunction &fun)
50 ResultSlot slot(fun);
51 slot_base::tracked_container_type tracked_objects = slot_in.tracked_objects();
52 slot_base::tracked_container_type::const_iterator it;
53 for(it = tracked_objects.begin(); it != tracked_objects.end(); ++it)
55 slot.track(*it);
57 return slot;
59 } // namespace detail
60 } // namespace signals2
61 } // namespace boost
64 #define BOOST_PP_ITERATION_LIMITS (0, BOOST_SIGNALS2_MAX_ARGS)
65 #define BOOST_PP_FILENAME_1 <boost/signals2/detail/signal_template.hpp>
66 #include BOOST_PP_ITERATE()
68 namespace boost
70 namespace signals2
72 template<typename Signature,
73 typename Combiner = optional_last_value<typename boost::function_traits<Signature>::result_type>,
74 typename Group = int,
75 typename GroupCompare = std::less<Group>,
76 typename SlotFunction = function<Signature>,
77 typename ExtendedSlotFunction = typename detail::extended_signature<function_traits<Signature>::arity, Signature>::function_type,
78 typename Mutex = mutex >
79 class signal: public detail::signalN<function_traits<Signature>::arity,
80 Signature, Combiner, Group, GroupCompare, SlotFunction, ExtendedSlotFunction, Mutex>::type
82 private:
83 typedef typename detail::signalN<boost::function_traits<Signature>::arity,
84 Signature, Combiner, Group, GroupCompare, SlotFunction, ExtendedSlotFunction, Mutex>::type base_type;
85 public:
86 typedef Signature signature_type;
87 signal(const Combiner &combiner = Combiner(), const GroupCompare &group_compare = GroupCompare()):
88 base_type(combiner, group_compare)
94 #endif // BOOST_SIGNALS2_SIGNAL_HPP