void copyDataflows( ESMoL::ModelsFolder inputModelsFolder, ESMoL::ModelsFolder outputModelsFolder ) { getPortList().clear(); getPortMap().clear(); DataflowVector dataflowVector = inputModelsFolder.Dataflow_kind_children(); for( DataflowVector::iterator dfvItr = dataflowVector.begin() ; dfvItr != dataflowVector.end() ; ++dfvItr ) { ESMoL::Dataflow inputDataflow = *dfvItr; ESMoL::Dataflow outputDataflow = ESMoL::Dataflow::Create( outputModelsFolder ); outputDataflow.name() = inputDataflow.name(); copySubsystems_flatten( inputDataflow, outputDataflow ); } for( PortList::iterator ptlItr = getPortList().begin() ; ptlItr != getPortList().end() ; ++ptlItr ) { ESMoL::Port inputDstPort = *ptlItr; LineSet lineSet = inputDstPort.srcLine(); if ( lineSet.empty() ) continue; ESMoL::Line line = *lineSet.begin(); ESMoL::Port inputSrcPort = line.srcLine_end(); lineSet = inputSrcPort.srcLine(); while( getPortMap().find( inputSrcPort ) == getPortMap().end() && !lineSet.empty() ) { line = *lineSet.begin(); inputSrcPort = line.srcLine_end(); lineSet = inputSrcPort.srcLine(); } PortMap::iterator ptmItr = getPortMap().find( inputDstPort ); if ( ptmItr == getPortMap().end() ) { std::cerr << "Warning: port not in PortMap" << std::endl; continue; } ESMoL::Port outputDstPort = ptmItr->second; ptmItr = getPortMap().find( inputSrcPort ); if ( ptmItr == getPortMap().end() ) { std::cerr << "Warning: port not in PortMap" << std::endl; continue; } ESMoL::Port outputSrcPort = ptmItr->second; Udm::Object lineParent = outputSrcPort.GetParent(); if ( Udm::IsDerivedFrom( outputSrcPort.type(), ESMoL::OutPort::meta ) ) lineParent = lineParent.GetParent(); ESMoL::Line outputLine = ESMoL::Line::Create( lineParent ); outputLine.srcLine_end() = outputSrcPort; outputLine.dstLine_end() = outputDstPort; } }