Exemplo n.º 1
0
        virtual bool connectionAdded( base::ChannelElementBase::shared_ptr channel_input, ConnPolicy const& policy ) {
            // Initialize the new channel with last written data if requested
            // (and available)

            // This this the input channel element of the whole connection
            typename base::ChannelElement<T>::shared_ptr channel_el_input =
                static_cast< base::ChannelElement<T>* >(channel_input.get());


            if (written)
            {
                typename internal::AssignableDataSource<T>::shared_ptr last_written_value = this->last_written_value;
                if (last_written_value)
                {
                    T sample = last_written_value->get();
                    if ( channel_el_input->data_sample(sample) ) {
                        if ( policy.init )
                            return channel_el_input->write(sample);
                        return true;
                    } else {
                        Logger::In in("OutputPort");
                        log(Error) << "Failed to pass data sample to data channel. Aborting connection."<<endlog();
                        return false;
                    }
                }
            }
            // even if we're not written, test the connection with a default sample.
            return channel_el_input->data_sample( T() );
        }
Exemplo n.º 2
0
 virtual bool inputReady() {
     if ( mqReady(read_sample, this) ) {
         typename base::ChannelElement<T>::shared_ptr output =
             this->getOutput();
         assert(output);
         output->data_sample(read_sample->rvalue());
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 bool do_init(typename base::ChannelElement<T>::param_t sample, const internal::ConnectionManager::ChannelDescriptor& descriptor)
 {
     typename base::ChannelElement<T>::shared_ptr output
         = boost::static_pointer_cast< base::ChannelElement<T> >(descriptor.get<1>());
     if (output->data_sample(sample))
         return false;
     else
     {
         log(Error) << "A channel of port " << getName() << " has been invalidated during setDataSample(), it will be removed" << endlog();
         return true;
     }
 }