Update of /cvsroot/boost-sandbox/boost-sandbox/boost/signals/detail In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17176/detail Added Files: epilogue.hpp named_slot_container.hpp prologue.hpp slot_tracking_base.hpp type_selection.hpp unnamed_slot_container.hpp Log Message: --- NEW FILE: epilogue.hpp --- // Boost.Signals library // Copyright Timmo Stange 2007. Use, modification and // distribution is subject to the Boost Software License, Version // 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // For more information, see http://www.boost.org #undef BOOST_SIGNALS_TEMPLATE_PARMS #undef BOOST_SIGNALS_TEMPLATE_ARGS #undef BOOST_SIGNALS_PARMS #undef BOOST_SIGNALS_ARGS #undef BOOST_SIGNALS_BOUND_ARGS #undef BOOST_SIGNALS_SEMICOLON #undef BOOST_SIGNALS_ARG_AS_MEMBER #undef BOOST_SIGNALS_ARGS_AS_MEMBERS #undef BOOST_SIGNALS_COPY_PARMS #undef BOOST_SIGNALS_INIT_ARG #undef BOOST_SIGNALS_INIT_ARGS #undef BOOST_SIGNALS_ARG_TYPE #undef BOOST_SIGNALS_ARG_TYPES #undef BOOST_SIGNALS_TRAITS_ARG_TYPE #undef BOOST_SIGNALS_TRAITS_ARG_TYPES #undef BOOST_SIGNAL_FUNCTION_N_HEADER #undef BOOST_SIGNALS_COMMA_IF_NONZERO_ARGS #undef BOOST_SIGNALS_STANDARD_ARG_TYPES #undef BOOST_SIGNALS_SIGNAL #undef BOOST_SIGNALS_FUNCTION #undef BOOST_SIGNALS_ARGS_STRUCT #undef BOOST_SIGNALS_CALL_BOUND #undef BOOST_SIGNALS_SELECT_SLOT_FUNCTION #undef BOOST_SIGNALS_ARGS_STRUCT_INST --- NEW FILE: unnamed_slot_container.hpp --- // Boost.Signals library // Copyright Timmo Stange 2007. // Copyright Douglas Gregor 2001-2004. Use, modification and // distribution is subject to the Boost Software License, Version // 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // For more information, see http://www.boost.org #ifndef BOOST_SIGNALS_DETAIL_UNNAMED_SLOT_CONTAINER_HEADER #define BOOST_SIGNALS_DETAIL_UNNAMED_SLOT_CONTAINER_HEADER #include <boost/signals/detail/signals_common.hpp> #include <boost/signals/detail/connect_position.hpp> #include <list> #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX #endif namespace boost { namespace BOOST_SIGNALS_NAMESPACE { namespace detail { // unnamed_slot_container class template. // Manages slots for non-grouping signals. template<typename T, typename Allocator> class unnamed_slot_container { #ifdef BOOST_NO_STD_ALLOCATOR typedef std::list<T> list_type; #else typedef std::list<T, typename Allocator::template rebind<T>::other> list_type; #endif public: typedef typename list_type::iterator iterator; // Constructor (group comparison value is ignored). unnamed_slot_container(const no_name_compare&) { } // Insert a value. iterator insert(const T& v, connect_position at) { if(at == at_back) { return list_.insert(v, list_.end()); } else { return list_.insert(v, list_.begin()); } } // Erase a value iterator erase(iterator pos) { return list_.erase(pos); } // Begin and end. iterator begin() { return list_.begin(); } iterator end() { return list_.end(); } // Retrieve size. std::size_t size() const { return std::count_if(list_.begin(), list_.end(), is_connected()); } // Check for emptiness. bool empty() const { return size() == 0; } private: list_type list_; }; } // end namespace detail } // end namespace BOOST_SIGNALS_NAMESPACE } // end namespace boost #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_SUFFIX #endif #endif // BOOST_SIGNALS_DETAIL_UNNAMED_SLOT_CONTAINER_HEADER --- NEW FILE: slot_tracking_base.hpp --- // Boost.Signals library // Copyright Timmo Stange 2007. // Copyright Douglas Gregor 2001-2004. Use, modification and // distribution is subject to the Boost Software License, Version // 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // For more information, see http://www.boost.org #ifndef BOOST_SIGNALS_DETAIL_SLOT_TRACKING_BASE_HEADER #define BOOST_SIGNALS_DETAIL_SLOT_TRACKING_BASE_HEADER #include <boost/signals/detail/config.hpp> #include <boost/signals/detail/slot_connection_interface.hpp> #include <boost/signals/trackable.hpp> #include <boost/bind.hpp> #include <boost/visit_each.hpp> #include <boost/smart_ptr.hpp> #include <vector> #include <algorithm> #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX #endif namespace boost { namespace BOOST_SIGNALS_NAMESPACE { namespace detail { class BOOST_SIGNALS_DECL slot_tracking_base : public slot_connection_interface, public enable_shared_from_this<slot_tracking_base> { public: slot_tracking_base(set_function_type s, get_function_type g) : slot_connection_interface(s, g) { } ~slot_tracking_base() { stop_tracking(); } template<class T> void setup_tracking(const T& t) const { } void start_tracking() const { } void stop_tracking() const { } // Check the lifetime of tracked objects. bool check_tracked_objects() const { return true; } protected: typedef std::vector<void*> tracked_pointer_container; mutable tracked_pointer_container tracked_pointers_; }; class BOOST_SIGNALS_DECL dual_slot_tracking_base : public slot_tracking_base { public: dual_slot_tracking_base(set_function_type s, get_function_type g) : slot_tracking_base(s, g) { } ~dual_slot_tracking_base() { stop_tracking(); } // Enumerate and store the trackable-derived objects in a target function. template<class T> void setup_tracking(const T& t) const { trackable_objects_visitor do_bind(trackable_objects_); visit_each(do_bind, t); this->slot_tracking_base::setup_tracking(t); } // Establish a connection to the tracked objects. void start_tracking() const { std::for_each(trackable_objects_.begin(), trackable_objects_.end(), bind(&trackable::add_slot, _1, const_cast<dual_slot_tracking_base*>(this))); this->slot_tracking_base::start_tracking(); } // Disconnect this slot from all tracked objects. void stop_tracking() const { std::for_each(trackable_objects_.begin(), trackable_objects_.end(), bind(&trackable::remove_slot, _1, this)); trackable_objects_.clear(); this->slot_tracking_base::stop_tracking(); } // Check the lifetime of tracked objects. bool check_tracked_objects() const { // This is always given with the trackable base approach, so we just // forward the call to the base. return this->slot_tracking_base::check_tracked_objects(); } protected: typedef std::vector<const trackable*> trackable_objects_container; mutable trackable_objects_container trackable_objects_; }; } // end namespace detail } // end namespace BOOST_SIGNALS_NAMESPACE } // end namespace boost #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_SUFFIX #endif #endif // BOOST_SIGNALS_DETAIL_SLOT_TRACKING_BASE_HEADER --- NEW FILE: named_slot_container.hpp --- // Boost.Signals library // Copyright Timmo Stange 2007. // Copyright Douglas Gregor 2001-2004. Use, modification and // distribution is subject to the Boost Software License, Version // 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // For more information, see http://www.boost.org #ifndef BOOST_SIGNALS_DETAIL_NAMED_SLOT_CONTAINER_HEADER #define BOOST_SIGNALS_DETAIL_NAMED_SLOT_CONTAINER_HEADER #include <boost/signals/detail/signals_common.hpp> #include <boost/signals/detail/connect_position.hpp> #include <boost/iterator/iterator_facade.hpp> #include <list> #include <map> #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX #endif namespace boost { namespace BOOST_SIGNALS_NAMESPACE { namespace detail { // named_slot_container class template. // Manages slots for grouping signals. template<typename T, typename Group, typename GroupCompare, typename Allocator> class named_slot_container { // The internal map needs to differentiate between named and // unnamed slots. Unnamed slots are either positioned at the // front or back of the map. struct key { enum group_type { type_front, type_group, type_back }; // Construct a key from a group name. This is for a named slot. key(const Group& group) : type_(type_group), group_(group) { } // Construct a key from a position. This is for an unnamed slot. key(connect_position at) : group_() { if(at == at_back) type_ = type_back; else type_ = type_front; } group_type type_; Group group_; }; // The comparison operation for internal keys struct key_compare { // Construct from a group comparison operator. key_compare(const GroupCompare& group_compare) : group_compare_(group_compare) { } bool operator()(const key& lhs, const key& rhs) const { // Both keys are for named slots. Compare the names. if(lhs.type_ == key::type_group && rhs.type_ == key::type_group) return group_compare_(lhs.group_, rhs.group_); // If lhs is a key for an unnamed back slot, it belongs to the end // of the map. If the other key is for an unnamed front slot, it // belongs behind it. if(lhs.type_ == key::type_back || rhs.type_ == key::type_front) return false; // If the rhs key is for an unnamed back slot, the lhs key belongs // in front of it. if(rhs.type_ == key::type_back) return true; } GroupCompare group_compare_; }; // Internal storage is a map of lists of slots. #ifdef BOOST_NO_STD_ALLOCATOR typedef std::list<T> list_type; typedef std::map<key, list_type, key_compare> map_type; #else typedef std::list<T, typename Allocator::template rebind<T>::other> list_type; typedef std::map<key, list_type, key_compare, typename Allocator::template rebind<list_type>::other> map_type; #endif public: // The named_slot_container iterator class. class iterator : public iterator_facade<iterator, T, forward_traversal_tag> { public: // Copy construction. iterator(const iterator& other) : map_pos_(other.map_pos_), list_pos_(other.list_pos_), map_end_(other.map_end_) { } // Copy assignment. iterator& operator=(const iterator& other) { map_pos_ = other.map_pos_; list_pos_ = other.list_pos_; map_end_ = other.map_end_; return *this; } private: friend class iterator_core_access; friend named_slot_container; // Construct from a map iterator a list iterator and the map's end. iterator(const typename map_type::iterator map_it, const typename list_type::iterator list_it, const typename map_type::iterator map_end) : map_pos_(map_it), list_pos_(list_it), map_end_(map_end) { } T& dereference() const { return *list_pos_; } void increment() { if(++list_pos_ == map_pos_->second.end()) { ++map_pos_; if(map_pos_ != map_end_) list_pos_ = map_pos_->second.begin(); } } bool equal(const iterator& other) const { if(map_pos_ != other.map_pos_) return false; if(map_pos_ == map_end_) return true; return list_pos_ == other.list_pos_; } typename map_type::iterator map_pos_; typename map_type::const_iterator map_end_; typename list_type::iterator list_pos_; }; // Constructor (group comparison value is ignored). named_slot_container(const GroupCompare& comp) : map_(key_compare(comp)) { } // Insert a value. iterator insert(const T& v, connect_position at) { return do_insert(v, key(at), at); } // Insert a value with a given group name. iterator insert(const T& v, const Group& group, connect_position at) { return do_insert(v, key(group), at); } // Erase a single entry. iterator erase(iterator pos) { iterator tmp = pos++; tmp.map_pos_->second.erase(tmp.list_pos_); if(tmp.map_pos_->second.empty()) map_.erase(tmp.map_pos_->first); return pos; } // Begin and end. iterator begin() { if(!map_.empty()) return iterator(map_.begin(), map_.begin()->second.begin(), map_.end()); return iterator(map_.begin(), typename list_type::iterator(), map_.end()); } iterator end() { return iterator(map_.end(), typename list_type::iterator(), map_.end()); } // Retrieve size. std::size_t size() const { return count_if(begin(), end(), is_connected()); } // Check for emptiness. bool empty() const { return size() == 0; } // Get an iterator pair for a specific group range. std::pair<iterator, iterator> group_range(const Group& group) { typename map_type::iterator map_it = map_.find(key(group)); if(map_it == map_.end()) { return std::make_pair(end(), end()); } typename map_type::iterator next = map_it; ++next; if(next == map_.end()) { return std::make_pair( iterator(map_it, map_it->second.begin(), map_.end()), end()); } return std::make_pair( iterator(map_it, map_it->second.begin(), map_.end()), iterator(next, next->second.begin(), map_.end())); } private: iterator do_insert(const T& v, const key& k, connect_position at) { typename map_type::iterator map_it = map_.find(k); if(map_it == map_.end()) { // Insert an empty list for the given key into the map. map_it = map_.insert(k, list_type()); } // Insert the value into the appropriate list. typename list_type::iterator list_it; if(at == at_back) { list_it = map_it->second.insert(v, map_it->second.end()); } else { list_it = map_it->second.insert(v, map_it->second.begin()); } return iterator(map_it, list_it, map_.end()); } map_type map_; }; } // end namespace detail } // end namespace BOOST_SIGNALS_NAMESPACE } // end namespace boost #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_SUFFIX #endif #endif // BOOST_SIGNALS_DETAIL_NAMED_SLOT_CONTAINER_HEADER --- NEW FILE: type_selection.hpp --- // Boost.Signals library // Copyright Timmo Stange 2007. // Copyright Douglas Gregor 2001-2004. Use, modification and // distribution is subject to the Boost Software License, Version // 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // For more information, see http://www.boost.org #ifndef BOOST_SIGNALS_DETAIL_TYPE_SELECTION_HEADER #define BOOST_SIGNALS_DETAIL_TYPE_SELECTION_HEADER #include <boost/signals/detail/signals_common.hpp> #include <boost/signals/detail/signal_base.hpp> #include <boost/mpl/if.hpp> #include <boost/type_traits/is_same.hpp> #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX #endif #ifndef BOOST_SIGNALS_DEFAULT_ALLOCATOR // NOTE: We should check if a standard allocator is available here. # define BOOST_SIGNALS_DEFAULT_ALLOCATOR std::allocator<int> #endif namespace boost { namespace BOOST_SIGNALS_NAMESPACE { // use_default type. // Used to leave signal template arguments to their default value while // specializing arguments that are further behind in the list of template // parameters. struct use_default; namespace detail { // select_group template structure. // Determine the appropriate group type from the Group template argument. template<typename Group> struct select_group { typedef Group type; }; template<> struct select_group<use_default> { typedef int type; }; // select_group_compare template structure. // Determine the appropriate group compare type from the Group and GroupCompare // template arguments. template<typename Group, typename GroupCompare> struct select_group_compare { typedef typename mpl::if_< is_same<Group, no_name>, no_name_compare, typename mpl::if_< is_same<GroupCompare, use_default>, std::less<typename select_group<Group>::type>, GroupCompare >::type >::type type; }; // select_combiner template structure. // Determine the appropriate combiner type from the Combiner and R template // arguments. template<typename Combiner, typename R> struct select_combiner { typedef typename mpl::if_< is_same<Combiner, use_default>, last_value<R>, Combiner >::type type; }; // select_threading_model template structure. // Determine the appropriate threading model type from the ThreadingModel // template argument. template<typename ThreadingModel> struct select_threading_model { typedef ThreadingModel type; }; template<> struct select_threading_model<use_default> { typedef single_threaded type; }; // select_allocator template structure. // Determine the appropriate allocator type from the Allocator // template argument. template<typename Allocator> struct select_allocator { typedef Allocator type; }; template<> struct select_allocator<use_default> { typedef BOOST_SIGNALS_DEFAULT_ALLOCATOR type; }; // select_signal_base template structure. // Determine the appropriate signal base class from the signal // template arguments. template<typename Combiner, typename R, typename Group, typename GroupCompare, typename ThreadingModel, typename Allocator> struct select_signal_base { typedef signal_base< typename select_combiner<Combiner, R>::type, typename select_group<Group>::type, typename select_group_compare<Group, GroupCompare>::type, typename select_threading_model<ThreadingModel>::type, typename select_allocator<Allocator>::type > type; }; // select_result_type template structure. // Determine the result type of a slot call. template<typename R> struct select_result_type { typedef R type; }; template<> struct select_result_type<void> { typedef unusable type; }; } // end namespace detail } // end namespace BOOST_SIGNALS_NAMESPACE } // end namespace boost #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_SUFFIX #endif #endif // BOOST_SIGNALS_DETAIL_TYPE_SELECTION_HEADER --- NEW FILE: prologue.hpp --- // Boost.Signals library // Copyright Timmo Stange 2007. Use, modification and // distribution is subject to the Boost Software License, Version // 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // For more information, see http://www.boost.org #ifndef BOOST_SIGNALS_DETAIL_PROLOGUE_HEADERS_INCLUDED #define BOOST_SIGNALS_DETAIL_PROLOGUE_HEADERS_INCLUDED # include <boost/config.hpp> # include <boost/signals/connection.hpp> # include <boost/utility.hpp> # include <boost/ref.hpp> # include <boost/signals/slot.hpp> # include <boost/last_value.hpp> # include <boost/signals/detail/type_selection.hpp> # include <boost/signals/detail/signal_base.hpp> # include <boost/signals/detail/slot_call_iterator.hpp> # include <boost/mpl/bool.hpp> # include <boost/type_traits/is_convertible.hpp> # include <boost/preprocessor/comma_if.hpp> # include <boost/preprocessor/enum.hpp> # include <boost/preprocessor/enum_params.hpp> # include <boost/preprocessor/repetition/enum_binary_params.hpp> # include <boost/preprocessor/punctuation/paren.hpp> # include <boost/preprocessor/repeat.hpp> # include <boost/preprocessor/cat.hpp> # include <boost/preprocessor/inc.hpp> # include <boost/preprocessor/empty.hpp> # include <cassert> # include <functional> # include <memory> #endif // ndef BOOST_SIGNALS_DETAIL_PROLOGUE_HEADERS_INCLUDED // Template parameter list ("typename T0, typename T1, ...") #define BOOST_SIGNALS_TEMPLATE_PARMS \ BOOST_PP_ENUM_PARAMS(BOOST_SIGNALS_NUM_ARGS, typename T) // Template argument list ("T0, T1, T2, ...") #define BOOST_SIGNALS_TEMPLATE_ARGS \ BOOST_PP_ENUM_PARAMS(BOOST_SIGNALS_NUM_ARGS, T) // Template argument variable name pairs list ("T0 a0, T1 a1, ...") #define BOOST_SIGNALS_PARMS \ BOOST_PP_ENUM_BINARY_PARAMS(BOOST_SIGNALS_NUM_ARGS, T, a) // Variable names list ("a0, a1, a2, ...") #define BOOST_SIGNALS_ARGS \ BOOST_PP_ENUM_PARAMS(BOOST_SIGNALS_NUM_ARGS, a) // Bound arguments accessor list ("args->a0, args->a1, ...") #define BOOST_SIGNALS_BOUND_ARGS \ BOOST_PP_ENUM_PARAMS(BOOST_SIGNALS_NUM_ARGS, args->a) #define BOOST_SIGNALS_SEMICOLON ; // Bound arguments as member declarations ("T0 a0; T1 a1; ...") #define BOOST_SIGNALS_ARG_AS_MEMBER(z, n, d) \ BOOST_PP_CAT(T,n) BOOST_PP_CAT(a,n); #define BOOST_SIGNALS_ARGS_AS_MEMBERS \ BOOST_PP_REPEAT(BOOST_SIGNALS_NUM_ARGS,BOOST_SIGNALS_ARG_AS_MEMBER,BOOST_PP_EMPTY) // Bound arguments as constructor parameter list ("T0 ia0, T1 ia1, ...") #define BOOST_SIGNALS_COPY_PARMS \ BOOST_PP_ENUM_BINARY_PARAMS(BOOST_SIGNALS_NUM_ARGS, T, ia) // Bound arguments as initializer list ("a0(ia0), a1(ia1), a2(ia2)...") #if BOOST_SIGNALS_NUM_ARGS > 0 # define BOOST_SIGNALS_INIT_ARG(z, n, d) \ BOOST_PP_COMMA_IF(n) BOOST_PP_CAT(a,n) ( BOOST_PP_CAT(ia,n) ) # define BOOST_SIGNALS_INIT_ARGS \ : BOOST_PP_REPEAT(BOOST_SIGNALS_NUM_ARGS, BOOST_SIGNALS_INIT_ARG, BOOST_PP_EMPTY) #else # define BOOST_SIGNALS_INIT_ARGS #endif // Argument type typedefs ("typedef T0 arg1_type; typedef T1 arg2_type; ...") #define BOOST_SIGNALS_ARG_TYPE(z, n, d) \ typedef BOOST_PP_CAT(T,n) BOOST_PP_CAT(BOOST_PP_CAT(arg, BOOST_PP_INC(n)),_type); #define BOOST_SIGNALS_ARG_TYPES \ BOOST_PP_REPEAT(BOOST_SIGNALS_NUM_ARGS, BOOST_SIGNALS_ARG_TYPE, BOOST_PP_EMPTY) // Function traits member typedefs as template parameters list // (typename traits::arg1_type, typename traits::arg_type, ...) #define BOOST_SIGNALS_TRAITS_ARG_TYPE(z, n, d) \ BOOST_PP_COMMA_IF(n) BOOST_PP_CAT(BOOST_PP_CAT(typename traits::arg, BOOST_PP_INC(n)),_type) #define BOOST_SIGNALS_TRAITS_ARG_TYPES \ BOOST_PP_REPEAT(BOOST_SIGNALS_NUM_ARGS, BOOST_SIGNALS_TRAITS_ARG_TYPE, BOOST_PP_EMPTY) // Include the appropriate functionN header #define BOOST_SIGNAL_FUNCTION_N_HEADER \ BOOST_JOIN(<boost/function/function,BOOST_SIGNALS_NUM_ARGS.hpp>) #include BOOST_SIGNAL_FUNCTION_N_HEADER // Determine if a comma should follow a listing of the arguments/parameters #if BOOST_SIGNALS_NUM_ARGS == 0 # define BOOST_SIGNALS_COMMA_IF_NONZERO_ARGS #else # define BOOST_SIGNALS_COMMA_IF_NONZERO_ARGS , #endif // BOOST_SIGNALS_NUM_ARGS > 0 // Standard library argument type member typedefs #if BOOST_SIGNALS_NUM_ARGS == 1 # define BOOST_SIGNALS_STANDARD_ARG_TYPES typedef T0 argument_type; #elif BOOST_SIGNALS_NUM_ARGS == 2 # define BOOST_SIGNALS_STANDARD_ARG_TYPES \ typedef T0 first_argument_type;\ typedef T1 second_argument_type; #else # define BOOST_SIGNALS_STANDARD_ARG_TYPES #endif // Define class names used #define BOOST_SIGNALS_SIGNAL BOOST_JOIN(signal,BOOST_SIGNALS_NUM_ARGS) #define BOOST_SIGNALS_FUNCTION BOOST_JOIN(function,BOOST_SIGNALS_NUM_ARGS) #define BOOST_SIGNALS_ARGS_STRUCT BOOST_JOIN(args,BOOST_SIGNALS_NUM_ARGS) #define BOOST_SIGNALS_CALL_BOUND BOOST_JOIN(call_bound,BOOST_SIGNALS_NUM_ARGS) #define BOOST_SIGNALS_SELECT_SLOT_FUNCTION \ BOOST_JOIN(select_slot_function,BOOST_SIGNALS_NUM_ARGS) // Define commonly-used instantiations #define BOOST_SIGNALS_ARGS_STRUCT_INST \ BOOST_SIGNALS_NAMESPACE::detail::BOOST_SIGNALS_ARGS_STRUCT<BOOST_SIGNALS_TEMPLATE_ARGS> |