OpenWalnut  1.3.1
WModuleOutputConnector.cpp
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 #include <string>
26 
27 #include <boost/signals2/signal.hpp>
28 #include <boost/signals2/connection.hpp>
29 
30 #include "WModuleInputConnector.h"
31 #include "WModuleConnectorSignals.h"
32 
33 #include "WModuleOutputConnector.h"
34 
35 WModuleOutputConnector::WModuleOutputConnector( boost::shared_ptr< WModule > module, std::string name, std::string description ):
36  WModuleConnector( module, name, description )
37 {
38  // initialize members
39 }
40 
42 {
43  // cleanup
44 }
45 
46 bool WModuleOutputConnector::connectable( boost::shared_ptr<WModuleConnector> con )
47 {
48  // output connectors are just allowed to get connected with input connectors
49  if( dynamic_cast<WModuleInputConnector*>( con.get() ) ) // NOLINT - since we really need them here
50  {
51  return true;
52  }
53 
54  return false;
55 }
56 
57 boost::signals2::connection WModuleOutputConnector::subscribeSignal( MODULE_CONNECTOR_SIGNAL signal,
58  t_GenericSignalHandlerType notifier )
59 {
60  // connect DataChanged signal
61  switch( signal )
62  {
63  case DATA_CHANGED:
64  return signal_DataChanged.connect( notifier );
65  default: // we do not know this signal: maybe the base class knows it
66  return WModuleConnector::subscribeSignal( signal, notifier );
67  }
68 }
69 
71 {
72  signal_DataChanged( boost::shared_ptr<WModuleConnector>(), shared_from_this() );
73 }
74 
76 {
77  return false;
78 }
79 
81 {
82  return true;
83 }