OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
WModuleOutputConnector.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 WMODULEOUTPUTCONNECTOR_H
26 #define WMODULEOUTPUTCONNECTOR_H
27 
28 #include <string>
29 
30 #include <boost/signals2/signal.hpp>
31 #include <boost/signals2/connection.hpp>
32 
33 #include "WModule.h"
34 #include "WModuleConnector.h"
35 #include "WModuleConnectorSignals.h"
36 #include "../common/WPrototyped.h"
37 #include "../common/WTransferable.h"
38 
39 #include "WExportKernel.h"
40 
41 /**
42  * Class implementing output connection functionality between modules.
43  */
44 class OWKERNEL_EXPORT WModuleOutputConnector: public WModuleConnector
45 {
46 public:
47 
48  // **************************************************************************************************************************
49  // Methods
50  // **************************************************************************************************************************
51 
52  /**
53  * Constructor.
54  *
55  * \param module the module which is owner of this connector.
56  * \param name The name of this connector.
57  * \param description Short description of this connector.
58  */
59  WModuleOutputConnector( boost::shared_ptr< WModule > module, std::string name="", std::string description="" );
60 
61  /**
62  * Destructor.
63  */
64  virtual ~WModuleOutputConnector();
65 
66  /**
67  * Connects (subscribes) a specified notify function with a signal this module instance is offering.
68  *
69  * \exception WModuleSignalSubscriptionFailed thrown if the signal can't be connected.
70  *
71  * \param signal the signal to connect to.
72  * \param notifier the notifier function to bind.
73  *
74  * \return the connection object. Disconnect manually if not needed anymore.
75  */
76  boost::signals2::connection subscribeSignal( MODULE_CONNECTOR_SIGNAL signal, t_GenericSignalHandlerType notifier );
77 
78  /**
79  * Checks whether the specified connector is an input connector.
80  *
81  * \param con the connector to check against.
82  *
83  * \return true if compatible.
84  */
85  virtual bool connectable( boost::shared_ptr<WModuleConnector> con );
86 
87  /**
88  * Returns the prototype of the WTransferable used in this connector.
89  *
90  * \return the prototype of the transfered type.
91  */
92  virtual boost::shared_ptr< WPrototyped > getTransferPrototype() = 0;
93 
94  /**
95  * Gives back the currently set data as WTransferable.
96  *
97  * \return the data. If no data has been set: a NULL pointer is returned.
98  */
99  virtual const boost::shared_ptr< WTransferable > getRawData() const = 0;
100 
101  /**
102  * Returns true if this instance is an WModuleInputConnector.
103  *
104  * \return true if castable to WModuleInputConnector.
105  */
106  virtual bool isInputConnector() const;
107 
108  /**
109  * Returns true if this instance is an WModuleOutputConnector.
110  *
111  * \return true if castable to WModuleOutputConnector.
112  */
113  virtual bool isOutputConnector() const;
114 
115 protected:
116 
117  // If you want to add additional signals an output connector should subscribe FROM an input connector, overwrite
118  // connectSignals
119  // virtual void connectSignals( boost::shared_ptr<WModuleConnector> con );
120 
121  /**
122  * Propagates the signal "DATA_CHANGED" to all connected items.
123  */
124  virtual void propagateDataChange();
125 
126 private:
127 
128  /**
129  * Signal fired whenever new data should be propagated. Represented by DATA_CHANGED enum- element.
130  */
131  t_GenericSignalType signal_DataChanged;
132 };
133 
134 #endif // WMODULEOUTPUTCONNECTOR_H
135