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