OpenWalnut  1.5.0dev
WMTemplateContainers.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 WMTEMPLATECONTAINERS_H
26 #define WMTEMPLATECONTAINERS_H
27 
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 #include <boost/thread.hpp>
33 
34 #include "core/dataHandler/WDataSetScalar.h"
35 #include "core/kernel/WModule.h"
36 #include "core/kernel/WModuleContainer.h"
37 #include "core/kernel/WModuleInputForwardData.h"
38 #include "core/kernel/WModuleOutputForwardData.h"
39 
40 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
41 // If you want to learn how to program a module, refer to WMTemplate.cpp. It is an extensive tutorial on all the details.
42 // In this tutorial, we assume you already know how to write modules. For other examples, refer to the README file.
43 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
44 
45 /**
46  * \class WMTemplateContainers
47  *
48  * A module that explains re-use and re-combination of existing modules. Therefore, we derive from WModuleContainer. A module container itself is
49  * a module, but can additionally contain modules for itself. This way, we are able to re-use other modules and re-combine them in a different
50  * way. We will be able to connect inputs and outputs of inner modules to our own connectors and, thus, will be able to forward data easily.
51  * Please read the WMTemplateContainers.cpp file for all further descriptions.
52  *
53  * \ingroup modules
54  */
56 {
57 public:
58  /**
59  * Constuctor.
60  */
62 
63  /**
64  * Destructor.
65  */
66  virtual ~WMTemplateContainers();
67 
68  /**
69  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
70  * should never be initialized or modified in some other way. A simple new instance is required.
71  *
72  * \return the prototype used to create every module in OpenWalnut.
73  */
74  virtual std::shared_ptr< WModule > factory() const;
75 
76 protected:
77  /**
78  * Entry point after loading the module. Runs in separate thread.
79  */
80  virtual void moduleMain();
81 
82  /**
83  * Initialize the connectors this module is using.
84  */
85  virtual void connectors();
86 
87  /**
88  * Initialize the properties for this module.
89  */
90  virtual void properties();
91 
92  /**
93  * Initialize requirements for this module.
94  */
95  virtual void requirements();
96 
97 private:
98  /**
99  * Define an input connector, which only forwards the data. This is very useful since we want this to be some kind of "gate" to the outside
100  * world. Data going into this connector can be used by a real WModuleInputData connector of an embedded module.
101  */
103 
104  /**
105  * Define an output connector, which only forwards the data. This is very useful since we want this to be some kind of "gate" to the outside
106  * world. Data going out of this connector is originating from a real WModuleInputData connector of an embedded module.
107  */
109 };
110 
111 #endif // WMTEMPLATECONTAINERS_H
A module that explains re-use and re-combination of existing modules.
WModuleOutputForwardData< WDataSetScalar >::SPtr m_output
Define an output connector, which only forwards the data.
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
virtual ~WMTemplateContainers()
Destructor.
virtual void connectors()
Initialize the connectors this module is using.
virtual void requirements()
Initialize requirements for this module.
virtual void properties()
Initialize the properties for this module.
virtual void moduleMain()
Entry point after loading the module.
WModuleInputForwardData< WDataSetScalar >::SPtr m_input
Define an input connector, which only forwards the data.
Class able to contain other modules.
This is a simple class which forwards input data to input data connectors.
This is a simple class which forwards output data to output data connectors.