void copyPorts( ESMoL::Block inputBlock, ESMoL::Block outputBlock ) {

	PortVector portVector = inputBlock.Port_kind_children();
	for( PortVector::iterator ptvItr = portVector.begin() ; ptvItr != portVector.end() ; ++ptvItr ) {
		ESMoL::Port inputPort = *ptvItr;
		ESMoL::Port outputPort = UdmEngine::copy( inputPort, outputBlock  );
		if ( outputPort == Udm::null ) {
			std::cerr << "Warning: could not copy output port" << std::endl;
			return;
		}

		getPortList().push_back( inputPort );
		getPortMap().insert(  std::make_pair( inputPort, outputPort )  );

		ESMoL::TypeBaseRef inputTypeBaseRef = inputPort.TypeBaseRef_child();
		if ( inputTypeBaseRef != Udm::null ) {
			ESMoL::TypeBaseRef outputTypeBaseRef = ESMoL::TypeBaseRef::Create( outputPort );
			ESMoL::TypeBase inputTypeBase = inputTypeBaseRef.ref();
			if ( inputTypeBase != Udm::null ) {
				TypeBaseMap::iterator tbmItr = getTypeBaseMap().find( inputTypeBase );
				if ( tbmItr != getTypeBaseMap().end() ) {
					outputTypeBaseRef.name() = inputTypeBaseRef.name();
					outputTypeBaseRef.ref() = tbmItr->second;
				}
			}
		}

	}	
}
Beispiel #2
0
/** Find a port on this module. */
inline boost::shared_ptr<Port>
Module::get_port(const std::string& port_name) const
{
    PortComparator comp(port_name);
    PortVector::const_iterator i = std::find_if(_ports.begin(), _ports.end(), comp);
    return (i != _ports.end()) ? *i : boost::shared_ptr<Port>();
}