// // broadcast_dispatcher.hpp // // Copyright (c) 2005-2009 Yigong Liu (yigongliu at gmail dot com) // // 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) // //// broadcast dispatcher #ifndef BROADCAST_DISPATCHER_HPP #define BROADCAST_DISPATCHER_HPP #include #include #include #include #include #include #include #include #include #include namespace boost { namespace channel { namespace detail { //the following is for 3 simple "push" dispatchers: broadcast, roundrobin, union template struct broadcast_algo { typedef typename name_space::id_type id_type; typedef message msg_type; typedef push_recver_base recver_type; typedef named_in named_in_type; template void operator() (bindings_type &bindings, boost::shared_ptr msg) { if (!bindings.empty()) { for(typename bindings_type::iterator iter = bindings.begin(); iter != bindings.end(); iter++) { named_in_type *named_in = (named_in_type *)(*iter); recver_type *recver = (recver_type *)named_in; recver->push(msg); } } } }; } template struct broadcast_dispatcher { typedef detail::push_sender_base sender; typedef detail::push_recver_base recver; }; } } #endif