OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
WModuleOneToOneCombiner.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WMODULEONETOONECOMBINER_H
26 #define WMODULEONETOONECOMBINER_H
27 
28 #include <string>
29 
30 #include <boost/shared_ptr.hpp>
31 
32 #include "../WModule.h"
33 #include "../WModuleCombiner.h"
34 #include "../WModuleCombinerTypes.h"
35 
36 #include "../WExportKernel.h"
37 
38 /**
39  * Base class for all combiners which apply one connection between two connectors of two modules.
40  */
41 class OWKERNEL_EXPORT WModuleOneToOneCombiner: public WModuleCombiner
42 {
43 public:
44 
45  /**
46  * Creates a combiner which sets up the specified modules and prototype combination. Specifying a NULL pointer to the srcModule parameter
47  * causes the combiner to only add the target module without any connections. This is especially useful for modules which do not provide any
48  * input which must be connected. It is possible to specify prototypes here. The will get created upon apply.
49  *
50  *
51  * \param target the target container
52  * \param srcModule the module whose output should be connected with the prototypes input
53  * \param srcConnector the output connector of the module
54  * \param targetModule the module/prototype to use for connecting the module with
55  * \param targetConnector the input connector of the prototype to connect with srcConnector.
56  */
57  WModuleOneToOneCombiner( boost::shared_ptr< WModuleContainer > target,
58  boost::shared_ptr< WModule > srcModule, std::string srcConnector,
59  boost::shared_ptr< WModule > targetModule, std::string targetConnector );
60 
61  /**
62  * Creates a combiner which sets up the specified modules and prototype combination. This constructor automatically uses the kernel's root
63  * container as target container. Specifying a NULL pointer to the srcModule parameter
64  * causes the combiner to only add the target module without any connections. This is especially useful for modules which do not provide any
65  * input which must be connected. It is possible to specify prototypes here. The will get created upon apply.
66  *
67  * \param srcModule the module whose output should be connected with the prototypes input
68  * \param srcConnector the output connector of the module
69  * \param targetModule the module/prototype to use for connecting the module with
70  * \param targetConnector the input connector of the prototype to connect with srcConnector.
71  */
72  WModuleOneToOneCombiner( boost::shared_ptr< WModule > srcModule, std::string srcConnector,
73  boost::shared_ptr< WModule > targetModule, std::string targetConnector );
74 
75  /**
76  * Destructor.
77  */
78  virtual ~WModuleOneToOneCombiner();
79 
80  /**
81  * Apply the internal module structure to the target container. Be aware, that this operation might take some time, as modules can be
82  * connected only if they are "ready", which, at least with WMData modules, might take some time. It applies the loaded project file.
83  */
84  virtual void apply() = 0;
85 
86  /**
87  * Gets the source module. This module's output connector is connected with the target.
88  *
89  * \return the source module.
90  */
91  boost::shared_ptr< WModule > getSrcModule() const;
92 
93  /**
94  * The output connector of m_srcModule to connect with m_targetConnector.
95  *
96  * \return the source module's output connector.
97  */
98  std::string getSrcConnector() const;
99 
100  /**
101  * The module/prototype to connect with m_srcModule.
102  *
103  * \return the target module prototype.
104  */
105  boost::shared_ptr< WModule > getTargetModule() const;
106 
107  /**
108  * The input connector the target module to connect with m_srcConnector.
109  *
110  * \return the target module's input connector.
111  */
112  std::string getTargetConnector() const;
113 
114 protected:
115 
116  /**
117  * The source module to connect with the target
118  */
119  boost::shared_ptr< WModule > m_srcModule;
120 
121  /**
122  * The output connector of m_srcModule to connect with m_targetConnector.
123  */
124  std::string m_srcConnector;
125 
126  /**
127  * The module/prototype to connect with m_srcMdodule.
128  */
129  boost::shared_ptr< WModule > m_targetModule;
130 
131  /**
132  * The input connector the target module to connect with m_srcConnector.
133  */
134  std::string m_targetConnector;
135 
136 private:
137 };
138 
139 #endif // WMODULEONETOONECOMBINER_H
140 
141