Update of /cvsroot/boost-sandbox/boost-sandbox/boost/signals/detail In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11388/signals/detail Modified Files: config.hpp signal_base.hpp signal_impl_base.hpp signals_common.hpp slot_signal_interface.hpp Removed Files: threading_model.hpp Log Message: Simplified the template interface; some code cleanup; added Allocator template parameter; work-in-progress; Index: signal_base.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/signals/detail/signal_base.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- signal_base.hpp 9 Feb 2007 06:34:51 -0000 1.2 +++ signal_base.hpp 18 Feb 2007 16:51:21 -0000 1.3 @@ -28,30 +28,35 @@ namespace BOOST_SIGNALS_NAMESPACE { namespace detail { // signal_impl class template. - // Holds the compiner and derives from a signal_impl_base instantiation - // providing the slot maintenance functionality. - template<class Combiner, class ThreadingModel> - class signal_impl : public signal_impl_base<ThreadingModel> + // Holds the combiner and derives from a signal_impl_base instantiation + // which is providing the slot maintenance functionality. + template<typename Combiner, + typename Group, + typename GroupCompare, + typename ThreadingModel, + typename Allocator> + class signal_impl + : public signal_impl_base<Group, GroupCompare, ThreadingModel, Allocator> { - typedef signal_impl_base<ThreadingModel> base_type; public: -#ifdef BOOST_SIGNALS_NO_LEGACY_SUPPORT - signal_impl(const Combiner& c) - : base_type(), combiner_(c) - { } -#else + typedef signal_impl_base<Group, GroupCompare, ThreadingModel, + Allocator> base_type; + signal_impl(const Combiner& c, - const legacy_implementation::compare_type& comp) + const GroupCompare& comp) : base_type(comp), combiner_(c) { } -#endif // def BOOST_SIGNALS_NO_LEGACY_SUPPORT - Combiner& combiner() { + // Combiner access. + Combiner& combiner() + { return combiner_; } - const Combiner& combiner() const { + const Combiner& combiner() const + { return combiner_; } + private: Combiner combiner_; }; @@ -64,26 +69,25 @@ // Implement common functionality for all signal types which is not // dependent on the signal call signature. Holds the shared_ptr to // the actual implementation. - template<class Combiner, class ThreadingModel> - class BOOST_SIGNALS_DECL signal_base : public signal_base_tag, public noncopyable + template<typename Combiner, + typename Group, + typename GroupCompare, + typename ThreadingModel, + typename Allocator> + class BOOST_SIGNALS_DECL signal_base + : public signal_base_tag, + public noncopyable { protected: - typedef signal_impl<Combiner, ThreadingModel> signal_impl_type; + typedef signal_impl<Combiner, Group, GroupCompare, ThreadingModel, + Allocator> impl_type; + typedef typename impl_type::base_type impl_base_type; public: -#ifdef BOOST_SIGNALS_NO_LEGACY_SUPPORT - signal_base(const Combiner& combiner) - : impl_(new signal_impl_type(combiner)) - { } - -#else - typedef typename signal_impl_type::compare_type compare_type; - - signal_base(const Combiner& combiner, const compare_type& comp) - : impl_(new signal_impl_type(combiner, comp)) + signal_base(const Combiner& combiner, const GroupCompare& comp) + : impl_(new impl_type(combiner, comp)) { } -#endif ~signal_base() { impl_->disconnect_all_slots(); @@ -107,15 +111,15 @@ protected: connection connect_slot( - const shared_ptr<slot_signal_interface<signal_impl_type> >& slot, + const shared_ptr<slot_signal_interface<impl_type> >& slot, connect_position at) { return impl_->connect_slot(slot, at); } - typedef typename signal_impl_type::slot_iterator iterator; + typedef typename impl_type::slot_iterator iterator; - shared_ptr<signal_impl_type> impl_; + shared_ptr<impl_type> impl_; }; } // end namespace detail } // end namespace BOOST_SIGNALS_NAMESPACE Index: config.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/signals/detail/config.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- config.hpp 7 Feb 2007 01:21:35 -0000 1.1 +++ config.hpp 18 Feb 2007 16:51:21 -0000 1.2 @@ -17,30 +17,30 @@ #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 +//#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 +//// 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 Index: signals_common.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/signals/detail/signals_common.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- signals_common.hpp 9 Feb 2007 06:34:51 -0000 1.2 +++ signals_common.hpp 18 Feb 2007 16:51:21 -0000 1.3 @@ -25,7 +25,17 @@ namespace boost { namespace BOOST_SIGNALS_NAMESPACE { + // no_name type + // Represents disabled grouping of slots when provided as a group + // type. + struct no_name { }; + namespace detail { + // no_name_compare type + // Simple comparison predicate replacement for signals using the no_name + // group type. + struct no_name_compare { }; + // 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 @@ -34,17 +44,6 @@ 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; - }; - struct signal_base_tag; template<typename T> Index: slot_signal_interface.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/signals/detail/slot_signal_interface.hpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- slot_signal_interface.hpp 11 Feb 2007 06:13:30 -0000 1.4 +++ slot_signal_interface.hpp 18 Feb 2007 16:51:21 -0000 1.5 @@ -26,11 +26,11 @@ // library that are aware of the signal implementation in use. template<class SignalImpl> class slot_signal_interface - : public SignalImpl::slot_tracker_base_type + : public SignalImpl::slot_tracking_base_type { typedef typename SignalImpl::slot_iterator iterator; typedef typename SignalImpl::signal_lock signal_lock; - typedef typename SignalImpl::slot_tracker_base_type base_type; + typedef typename SignalImpl::slot_tracking_base_type base_type; public: // Acquire the slot from a locked signal context (protect it from being // removed). This and release() below is used to ensure a valid iterator @@ -57,16 +57,26 @@ } } + // Release if not already disconnected. + void disconnect() + { + if(!disconnected()) + release(); + } + // Check the connection state from a locked signal context. - bool disconnected() const { + bool disconnected() const + { return disconnected_; } // Check the blocking state from a locked signal context. - bool blocked() const { + bool blocked() const + { return block_ != 0; } // Check the callability from a locked signal context. - bool callable() const { + bool callable() const + { return !disconnected_ && (block_ == 0); } Index: signal_impl_base.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/signals/detail/signal_impl_base.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- signal_impl_base.hpp 11 Feb 2007 06:13:30 -0000 1.2 +++ signal_impl_base.hpp 18 Feb 2007 16:51:21 -0000 1.3 @@ -11,11 +11,13 @@ #ifndef BOOST_SIGNALS_DETAIL_SIGNAL_IMPL_HEADER #define BOOST_SIGNALS_DETAIL_SIGNAL_IMPL_HEADER -#include <boost/signals/detail/config.hpp> #include <boost/signals/detail/signals_common.hpp> -#include <boost/signals/detail/connect_position.hpp> +#include <boost/signals/detail/unnamed_slot_container.hpp> +#include <boost/signals/detail/named_slot_container.hpp> #include <boost/signals/detail/slot_signal_interface.hpp> #include <boost/signals/connection.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_same.hpp> #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -24,17 +26,42 @@ namespace boost { namespace BOOST_SIGNALS_NAMESPACE { namespace detail { + // select_slot_container template. + // Determine the proper type for slot storage from the Group and GroupCompare + // template arguments. + template<typename T, + typename Group, + typename GroupCompare, + typename Allocator + > + struct select_slot_container + { + typedef typename mpl::if_< + is_same<Group, no_name>, + unnamed_slot_container<T, Allocator>, + named_slot_container<T, Group, GroupCompare, Allocator> + >::type type; + }; + // signal_impl_base class template. - template<class ThreadingModel> + template<typename Group, + typename GroupCompare, + typename ThreadingModel, + typename Allocator + > class BOOST_SIGNALS_DECL signal_impl_base - : public ThreadingModel, - public enable_shared_from_this<signal_impl_base<ThreadingModel> > + : public ThreadingModel::signal_impl_threading_base_type, + public enable_shared_from_this<signal_impl_base<Group, + GroupCompare, + ThreadingModel, + Allocator> >, + public ThreadingModel { public: typedef slot_signal_interface<signal_impl_base> slot_interface; - typedef slot_tracking_base slot_tracker_base_type; - signal_impl_base() + signal_impl_base(const GroupCompare& comp) + : slots_(comp) { } ~signal_impl_base() { } @@ -62,22 +89,43 @@ return slots_.size(); } + // Connect an unnamed slot. connection connect_slot(const shared_ptr<slot_interface>& slot, connect_position at) { local_lock lock(this); - slot_iterator pos; - if(at == at_back) { - pos = slots_.insert(slots_.end(), slot); - } else { - pos = slots_.insert(slots_.begin(), slot); - } + slot_iterator pos = slots_.insert(slot, at); + slot->reset(shared_from_this(), pos); + return connection(slot); + } + + // Connect a named slot. + connection connect_slot(const shared_ptr<slot_interface>& slot, + const Group& group, + connect_position at) + { + local_lock lock(this); + slot_iterator pos = slots_.insert(slot, group, at); slot->reset(shared_from_this(), pos); return connection(slot); } + // Disconnect a slot group. + void disconnect(const Group& group) + { + local_lock lock(this); + std::pair<slot_iterator, slot_iterator> range = slots_.group_range(group); + slot_iterator it = range.first; + while(it != range.second) { + slot_iterator tmp = it++; + (*tmp)->disconnect(); + } + } public: - typedef std::list<shared_ptr<slot_interface> > slot_container; + typedef typename select_slot_container<shared_ptr<slot_interface>, + Group, + GroupCompare, + Allocator>::type slot_container; typedef typename slot_container::iterator slot_iterator; void remove_slot(const slot_iterator& pos) { --- threading_model.hpp DELETED --- |