OpenWalnut  1.4.0
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 }
virtual ~WModuleOutputConnector()
Destructor.
virtual void propagateDataChange()
Propagates the signal "DATA_CHANGED" to all connected items.
boost::signals2::connection subscribeSignal(MODULE_CONNECTOR_SIGNAL signal, t_GenericSignalHandlerType notifier)
Connects (subscribes) a specified notify function with a signal this module instance is offering...
virtual bool isInputConnector() const
Returns true if this instance is an WModuleInputConnector.
virtual bool connectable(boost::shared_ptr< WModuleConnector > con)
Checks whether the specified connector is an input connector.
WModuleOutputConnector(boost::shared_ptr< WModule > module, std::string name="", std::string description="")
Constructor.
t_GenericSignalType signal_DataChanged
Signal fired whenever new data should be propagated.
Base class for modelling connections between kernel modules.
virtual boost::signals2::connection subscribeSignal(MODULE_CONNECTOR_SIGNAL signal, t_GenericSignalHandlerType notifier)
Connects a specified notify function with a signal this module instance is offering.
virtual bool isOutputConnector() const
Returns true if this instance is an WModuleOutputConnector.