ChannelElementBase.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Thu Oct 22 11:59:07 CEST 2009 ChannelElementBase.hpp
3 
4  ChannelElementBase.hpp - description
5  -------------------
6  begin : Thu October 22 2009
7  copyright : (C) 2009 Sylvain Joyeux
8  email : sylvain.joyeux@m4x.org
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
39 #ifndef ORO_CHANNEL_BASE_HPP
40 #define ORO_CHANNEL_BASE_HPP
41 
42 #include "../os/oro_arch.h"
43 #include <utility>
44 #include <boost/intrusive_ptr.hpp>
45 #include <boost/call_traits.hpp>
46 
47 #include "../rtt-fwd.hpp"
48 #include "rtt-base-fwd.hpp"
49 #include "../internal/rtt-internal-fwd.hpp"
50 #include "../BufferPolicy.hpp"
51 #include "../os/Mutex.hpp"
52 
53 #include <list>
54 #include <map>
55 
56 namespace RTT { namespace base {
57 
65  class RTT_API ChannelElementBase
66  {
67  public:
68  typedef boost::intrusive_ptr<ChannelElementBase> shared_ptr;
69 
70  private:
72  friend void RTT_API intrusive_ptr_add_ref( ChannelElementBase* e );
73  friend void RTT_API intrusive_ptr_release( ChannelElementBase* e );
74 
75  protected:
76  shared_ptr input;
77  shared_ptr output;
78 
81 
82  protected:
84  void ref();
87  void deref();
88 
89  public:
96  virtual ~ChannelElementBase();
97 
101  template <typename T> static ChannelElement<T> *narrow(ChannelElementBase *e)
102  {
103  return dynamic_cast<ChannelElement<T> *>(e);
104  }
105 
109  template <typename T> ChannelElement<T> *narrow()
110  {
111  return dynamic_cast<ChannelElement<T> *>(this);
112  }
113 
121  shared_ptr getInput();
122 
129  virtual shared_ptr getInputEndPoint();
130 
131 
135  shared_ptr getOutput();
136 
143  virtual shared_ptr getOutputEndPoint();
144 
150  virtual bool connectTo(ChannelElementBase::shared_ptr const& output, bool mandatory = true);
151 
156  virtual bool connectFrom(ChannelElementBase::shared_ptr const& input);
157 
161  virtual bool connected();
162 
168  virtual bool signal();
169 
173  virtual bool signalFrom(ChannelElementBase *) { return signal(); }
174 
186  virtual bool channelReady(ChannelElementBase::shared_ptr const& caller, ConnPolicy const& policy, internal::ConnID *conn_id = 0);
187 
195  virtual bool inputReady(ChannelElementBase::shared_ptr const& caller);
196 
203  virtual void clear();
204 
209  virtual void disconnect(bool forward);
210 
221  virtual bool disconnect(ChannelElementBase::shared_ptr const& channel, bool forward);
222 
228  virtual PortInterface* getPort() const;
229 
236  virtual const ConnPolicy* getConnPolicy() const;
237 
238  RTT_DEPRECATED void setOutput(const ChannelElementBase::shared_ptr &output)
239  {
240  assert(false && "ChannelElementBase::setOutput() is deprecated! You should use ChannelElementBase::connectTo() instead.");
241  (void) connectTo(output);
242  }
243 
244  RTT_DEPRECATED void setInput(const ChannelElementBase::shared_ptr &input)
245  {
246  assert(false && "ChannelElementBase::setInput() is deprecated! You should use ChannelElementBase::addInput() instead.");
247  (void) addInput(input);
248  }
249 
258  virtual bool isRemoteElement() const;
259 
270  virtual std::string getRemoteURI() const;
271 
277  virtual std::string getLocalURI() const;
278 
286  virtual std::string getElementName() const;
287 
288  protected:
291 
298  virtual bool addOutput(shared_ptr const& output, bool mandatory = true);
299 
304  virtual void removeOutput(shared_ptr const& output);
305 
311  virtual bool addInput(shared_ptr const& input);
312 
317  virtual void removeInput(shared_ptr const& input);
318 
319  private:
325  virtual bool inputReady();
326  };
327 
332  {
333  public:
334  typedef boost::intrusive_ptr<MultipleInputsChannelElementBase> shared_ptr;
335  typedef std::list<ChannelElementBase::shared_ptr> Inputs;
336 
337  protected:
338  Inputs inputs;
340 
341  public:
343 
348  virtual bool connected();
349 
354  virtual bool inputReady(ChannelElementBase::shared_ptr const& caller);
355 
360  virtual void clear();
361 
363 
367  virtual bool disconnect(ChannelElementBase::shared_ptr const& channel, bool forward = true);
368 
372  bool signalFrom(ChannelElementBase *caller);
373 
374  protected:
380  virtual bool addInput(ChannelElementBase::shared_ptr const& input);
381 
386  virtual void removeInput(ChannelElementBase::shared_ptr const& input);
387  };
388 
393  {
394  public:
395  typedef boost::intrusive_ptr<MultipleOutputsChannelElementBase> shared_ptr;
396  struct Output {
397  Output(ChannelElementBase::shared_ptr const &channel, bool mandatory = true);
398  bool operator==(ChannelElementBase::shared_ptr const& channel) const;
400  bool mandatory;
402  };
403  typedef std::list<Output> Outputs;
404 
405  protected:
406  Outputs outputs;
408 
409  public:
411 
416  virtual bool connected();
417 
422  virtual bool signal();
423 
428  virtual bool channelReady(ChannelElementBase::shared_ptr const& caller, ConnPolicy const& policy, internal::ConnID *conn_id = 0);
429 
431 
435  virtual bool disconnect(ChannelElementBase::shared_ptr const& channel, bool forward = false);
436 
437  protected:
444  virtual bool addOutput(ChannelElementBase::shared_ptr const& output, bool mandatory = true);
445 
450  virtual void removeOutput(ChannelElementBase::shared_ptr const& output);
451 
456  void removeDisconnectedOutputs();
457  };
458 
463  {
464  public:
465  typedef boost::intrusive_ptr<MultipleInputsMultipleOutputsChannelElementBase> shared_ptr;
466 
470  virtual bool connected();
471 
473 
477  virtual bool disconnect(ChannelElementBase::shared_ptr const& channel, bool forward);
478  };
479 
480  void RTT_API intrusive_ptr_add_ref( ChannelElementBase* e );
481  void RTT_API intrusive_ptr_release( ChannelElementBase* e );
482 
483 }}
484 
485 #endif
486 
RTT_DEPRECATED void setInput(const ChannelElementBase::shared_ptr &input)
void RTT_API intrusive_ptr_add_ref(ChannelElementBase *e)
boost::intrusive_ptr< MultipleOutputsChannelElementBase > shared_ptr
static ChannelElement< T > * narrow(ChannelElementBase *e)
virtual void disconnect(bool forward)
std::list< ChannelElementBase::shared_ptr > Inputs
boost::intrusive_ptr< MultipleInputsChannelElementBase > shared_ptr
RTT_DEPRECATED void setOutput(const ChannelElementBase::shared_ptr &output)
An object oriented wrapper around a shared mutex (multiple readers allowed, but only one writer with ...
Definition: Mutex.hpp:346
boost::intrusive_ptr< MultipleInputsMultipleOutputsChannelElementBase > shared_ptr
static bool operator==(const ConnPolicy &, const ConnPolicy &)
Definition: corba_test.cpp:227
boost::intrusive_ptr< ChannelElementBase > shared_ptr
void RTT_API intrusive_ptr_release(ChannelElementBase *e)
ChannelElement< T > * narrow()
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
virtual bool signalFrom(ChannelElementBase *)


rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:31