00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <string>
00026
00027 #include "../WModuleFactory.h"
00028
00029 #include "WApplyCombiner.h"
00030
00031 WApplyCombiner::WApplyCombiner( boost::shared_ptr< WModuleContainer > target,
00032 boost::shared_ptr< WModule > srcModule, std::string srcConnector,
00033 boost::shared_ptr< WModule > targetModule, std::string targetConnector ):
00034 WModuleOneToOneCombiner( target, srcModule, srcConnector, targetModule, targetConnector )
00035 {
00036 }
00037
00038 WApplyCombiner::WApplyCombiner( boost::shared_ptr< WModule > srcModule, std::string srcConnector,
00039 boost::shared_ptr< WModule > targetModule, std::string targetConnector ):
00040 WModuleOneToOneCombiner( srcModule, srcConnector, targetModule, targetConnector )
00041 {
00042 }
00043
00044 WApplyCombiner::~WApplyCombiner()
00045 {
00046
00047 }
00048
00049 void WApplyCombiner::apply()
00050 {
00051
00052 boost::shared_ptr< WModule > srcModule = m_srcModule;
00053 boost::shared_ptr< WModule > targetModule = m_targetModule;
00054
00055
00056 if( srcModule && WModuleFactory::isPrototype( srcModule ) )
00057 {
00058 srcModule = WModuleFactory::getModuleFactory()->create( m_srcModule );
00059 }
00060
00061
00062 if( targetModule && WModuleFactory::isPrototype( targetModule ) )
00063 {
00064 targetModule = WModuleFactory::getModuleFactory()->create( m_targetModule );
00065 }
00066
00067
00068
00069
00070 m_container->add( srcModule );
00071 m_container->add( targetModule );
00072
00073
00074 if( srcModule )
00075 {
00076 srcModule->isReadyOrCrashed().wait();
00077 if( srcModule->isCrashed()() )
00078 {
00079
00080 wlog::error( "Prototype Combiner" ) << "The source module \"" << srcModule->getName() << "\" has crashed. Abort.";
00081 return;
00082 }
00083 }
00084
00085
00086 if( targetModule )
00087 {
00088 targetModule->isReadyOrCrashed().wait();
00089 if( targetModule->isCrashed()() )
00090 {
00091
00092 wlog::error( "Prototype Combiner" ) << "The target module \"" << targetModule->getName() << "\" has crashed. Abort.";
00093 return;
00094 }
00095 }
00096
00097
00098 if( ( m_srcConnector.empty() ) || ( m_targetConnector.empty() ) )
00099 {
00100 return;
00101 }
00102
00103
00104 if( srcModule && targetModule )
00105 {
00106 targetModule->getInputConnector( m_targetConnector )->disconnectAll();
00107 targetModule->getInputConnector( m_targetConnector )->connect( srcModule->getOutputConnector( m_srcConnector ) );
00108 }
00109 }
00110