OpenWalnut  1.4.0
WDisconnectCombiner.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 "WDisconnectCombiner.h"
28 
29 WDisconnectCombiner::WDisconnectCombiner( boost::shared_ptr< WModuleContainer > target,
30  boost::shared_ptr< WModule > srcModule, std::string srcConnector,
31  boost::shared_ptr< WModule > targetModule, std::string targetConnector ):
32  WModuleOneToOneCombiner( target, srcModule, srcConnector, targetModule, targetConnector )
33 {
34 }
35 
36 WDisconnectCombiner::WDisconnectCombiner( boost::shared_ptr< WModule > srcModule, std::string srcConnector,
37  boost::shared_ptr< WModule > targetModule, std::string targetConnector ):
38  WModuleOneToOneCombiner( srcModule, srcConnector, targetModule, targetConnector )
39 {
40 }
41 
42 WDisconnectCombiner::WDisconnectCombiner( boost::shared_ptr< WModuleConnector > srcConnector,
43  boost::shared_ptr< WModuleConnector > targetConnector ):
44  WModuleOneToOneCombiner( srcConnector->getModule(), srcConnector->getName(), targetConnector->getModule(), targetConnector->getName() )
45 {
46 }
47 
49 {
50  // cleanup
51 }
52 
54 {
55  // get first connector
56  boost::shared_ptr< WModuleConnector > c1 = m_srcModule->findConnector( m_srcConnector );
57  boost::shared_ptr< WModuleConnector > c2 = m_targetModule->findConnector( m_targetConnector );
58 
59  // check if they really existed
60  if( !c1 || !c2 )
61  {
62  return;
63  }
64 
65  // and do it
66  c1->disconnect( c2 );
67 }
68 
virtual void apply()
Disconnects the specified connection.
WDisconnectCombiner(boost::shared_ptr< WModuleContainer > target, boost::shared_ptr< WModule > srcModule, std::string srcConnector, boost::shared_ptr< WModule > targetModule, std::string targetConnector)
Creates a combiner which disconnects the specified connection.
boost::shared_ptr< WModule > m_targetModule
The module/prototype to connect with m_srcMdodule.
std::string m_targetConnector
The input connector the target module to connect with m_srcConnector.
virtual ~WDisconnectCombiner()
Destructor.
std::string m_srcConnector
The output connector of m_srcModule to connect with m_targetConnector.
boost::shared_ptr< WModule > m_srcModule
The source module to connect with the target.
Base class for all combiners which apply one connection between two connectors of two modules...