b9d4c4c783d0a9bb0ba6040ac4422382f37c50e6
[senf.git] / senf / 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 #include "MultiConnectorMixin.hh"
35
36 //#include "Duplicators.mpp"
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38
39 namespace senf {
40 namespace ppi {
41 namespace module {
42
43     /** \brief Copy every incoming packet to each output
44
45         ActiveDuplicator will take every received packet and push it out to each connected output.
46
47         Since ActiveDuplicator allows any number of incoming packet streams, the input connectors
48         are dynamically managed. A special senf::ppi::connect() overload is used to dynamically
49         create the needed input connectors. This hides this extra functionality from the user.
50         \code
51         senf::ppi::module::ActiveDuplicator dup;
52
53         senf::ppi::connect(sourceModule, dup);
54         senf::ppi::connect(dup, targetModule1);
55         senf::ppi::connect(dup, targetModule2.some_input);
56         \endcode
57
58         \ingroup routing_modules
59      */
60     class ActiveDuplicator
61         : public Module,
62           public MultiConnectorMixin<ActiveDuplicator, connector::ActiveOutput<> >
63     {
64         SENF_PPI_MODULE(ActiveDuplicator);
65     public:
66         connector::PassiveInput<> input;
67
68         ActiveDuplicator();
69
70     private:
71         void connectorSetup(ActiveDuplicator::ConnectorType & conn);
72         void request();
73
74         friend class MultiConnectorMixin<ActiveDuplicator, connector::ActiveOutput<> >;
75     };
76
77 }}}
78
79
80
81 //-/////////////////////////////////////////////////////////////////////////////////////////////////
82 #include "Duplicators.cci"
83 //#include "Duplicators.ct"
84 //#include "Duplicators.cti"
85 #endif
86
87 \f
88 // Local Variables:
89 // mode: c++
90 // fill-column: 100
91 // comment-column: 40
92 // c-file-style: "senf"
93 // indent-tabs-mode: nil
94 // ispell-local-dictionary: "american"
95 // compile-command: "scons -u test"
96 // End: