OpenWalnut  1.5.0dev
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 <memory>
29 #include <string>
30 
31 
32 #include "../WModule.h"
33 #include "../WModuleCombiner.h"
34 #include "../WModuleCombinerTypes.h"
35 
36 
37 
38 /**
39  * Base class for all combiners which apply one connection between two connectors of two modules.
40  */
42 {
43 public:
44  /**
45  * Creates a combiner which sets up the specified modules and prototype combination. Specifying a NULL pointer to the srcModule parameter
46  * causes the combiner to only add the target module without any connections. This is especially useful for modules which do not provide any
47  * input which must be connected. It is possible to specify prototypes here. The will get created upon apply.
48  *
49  *
50  * \param target the target container
51  * \param srcModule the module whose output should be connected with the prototypes input
52  * \param srcConnector the output connector of the module
53  * \param targetModule the module/prototype to use for connecting the module with
54  * \param targetConnector the input connector of the prototype to connect with srcConnector.
55  */
56  WModuleOneToOneCombiner( std::shared_ptr< WModuleContainer > target,
57  std::shared_ptr< WModule > srcModule, std::string srcConnector,
58  std::shared_ptr< WModule > targetModule, std::string targetConnector );
59 
60  /**
61  * Creates a combiner which sets up the specified modules and prototype combination. This constructor automatically uses the kernel's root
62  * container as target container. Specifying a NULL pointer to the srcModule parameter
63  * causes the combiner to only add the target module without any connections. This is especially useful for modules which do not provide any
64  * input which must be connected. It is possible to specify prototypes here. The will get created upon apply.
65  *
66  * \param srcModule the module whose output should be connected with the prototypes input
67  * \param srcConnector the output connector of the module
68  * \param targetModule the module/prototype to use for connecting the module with
69  * \param targetConnector the input connector of the prototype to connect with srcConnector.
70  */
71  WModuleOneToOneCombiner( std::shared_ptr< WModule > srcModule, std::string srcConnector,
72  std::shared_ptr< WModule > targetModule, std::string targetConnector );
73 
74  /**
75  * Destructor.
76  */
77  virtual ~WModuleOneToOneCombiner();
78 
79  /**
80  * Apply the internal module structure to the target container. Be aware, that this operation might take some time, as modules can be
81  * connected only if they are "ready", which, at least with WDataModule modules, might take some time. It applies the loaded project file.
82  */
83  virtual void apply() = 0;
84 
85  /**
86  * Gets the source module. This module's output connector is connected with the target.
87  *
88  * \return the source module.
89  */
90  std::shared_ptr< WModule > getSrcModule() const;
91 
92  /**
93  * The output connector of m_srcModule to connect with m_targetConnector.
94  *
95  * \return the source module's output connector.
96  */
97  std::string getSrcConnector() const;
98 
99  /**
100  * The module/prototype to connect with m_srcModule.
101  *
102  * \return the target module prototype.
103  */
104  std::shared_ptr< WModule > getTargetModule() const;
105 
106  /**
107  * The input connector the target module to connect with m_srcConnector.
108  *
109  * \return the target module's input connector.
110  */
111  std::string getTargetConnector() const;
112 
113 protected:
114  /**
115  * The source module to connect with the target
116  */
117  std::shared_ptr< WModule > m_srcModule;
118 
119  /**
120  * The output connector of m_srcModule to connect with m_targetConnector.
121  */
122  std::string m_srcConnector;
123 
124  /**
125  * The module/prototype to connect with m_srcMdodule.
126  */
127  std::shared_ptr< WModule > m_targetModule;
128 
129  /**
130  * The input connector the target module to connect with m_srcConnector.
131  */
132  std::string m_targetConnector;
133 
134 private:
135 };
136 
137 #endif // WMODULEONETOONECOMBINER_H
138 
139 
This is a base class for all module combination classes.
Base class for all combiners which apply one connection between two connectors of two modules.
std::shared_ptr< WModule > getSrcModule() const
Gets the source module.
WModuleOneToOneCombiner(std::shared_ptr< WModuleContainer > target, std::shared_ptr< WModule > srcModule, std::string srcConnector, std::shared_ptr< WModule > targetModule, std::string targetConnector)
Creates a combiner which sets up the specified modules and prototype combination.
std::shared_ptr< WModule > m_srcModule
The source module to connect with the target.
std::string getTargetConnector() const
The input connector the target module to connect with m_srcConnector.
virtual ~WModuleOneToOneCombiner()
Destructor.
std::string m_targetConnector
The input connector the target module to connect with m_srcConnector.
std::string m_srcConnector
The output connector of m_srcModule to connect with m_targetConnector.
std::shared_ptr< WModule > getTargetModule() const
The module/prototype to connect with m_srcModule.
virtual void apply()=0
Apply the internal module structure to the target container.
std::string getSrcConnector() const
The output connector of m_srcModule to connect with m_targetConnector.
std::shared_ptr< WModule > m_targetModule
The module/prototype to connect with m_srcMdodule.