Ejemplo n.º 1
0
bool RemoteOutputPort::createConnection( RTT::base::InputPortInterface& sink, RTT::ConnPolicy const& policy )
{
    try {
        CConnPolicy cpolicy = toCORBA(policy);
        // first check if we're connecting to another remote:
        RemoteInputPort* rip = dynamic_cast<RemoteInputPort*>(&sink);
        if ( rip ){
            CDataFlowInterface_var cdfi = rip->getDataFlowInterface();
            if ( dataflow->createConnection( this->getName().c_str(), cdfi.in() , sink.getName().c_str(), cpolicy ) ) {
                policy.name_id = cpolicy.name_id;
                return true;
            } else
                return false;
        }
        // !!! only if sink is local:
        // this dynamic CDataFlowInterface lookup is tricky, we re/ab-use the DataFlowInterface pointer of sink !
        CDataFlowInterface_ptr cdfi = CDataFlowInterface_i::getRemoteInterface( sink.getInterface(), mpoa.in() );
        if ( dataflow->createConnection( this->getName().c_str(), cdfi , sink.getName().c_str(), cpolicy ) ) {
            policy.name_id = cpolicy.name_id;
            return true;
        }
    }
    catch(CORBA::Exception& e)
    {
        log(Error) <<"Remote call to "<< getName() <<".createConnection() failed with a CORBA exception: aborting connection."<<endlog();
        log(Error) << CORBA_EXCEPTION_INFO( e ) <<endlog();
        return false;
    }
	return false;
}
Ejemplo n.º 2
0
bool DataPool::Connection::addPort(RTT::base::PortInterface *port) {
  RTT::base::InputPortInterface *inputPort   = dynamic_cast<RTT::base::InputPortInterface *>(port);
  RTT::base::OutputPortInterface *outputPort = dynamic_cast<RTT::base::OutputPortInterface *>(port);

  if (inputPort) {
    if (readers.count(inputPort)) {
      RTT::log(RTT::Error) << "InputPort " << inputPort->getName() << " is already a member of this connection" << RTT::endlog();
      return false;
    }
    readers.insert(inputPort);
    this->internalOutputPort->connectTo(inputPort);
    for(std::set<RTT::base::OutputPortInterface *>::iterator it = writers.begin(); it != writers.end(); ++it) (*it)->connectTo(inputPort);
    return true;
  }

  if (outputPort) {
    if (writers.count(outputPort)) {
      RTT::log(RTT::Error) << "OutputPort " << outputPort->getName() << " is already a member of this connection" << RTT::endlog();
      return false;
    }
    writers.insert(outputPort);
    outputPort->connectTo(this->internalInputPort);
    for(std::set<RTT::base::InputPortInterface *>::iterator it = readers.begin(); it != readers.end(); ++it) outputPort->connectTo(*it);
    return true;
  }

  return false;
}