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