Utils/Termlib: Extend the completion API
[senf.git] / PPI / Duplicators.hh
1 // $Id$
2 //
3 // Copyright (C) 2009 
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief Duplicators public header */
25
26 #ifndef HH_SENF_PPI_Duplicators_
27 #define HH_SENF_PPI_Duplicators_ 1
28
29 // Custom includes
30 #include <boost/ptr_container/ptr_vector.hpp>
31 #include "predecl.hh"
32 #include "Connectors.hh"
33 #include "Module.hh"
34
35 //#include "Duplicators.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
37
38 namespace senf {
39 namespace ppi {
40
41 #ifndef DOXYGEN
42
43     template <class Target>
44     connector::GenericActiveOutput & connect(module::ActiveDuplicator & source, Target & target);
45     
46 #endif
47
48 namespace module {
49
50     /** \brief Copy every incoming packet to each output
51
52         ActiveDuplicator will take every received packet and push it out to each connected output.
53
54         Since ActiveDuplicator allows any number of incoming packet streams, the input connectors
55         are dynamically managed. A special senf::ppi::connect() overload is used to dynamically
56         create the needed input connectors. This hides this extra functionality from the user. 
57         \code
58         senf::ppi::module::ActiveDuplicator dup;
59
60         senf::ppi::connect(sourceModule, dup);
61         senf::ppi::connect(dup, targetModule1);
62         senf::ppi::connect(dup, targetModule2.some_input);
63         \endcode
64
65         \ingroup routing_modules
66      */
67     class ActiveDuplicator
68         : public Module
69     {
70         SENF_PPI_MODULE(ActiveDuplicator);
71     public:
72         connector::PassiveInput<> input;
73
74         ActiveDuplicator();
75
76     private:
77         connector::ActiveOutput<> & newOutput();
78
79 #ifndef DOXYGEN
80     public:
81 #endif
82         template <class Target>
83         connector::GenericActiveOutput & connect(Target & target);
84
85     private:
86         void request();
87
88         typedef boost::ptr_vector<connector::ActiveOutput<> > Outputs;
89         Outputs outputs_;
90     };
91
92 }}}
93
94
95
96 ///////////////////////////////hh.e////////////////////////////////////////
97 #include "Duplicators.cci"
98 //#include "Duplicators.ct"
99 #include "Duplicators.cti"
100 #endif
101
102 \f
103 // Local Variables:
104 // mode: c++
105 // fill-column: 100
106 // comment-column: 40
107 // c-file-style: "senf"
108 // indent-tabs-mode: nil
109 // ispell-local-dictionary: "american"
110 // compile-command: "scons -u test"
111 // End: