OpenWalnut
1.4.0
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WMODULEOUTPUTCONNECTOR_H 00026 #define WMODULEOUTPUTCONNECTOR_H 00027 00028 #include <string> 00029 00030 #include <boost/signals2/signal.hpp> 00031 #include <boost/signals2/connection.hpp> 00032 00033 class WModule; 00034 #include "WModuleConnector.h" 00035 #include "WModuleConnectorSignals.h" 00036 #include "../common/WPrototyped.h" 00037 #include "../common/WTransferable.h" 00038 00039 00040 00041 /** 00042 * Class implementing output connection functionality between modules. 00043 */ 00044 class WModuleOutputConnector: public WModuleConnector 00045 { 00046 public: 00047 // ************************************************************************************************************************** 00048 // Methods 00049 // ************************************************************************************************************************** 00050 00051 /** 00052 * Constructor. 00053 * 00054 * \param module the module which is owner of this connector. 00055 * \param name The name of this connector. 00056 * \param description Short description of this connector. 00057 */ 00058 WModuleOutputConnector( boost::shared_ptr< WModule > module, std::string name="", std::string description="" ); 00059 00060 /** 00061 * Destructor. 00062 */ 00063 virtual ~WModuleOutputConnector(); 00064 00065 /** 00066 * Connects (subscribes) a specified notify function with a signal this module instance is offering. 00067 * 00068 * \exception WModuleSignalSubscriptionFailed thrown if the signal can't be connected. 00069 * 00070 * \param signal the signal to connect to. 00071 * \param notifier the notifier function to bind. 00072 * 00073 * \return the connection object. Disconnect manually if not needed anymore. 00074 */ 00075 boost::signals2::connection subscribeSignal( MODULE_CONNECTOR_SIGNAL signal, t_GenericSignalHandlerType notifier ); 00076 00077 /** 00078 * Checks whether the specified connector is an input connector. 00079 * 00080 * \param con the connector to check against. 00081 * 00082 * \return true if compatible. 00083 */ 00084 virtual bool connectable( boost::shared_ptr<WModuleConnector> con ); 00085 00086 /** 00087 * Returns the prototype of the WTransferable used in this connector. 00088 * 00089 * \return the prototype of the transfered type. 00090 */ 00091 virtual boost::shared_ptr< WPrototyped > getTransferPrototype() = 0; 00092 00093 /** 00094 * Gives back the currently set data as WTransferable. 00095 * 00096 * \return the data. If no data has been set: a NULL pointer is returned. 00097 */ 00098 virtual const boost::shared_ptr< WTransferable > getRawData() const = 0; 00099 00100 /** 00101 * Returns true if this instance is an WModuleInputConnector. 00102 * 00103 * \return true if castable to WModuleInputConnector. 00104 */ 00105 virtual bool isInputConnector() const; 00106 00107 /** 00108 * Returns true if this instance is an WModuleOutputConnector. 00109 * 00110 * \return true if castable to WModuleOutputConnector. 00111 */ 00112 virtual bool isOutputConnector() const; 00113 00114 protected: 00115 // If you want to add additional signals an output connector should subscribe FROM an input connector, overwrite 00116 // connectSignals 00117 // virtual void connectSignals( boost::shared_ptr<WModuleConnector> con ); 00118 00119 /** 00120 * Propagates the signal "DATA_CHANGED" to all connected items. 00121 */ 00122 virtual void propagateDataChange(); 00123 00124 private: 00125 /** 00126 * Signal fired whenever new data should be propagated. Represented by DATA_CHANGED enum- element. 00127 */ 00128 t_GenericSignalType signal_DataChanged; 00129 }; 00130 00131 #endif // WMODULEOUTPUTCONNECTOR_H 00132