39 #ifndef ORO_CHANNEL_ELEMENT_HPP 40 #define ORO_CHANNEL_ELEMENT_HPP 42 #include <boost/intrusive_ptr.hpp> 43 #include <boost/call_traits.hpp> 45 #include "../ConnPolicy.hpp" 46 #include "../FlowStatus.hpp" 47 #include "../os/MutexLock.hpp" 49 #include <boost/bind.hpp> 51 namespace RTT {
namespace base {
61 typedef boost::intrusive_ptr< ChannelElement<T> >
shared_ptr;
63 typedef typename boost::call_traits<T>::param_type
param_t;
64 typedef typename boost::call_traits<T>::reference
reference_t;
109 return output->
write(sample);
122 return input->
read(sample, copy_old_data);
134 typedef boost::intrusive_ptr< MultipleInputsChannelElement<T> >
shared_ptr;
174 if ( !last && !inputs.empty() ) last = inputs.front()->template narrow<T>();
189 if (tresult > result)
203 template<
typename Pred>
204 void select_reader_channel(Pred pred,
bool copy_old_data) {
206 find_if(pred, copy_old_data);
213 last = new_input.get();
217 template<
typename Pred>
225 if ( pred( copy_old_data, current ) )
228 for (Inputs::iterator it = inputs.begin(); it != inputs.end(); ++it) {
229 if (*it == current)
continue;
232 if ( pred(
false, input) ==
true)
242 if (last == input) last = 0;
256 typedef boost::intrusive_ptr< MultipleInputsChannelElement<T> >
shared_ptr;
264 bool at_least_one_output_is_disconnected =
false;
265 bool at_least_one_output_is_connected =
false;
270 for(Outputs::iterator it = outputs.begin(); it != outputs.end(); ++it)
274 if (result < fs) result = fs;
276 it->disconnected =
true;
277 at_least_one_output_is_disconnected =
true;
279 at_least_one_output_is_connected =
true;
284 if (at_least_one_output_is_disconnected) {
285 removeDisconnectedOutputs();
286 if (!at_least_one_output_is_connected) result =
NotConnected;
300 bool at_least_one_output_is_disconnected =
false;
301 bool at_least_one_output_is_connected =
false;
306 for(Outputs::iterator it = outputs.begin(); it != outputs.end(); ++it)
310 if (it->mandatory && (result < fs)) result = fs;
312 it->disconnected =
true;
313 at_least_one_output_is_disconnected =
true;
315 at_least_one_output_is_connected =
true;
320 if (at_least_one_output_is_disconnected) {
321 removeDisconnectedOutputs();
322 if (!at_least_one_output_is_connected) result =
NotConnected;
335 typedef boost::intrusive_ptr< MultipleInputsMultipleOutputsChannelElement<T> >
shared_ptr;
boost::call_traits< T >::param_type param_t
boost::intrusive_ptr< ChannelElement< T > > shared_ptr
ChannelElementBase variant with multiple output channels.
FlowStatus
Returns the status of a data flow read operation.
ChannelElement< T >::value_t value_t
ChannelElement< T >::param_t param_t
boost::intrusive_ptr< MultipleInputsChannelElement< T > > shared_ptr
ChannelElement< T >::reference_t reference_t
shared_ptr getInput()
Returns the current input channel element.
static ChannelElement< T > * narrow(ChannelElementBase *e)
Return a pointer to the typed instance of a ChannelElementBase.
A typed version of ChannelElementBase.
virtual FlowStatus read(reference_t sample, bool copy_old_data=true)
Reads a sample from the connection.
virtual WriteStatus write(param_t sample)
Writes a new sample on this connection.
A typed version of MultipleOutputsChannelElementBase.
boost::call_traits< T >::reference reference_t
virtual value_t data_sample()
boost::intrusive_ptr< ChannelElementBase > shared_ptr
SharedMutexLock is a scope based Monitor, protecting critical sections with a SharedMutex object thro...
virtual WriteStatus data_sample(param_t sample, bool reset=true)
Provides a data sample to initialize this connection.
virtual WriteStatus write(param_t sample)
Writes a new sample on this connection.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
In the data flow implementation, a channel is created by chaining ChannelElementBase objects...
shared_ptr getOutput()
Returns the next channel element in the channel's propagation direction.
WriteStatus
Returns the status of a data flow write operation.
virtual WriteStatus data_sample(param_t sample, bool reset=true)
Provides a data sample to initialize this connection.