diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-06-01 08:48:42 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-06-01 09:24:28 (GMT) |
commit | 2812bddd81f8a1b804c7460f4e14cd0aa393d129 (patch) | |
tree | d46294f35150c4f0f43deaf2d31fceaf945ae715 /3rdParty/Boost/boost/signals/detail | |
download | swift-contrib-2812bddd81f8a1b804c7460f4e14cd0aa393d129.zip swift-contrib-2812bddd81f8a1b804c7460f4e14cd0aa393d129.tar.bz2 |
Import.
Diffstat (limited to '3rdParty/Boost/boost/signals/detail')
-rw-r--r-- | 3rdParty/Boost/boost/signals/detail/config.hpp | 54 | ||||
-rw-r--r-- | 3rdParty/Boost/boost/signals/detail/named_slot_map.hpp | 193 | ||||
-rw-r--r-- | 3rdParty/Boost/boost/signals/detail/signal_base.hpp | 159 | ||||
-rw-r--r-- | 3rdParty/Boost/boost/signals/detail/signals_common.hpp | 162 | ||||
-rw-r--r-- | 3rdParty/Boost/boost/signals/detail/slot_call_iterator.hpp | 95 |
5 files changed, 663 insertions, 0 deletions
diff --git a/3rdParty/Boost/boost/signals/detail/config.hpp b/3rdParty/Boost/boost/signals/detail/config.hpp new file mode 100644 index 0000000..bdd6d20 --- /dev/null +++ b/3rdParty/Boost/boost/signals/detail/config.hpp @@ -0,0 +1,54 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Copyright (c) 2003-2004 + * Douglas Gregor + * + * Distributed under 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) + * + */ + +#ifndef BOOST_SIGNALS_CONFIG_HPP +#define BOOST_SIGNALS_CONFIG_HPP + +#include <boost/config.hpp> + +#ifdef BOOST_HAS_DECLSPEC +# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SIGNALS_DYN_LINK) +# ifdef BOOST_SIGNALS_SOURCE +# define BOOST_SIGNALS_DECL __declspec(dllexport) +# else +# define BOOST_SIGNALS_DECL __declspec(dllimport) +# endif // BOOST_SIGNALS_SOURCE +# endif // DYN_LINK +#endif // BOOST_HAS_DECLSPEC + +#ifndef BOOST_SIGNALS_DECL +# define BOOST_SIGNALS_DECL +#endif + +// Setup autolinking +#if !defined(BOOST_SIGNALS_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SIGNALS_NO_LIB) +# define BOOST_LIB_NAME boost_signals + +# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SIGNALS_DYN_LINK) +# define BOOST_DYN_LINK +# endif + +# include <boost/config/auto_link.hpp> +#endif // autolinking on + +#endif // BOOST_SIGNALS_CONFIG_HPP + + + + + + + + + diff --git a/3rdParty/Boost/boost/signals/detail/named_slot_map.hpp b/3rdParty/Boost/boost/signals/detail/named_slot_map.hpp new file mode 100644 index 0000000..e31d380 --- /dev/null +++ b/3rdParty/Boost/boost/signals/detail/named_slot_map.hpp @@ -0,0 +1,193 @@ +// Boost.Signals library + +// 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_NAMED_SLOT_MAP_HPP +#define BOOST_SIGNALS_NAMED_SLOT_MAP_HPP + +#include <boost/signals/detail/config.hpp> +#include <boost/signals/detail/signals_common.hpp> +#include <boost/signals/connection.hpp> +#include <boost/utility.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/function/function2.hpp> +#include <boost/iterator/iterator_facade.hpp> +#include <map> +#include <memory> +#include <utility> + +namespace boost { namespace BOOST_SIGNALS_NAMESPACE { + +enum connect_position { at_back, at_front }; + +namespace detail { + +class stored_group +{ + public: + enum storage_kind { sk_empty, sk_front, sk_back, sk_group }; + + stored_group(storage_kind kind = sk_empty) : kind(kind), group() { } + + template<typename T> + stored_group(const T& group) : kind(sk_group), group(new T(group)) { } + + bool is_front() const { return kind == sk_front; } + bool is_back() const { return kind == sk_back; } + bool empty() const { return kind == sk_empty; } + + void* get() const { return group.get(); } + + private: + storage_kind kind; + shared_ptr<void> group; +}; + +typedef function2<bool, stored_group, stored_group> compare_type; + +// This function object bridges from a pair of any objects that hold +// values of type Key to the underlying function object that compares +// values of type Key. +template<typename Compare, typename Key> +class group_bridge_compare { +public: + typedef bool result_type; + typedef const stored_group& first_argument_type; + typedef const stored_group& second_argument_type; + + group_bridge_compare(const Compare& c) : comp(c) + { } + + bool operator()(const stored_group& k1, const stored_group& k2) const + { + if (k1.is_front()) return !k2.is_front(); + if (k1.is_back()) return false; + if (k2.is_front()) return false; + if (k2.is_back()) return true; + + // Neither is empty, so compare their values to order them + return comp(*static_cast<Key*>(k1.get()), *static_cast<Key*>(k2.get())); + } + +private: + Compare comp; +}; + +class BOOST_SIGNALS_DECL named_slot_map_iterator : + public iterator_facade<named_slot_map_iterator, + connection_slot_pair, + forward_traversal_tag> +{ + typedef std::list<connection_slot_pair> group_list; + typedef group_list::iterator slot_pair_iterator; + typedef std::map<stored_group, group_list, compare_type> slot_container_type; + typedef slot_container_type::iterator group_iterator; + typedef slot_container_type::const_iterator const_group_iterator; + + typedef iterator_facade<named_slot_map_iterator, + connection_slot_pair, + forward_traversal_tag> inherited; +public: + named_slot_map_iterator() : slot_assigned(false) + { } + named_slot_map_iterator(const named_slot_map_iterator& other) + : group(other.group), last_group(other.last_group), + slot_assigned(other.slot_assigned) + { + if (slot_assigned) slot_ = other.slot_; + } + named_slot_map_iterator& operator=(const named_slot_map_iterator& other) + { + slot_assigned = other.slot_assigned; + group = other.group; + last_group = other.last_group; + if (slot_assigned) slot_ = other.slot_; + return *this; + } + connection_slot_pair& dereference() const + { + return *slot_; + } + void increment() + { + ++slot_; + if (slot_ == group->second.end()) { + ++group; + init_next_group(); + } + } + bool equal(const named_slot_map_iterator& other) const { + return (group == other.group + && (group == last_group + || slot_ == other.slot_)); + } + +#if BOOST_WORKAROUND(_MSC_VER, <= 1500) + void decrement(); + void advance(difference_type); +#endif + +private: + named_slot_map_iterator(group_iterator group, group_iterator last) : + group(group), last_group(last), slot_assigned(false) + { init_next_group(); } + named_slot_map_iterator(group_iterator group, group_iterator last, + slot_pair_iterator slot) : + group(group), last_group(last), slot_(slot), slot_assigned(true) + { } + + void init_next_group() + { + while (group != last_group && group->second.empty()) ++group; + if (group != last_group) { + slot_ = group->second.begin(); + slot_assigned = true; + } + } + + group_iterator group; + group_iterator last_group; + slot_pair_iterator slot_; + bool slot_assigned; + + friend class named_slot_map; +}; + +class BOOST_SIGNALS_DECL named_slot_map +{ +public: + typedef named_slot_map_iterator iterator; + + named_slot_map(const compare_type& compare); + + void clear(); + iterator begin(); + iterator end(); + iterator insert(const stored_group& name, const connection& con, + const any& slot, connect_position at); + void disconnect(const stored_group& name); + void erase(iterator pos); + void remove_disconnected_slots(); + +private: + typedef std::list<connection_slot_pair> group_list; + typedef std::map<stored_group, group_list, compare_type> slot_container_type; + typedef slot_container_type::iterator group_iterator; + typedef slot_container_type::const_iterator const_group_iterator; + + bool empty(const_group_iterator group) const + { + return (group->second.empty() && group != groups.begin() && group != back); + } + slot_container_type groups; + group_iterator back; +}; + +} } } + +#endif // BOOST_SIGNALS_NAMED_SLOT_MAP_HPP diff --git a/3rdParty/Boost/boost/signals/detail/signal_base.hpp b/3rdParty/Boost/boost/signals/detail/signal_base.hpp new file mode 100644 index 0000000..0438cf7 --- /dev/null +++ b/3rdParty/Boost/boost/signals/detail/signal_base.hpp @@ -0,0 +1,159 @@ +// Boost.Signals library + +// 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_SIGNAL_BASE_HEADER +#define BOOST_SIGNALS_SIGNAL_BASE_HEADER + +#include <boost/signals/detail/config.hpp> +#include <boost/signals/detail/signals_common.hpp> +#include <boost/signals/detail/named_slot_map.hpp> +#include <boost/signals/connection.hpp> +#include <boost/signals/trackable.hpp> +#include <boost/signals/slot.hpp> +#include <boost/smart_ptr.hpp> +#include <boost/utility.hpp> +#include <boost/function/function2.hpp> +#include <utility> +#include <vector> + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost { + namespace BOOST_SIGNALS_NAMESPACE { + namespace detail { + // Must be constructed before calling the slots, because it safely + // manages call depth + class BOOST_SIGNALS_DECL call_notification { + public: + call_notification(const shared_ptr<signal_base_impl>&); + ~call_notification(); + + shared_ptr<signal_base_impl> impl; + }; + + // Implementation of base class for all signals. It handles the + // management of the underlying slot lists. + class BOOST_SIGNALS_DECL signal_base_impl { + public: + friend class call_notification; + + typedef function2<bool, stored_group, stored_group> compare_type; + + // Make sure that an exception does not cause the "clearing" flag to + // remain set + class temporarily_set_clearing { + public: + temporarily_set_clearing(signal_base_impl* b) : base(b) + { + base->flags.clearing = true; + } + + ~temporarily_set_clearing() + { + base->flags.clearing = false; + } + + private: + signal_base_impl* base; + }; + + friend class temporarily_set_clearing; + + signal_base_impl(const compare_type&, const any&); + ~signal_base_impl(); + + // Disconnect all slots connected to this signal + void disconnect_all_slots(); + + // Are there any connected slots? + bool empty() const; + + // The number of connected slots + std::size_t num_slots() const; + + // Disconnect all slots in the given group + void disconnect(const stored_group&); + + // We're being notified that a slot has disconnected + static void slot_disconnected(void* obj, void* data); + + connection connect_slot(const any& slot, + const stored_group& name, + shared_ptr<slot_base::data_t> data, + connect_position at); + + private: + // Remove all of the slots that have been marked "disconnected" + void remove_disconnected_slots() const; + + public: + // Our call depth when invoking slots (> 1 when we have a loop) + mutable int call_depth; + + struct { + // True if some slots have disconnected, but we were not able to + // remove them from the list of slots because there are valid + // iterators into the slot list + mutable bool delayed_disconnect:1; + + // True if we are disconnecting all disconnected slots + bool clearing:1; + } flags; + + // Slots + mutable named_slot_map slots_; + any combiner_; + + // Types + typedef named_slot_map::iterator iterator; + }; + + class BOOST_SIGNALS_DECL signal_base : public noncopyable { + public: + typedef signal_base_impl::compare_type compare_type; + + friend class call_notification; + + signal_base(const compare_type& comp, const any& combiner); + ~signal_base(); + + public: + // Disconnect all slots connected to this signal + void disconnect_all_slots() { impl->disconnect_all_slots(); } + + // Are there any connected slots? + bool empty() const { return impl->empty(); } + + // How many slots are connected? + std::size_t num_slots() const { return impl->num_slots(); } + + protected: + connection connect_slot(const any& slot, + const stored_group& name, + shared_ptr<slot_base::data_t> data, + connect_position at) + { + return impl->connect_slot(slot, name, data, at); + } + + typedef named_slot_map::iterator iterator; + + shared_ptr<signal_base_impl> impl; + }; + } // end namespace detail + } // end namespace BOOST_SIGNALS_NAMESPACE +} // end namespace boost + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif // BOOST_SIGNALS_SIGNAL_BASE_HEADER diff --git a/3rdParty/Boost/boost/signals/detail/signals_common.hpp b/3rdParty/Boost/boost/signals/detail/signals_common.hpp new file mode 100644 index 0000000..fe1a5a1 --- /dev/null +++ b/3rdParty/Boost/boost/signals/detail/signals_common.hpp @@ -0,0 +1,162 @@ +// Boost.Signals library + +// 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_COMMON_HEADER +#define BOOST_SIGNALS_COMMON_HEADER + +#ifndef BOOST_SIGNALS_NAMESPACE +# define BOOST_SIGNALS_NAMESPACE signals +#endif + +#include <boost/type_traits/conversion_traits.hpp> +#include <boost/ref.hpp> +#include <boost/signals/detail/config.hpp> + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost { + namespace BOOST_SIGNALS_NAMESPACE { + namespace detail { + // The unusable class is a placeholder for unused function arguments + // It is also completely unusable except that it constructable from + // anything. This helps compilers without partial specialization + // handle slots returning void. + struct unusable { + unusable() {} + }; + + // Determine the result type of a slot call + template<typename R> + struct slot_result_type { + typedef R type; + }; + + template<> + struct slot_result_type<void> { + typedef unusable type; + }; + + // Determine if the given type T is a signal + class signal_base; + + template<typename T> + struct is_signal { + BOOST_STATIC_CONSTANT(bool, + value = (is_convertible<T*, signal_base*>::value)); + }; + + /* + * The IF implementation is temporary code. When a Boost metaprogramming + * library is introduced, Boost.Signals will use it instead. + */ + namespace intimate { + struct SelectThen + { + template<typename Then, typename Else> + struct Result + { + typedef Then type; + }; + }; + + struct SelectElse + { + template<typename Then, typename Else> + struct Result + { + typedef Else type; + }; + }; + + template<bool Condition> + struct Selector + { + typedef SelectThen type; + }; + + template<> + struct Selector<false> + { + typedef SelectElse type; + }; + } // end namespace intimate + + template<bool Condition, typename Then, typename Else> + struct IF + { + typedef typename intimate::Selector<Condition>::type select; + typedef typename select::template Result<Then,Else>::type type; + }; + + // Determine if the incoming argument is a reference_wrapper +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template<typename T> + struct is_ref + { + BOOST_STATIC_CONSTANT(bool, value = false); + }; + + template<typename T> + struct is_ref<reference_wrapper<T> > + { + BOOST_STATIC_CONSTANT(bool, value = true); + }; +#else // no partial specialization + typedef char yes_type; + typedef double no_type; + + no_type is_ref_tester(...); + + template<typename T> + yes_type is_ref_tester(reference_wrapper<T>*); + + template<typename T> + struct is_ref + { + static T* t; + BOOST_STATIC_CONSTANT(bool, + value = (sizeof(is_ref_tester(t)) == sizeof(yes_type))); + }; +#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // A slot can be a signal, a reference to a function object, or a + // function object. + struct signal_tag {}; + struct reference_tag {}; + struct value_tag {}; + + // Classify the given slot as a signal, a reference-to-slot, or a + // standard slot + template<typename S> + class get_slot_tag { + typedef typename IF<(is_signal<S>::value), + signal_tag, + value_tag>::type signal_or_value; + + public: + typedef typename IF<(is_ref<S>::value), + reference_tag, + signal_or_value>::type type; + }; + + // Forward declaration needed in lots of places + class signal_base_impl; + class bound_objects_visitor; + class slot_base; + } // end namespace detail + } // end namespace BOOST_SIGNALS_NAMESPACE +} // end namespace boost + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif // BOOST_SIGNALS_COMMON_HEADER diff --git a/3rdParty/Boost/boost/signals/detail/slot_call_iterator.hpp b/3rdParty/Boost/boost/signals/detail/slot_call_iterator.hpp new file mode 100644 index 0000000..c6706be --- /dev/null +++ b/3rdParty/Boost/boost/signals/detail/slot_call_iterator.hpp @@ -0,0 +1,95 @@ +// Boost.Signals library + +// 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_SLOT_CALL_ITERATOR +#define BOOST_SIGNALS_SLOT_CALL_ITERATOR + +#include <memory> +#include <boost/iterator/iterator_facade.hpp> +#include <boost/smart_ptr.hpp> +#include <boost/signals/detail/config.hpp> +#include <boost/signals/connection.hpp> +#include <boost/optional.hpp> + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost { + namespace BOOST_SIGNALS_NAMESPACE { + namespace detail { + + // Generates a slot call iterator. Essentially, this is an iterator that: + // - skips over disconnected slots in the underlying list + // - calls the connected slots when dereferenced + // - caches the result of calling the slots + template<typename Function, typename Iterator> + class slot_call_iterator + : public iterator_facade<slot_call_iterator<Function, Iterator>, + typename Function::result_type, + single_pass_traversal_tag, + typename Function::result_type const&> + { + typedef iterator_facade<slot_call_iterator<Function, Iterator>, + typename Function::result_type, + single_pass_traversal_tag, + typename Function::result_type const&> + inherited; + + typedef typename Function::result_type result_type; + + friend class iterator_core_access; + + public: + slot_call_iterator(Iterator iter_in, Iterator end_in, Function f, + optional<result_type> &c) + : iter(iter_in), end(end_in), f(f), cache(&c) + { + iter = std::find_if(iter, end, is_callable()); + } + + typename inherited::reference + dereference() const + { + if (!cache->is_initialized()) { + cache->reset(f(*iter)); + } + + return cache->get(); + } + + void increment() + { + iter = std::find_if(++iter, end, is_callable()); + cache->reset(); + } + + bool equal(const slot_call_iterator& other) const + { + iter = std::find_if(iter, end, is_callable()); + other.iter = std::find_if(other.iter, other.end, + is_callable()); + return iter == other.iter; + } + + private: + mutable Iterator iter; + Iterator end; + Function f; + optional<result_type>* cache; + }; + } // end namespace detail + } // end namespace BOOST_SIGNALS_NAMESPACE +} // end namespace boost + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif // BOOST_SIGNALS_SLOT_CALL_ITERATOR |