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 #include <string> 00026 00027 #include <boost/signals2/signal.hpp> 00028 #include <boost/signals2/connection.hpp> 00029 00030 #include "WModuleInputConnector.h" 00031 #include "WModuleConnectorSignals.h" 00032 00033 #include "WModuleOutputConnector.h" 00034 00035 WModuleOutputConnector::WModuleOutputConnector( boost::shared_ptr< WModule > module, std::string name, std::string description ): 00036 WModuleConnector( module, name, description ) 00037 { 00038 // initialize members 00039 } 00040 00041 WModuleOutputConnector::~WModuleOutputConnector() 00042 { 00043 // cleanup 00044 } 00045 00046 bool WModuleOutputConnector::connectable( boost::shared_ptr<WModuleConnector> con ) 00047 { 00048 // output connectors are just allowed to get connected with input connectors 00049 if( dynamic_cast<WModuleInputConnector*>( con.get() ) ) // NOLINT - since we really need them here 00050 { 00051 return true; 00052 } 00053 00054 return false; 00055 } 00056 00057 boost::signals2::connection WModuleOutputConnector::subscribeSignal( MODULE_CONNECTOR_SIGNAL signal, 00058 t_GenericSignalHandlerType notifier ) 00059 { 00060 // connect DataChanged signal 00061 switch( signal ) 00062 { 00063 case DATA_CHANGED: 00064 return signal_DataChanged.connect( notifier ); 00065 default: // we do not know this signal: maybe the base class knows it 00066 return WModuleConnector::subscribeSignal( signal, notifier ); 00067 } 00068 } 00069 00070 void WModuleOutputConnector::propagateDataChange() 00071 { 00072 signal_DataChanged( boost::shared_ptr<WModuleConnector>(), shared_from_this() ); 00073 } 00074 00075 bool WModuleOutputConnector::isInputConnector() const 00076 { 00077 return false; 00078 } 00079 00080 bool WModuleOutputConnector::isOutputConnector() const 00081 { 00082 return true; 00083 }