39 #include "../internal/Channels.hpp" 40 #include "../os/Atomic.hpp" 41 #include "../os/MutexLock.hpp" 42 #include <boost/lexical_cast.hpp> 71 if (!
addOutput(output, mandatory))
return false;
72 if (!output->addInput(
this)) {
82 if (this->output == output)
return true;
83 if (output && this->output)
return false;
91 if (!output || this->output == output) {
99 if (!input->addOutput(
this)) {
109 if (this->input == input)
return true;
110 if (input && this->input)
return false;
118 if (!input || this->input == input) {
141 if (!output->disconnect(
this,
true))
148 if (!input->disconnect(
this,
false))
160 return input ? input->getInputEndPoint() :
this;
166 return output ? output->getOutputEndPoint() :
this;
173 return output ? output->channelReady(
this, policy, conn_id) :
false;
180 return input ? input->inputReady(
this) :
false;
199 return output->signalFrom(
this);
218 return std::string();
220 return output->getLocalURI();
224 return std::string(boost::lexical_cast<std::string>(
this));
228 return std::string(
"ChannelElementBase");
236 if (!input)
return false;
238 assert(std::find(inputs.begin(), inputs.end(),
input) == inputs.end());
239 if (std::find(inputs.begin(), inputs.end(),
input) != inputs.end())
return false;
240 inputs.push_back(input);
246 inputs.remove(input);
252 return inputs.size() > 0;
258 for (Inputs::const_iterator it = inputs.begin(); it != inputs.end(); ++it) {
259 if (!(*it)->inputReady(
this))
return false;
261 return !inputs.empty();
267 for (Inputs::const_iterator it = inputs.begin(); it != inputs.end(); ++it) {
275 bool was_last =
false;
279 Inputs::iterator found = std::find(inputs.begin(), inputs.end(), channel);
280 if (found == inputs.end()) {
286 if (!input->disconnect(
this, forward)) {
292 was_last = inputs.empty();
296 if (was_last && forward) {
302 }
else if (!forward) {
305 for (Inputs::iterator it = inputs.begin(); it != inputs.end(); ) {
307 input->disconnect(
this,
false);
310 assert(inputs.empty());
326 , mandatory(mandatory)
327 , disconnected(false)
332 return (this->channel == channel);
337 if (!output)
return false;
347 outputs.remove_if(boost::bind(&Output::operator==, _1, output));
360 output->channel->signalFrom(
this);
368 for (Outputs::const_iterator it =
outputs.begin(); it !=
outputs.end(); ++it) {
369 if (!it->channel->channelReady(
this, policy, conn_id))
return false;
378 bool was_last =
false;
388 if (!output.
channel->disconnect(
this, forward)) {
398 if (was_last && !forward) {
408 for (Outputs::iterator it =
outputs.begin(); it !=
outputs.end(); ) {
410 output.
channel->disconnect(
this,
true);
422 for (Outputs::iterator it =
outputs.begin(); it !=
outputs.end(); ) {
425 output.
channel->disconnect(
this,
true);
452 }
else if (forward) {
virtual void removeInput(shared_ptr const &input)
virtual PortInterface * getPort() const
void removeDisconnectedOutputs()
virtual bool channelReady(ChannelElementBase::shared_ptr const &caller, ConnPolicy const &policy, internal::ConnID *conn_id=0)
virtual bool addInput(shared_ptr const &input)
virtual const ConnPolicy * getConnPolicy() const
Output(ChannelElementBase::shared_ptr const &channel, bool mandatory=true)
void RTT_API intrusive_ptr_add_ref(ChannelElementBase *e)
virtual bool isRemoteElement() const
virtual bool disconnect(ChannelElementBase::shared_ptr const &channel, bool forward=false)
bool operator==(ChannelElementBase::shared_ptr const &channel) const
virtual shared_ptr getInputEndPoint()
MultipleOutputsChannelElementBase()
virtual bool addOutput(shared_ptr const &output, bool mandatory=true)
virtual std::string getRemoteURI() const
virtual bool connectTo(ChannelElementBase::shared_ptr const &output, bool mandatory=true)
virtual void disconnect(bool forward)
ChannelElementBase::shared_ptr channel
void oro_atomic_inc(oro_atomic_t *a)
void ORO_ATOMIC_SETUP(oro_atomic_t *a, int n)
virtual std::string getLocalURI() const
virtual void removeOutput(ChannelElementBase::shared_ptr const &output)
void ORO_ATOMIC_CLEANUP(oro_atomic_t *a)
virtual bool addOutput(ChannelElementBase::shared_ptr const &output, bool mandatory=true)
boost::intrusive_ptr< ChannelElementBase > shared_ptr
int oro_atomic_dec_and_test(oro_atomic_t *a)
SharedMutexLock is a scope based Monitor, protecting critical sections with a SharedMutex object thro...
void RTT_API intrusive_ptr_release(ChannelElementBase *e)
virtual bool connectFrom(ChannelElementBase::shared_ptr const &input)
virtual bool channelReady(ChannelElementBase::shared_ptr const &caller, ConnPolicy const &policy, internal::ConnID *conn_id=0)
virtual bool inputReady()
virtual ~ChannelElementBase()
virtual void removeOutput(shared_ptr const &output)
virtual std::string getElementName() const
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
virtual shared_ptr getOutputEndPoint()
RTT::os::SharedMutex output_lock
RTT::os::SharedMutex outputs_lock
RTT::os::SharedMutex input_lock
MutexLock is a scope based Monitor, protecting critical sections with a Mutex object through locking ...