OpenWalnut 1.2.5

WModuleOutputConnector.h

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 #include "WModule.h"
00034 #include "WModuleConnector.h"
00035 #include "WModuleConnectorSignals.h"
00036 #include "../common/WPrototyped.h"
00037 #include "../common/WTransferable.h"
00038 
00039 #include "WExportKernel.h"
00040 
00041 /**
00042  * Class implementing output connection functionality between modules.
00043  */
00044 class OWKERNEL_EXPORT WModuleOutputConnector: public WModuleConnector
00045 {
00046 public:
00047 
00048     // **************************************************************************************************************************
00049     // Methods
00050     // **************************************************************************************************************************
00051 
00052     /**
00053      * Constructor.
00054      *
00055      * \param module the module which is owner of this connector.
00056      * \param name The name of this connector.
00057      * \param description Short description of this connector.
00058      */
00059     WModuleOutputConnector( boost::shared_ptr< WModule > module, std::string name="", std::string description="" );
00060 
00061     /**
00062      * Destructor.
00063      */
00064     virtual ~WModuleOutputConnector();
00065 
00066     /**
00067      * Connects (subscribes) a specified notify function with a signal this module instance is offering.
00068      *
00069      * \exception WModuleSignalSubscriptionFailed thrown if the signal can't be connected.
00070      *
00071      * \param signal the signal to connect to.
00072      * \param notifier the notifier function to bind.
00073      *
00074      * \return the connection object. Disconnect manually if not needed anymore.
00075      */
00076      boost::signals2::connection subscribeSignal( MODULE_CONNECTOR_SIGNAL signal, t_GenericSignalHandlerType notifier );
00077 
00078     /**
00079      * Checks whether the specified connector is an input connector.
00080      *
00081      * \param con the connector to check against.
00082      *
00083      * \return true if compatible.
00084      */
00085     virtual bool connectable( boost::shared_ptr<WModuleConnector> con );
00086 
00087     /**
00088      * Returns the prototype of the WTransferable used in this connector.
00089      *
00090      * \return the prototype of the transfered type.
00091      */
00092     virtual boost::shared_ptr< WPrototyped > getTransferPrototype() = 0;
00093 
00094     /**
00095      * Gives back the currently set data as WTransferable.
00096      *
00097      * \return the data. If no data has been set: a NULL pointer is returned.
00098      */
00099     virtual const boost::shared_ptr< WTransferable > getRawData() const = 0;
00100 
00101     /**
00102      * Returns true if this instance is an WModuleInputConnector.
00103      *
00104      * \return true if castable to WModuleInputConnector.
00105      */
00106     virtual bool isInputConnector() const;
00107 
00108     /**
00109      * Returns true if this instance is an WModuleOutputConnector.
00110      *
00111      * \return true if castable to WModuleOutputConnector.
00112      */
00113     virtual bool isOutputConnector() const;
00114 
00115 protected:
00116 
00117     // If you want to add additional signals an output connector should subscribe FROM an input connector, overwrite
00118     // connectSignals
00119     // virtual void connectSignals( boost::shared_ptr<WModuleConnector> con );
00120 
00121     /**
00122      * Propagates the signal "DATA_CHANGED" to all connected items.
00123      */
00124     virtual void propagateDataChange();
00125 
00126 private:
00127 
00128     /**
00129      * Signal fired whenever new data should be propagated. Represented by DATA_CHANGED enum- element.
00130      */
00131     t_GenericSignalType signal_DataChanged;
00132 };
00133 
00134 #endif  // WMODULEOUTPUTCONNECTOR_H
00135 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends