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