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