Orocos Real-Time Toolkit  2.8.3
ConnOutputEndPoint.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Thu Oct 22 11:59:08 CEST 2009 ConnOutputEndPoint.hpp
3 
4  ConnOutputEndPoint.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_CONN_OUTPUT_ENDPOINT_HPP
40 #define ORO_CONN_OUTPUT_ENDPOINT_HPP
41 
42 #include "Channels.hpp"
43 #include "ConnID.hpp"
44 
45 namespace RTT
46 { namespace internal {
47 
56  template<typename T>
58  {
59  InputPort<T>* port;
60  ConnID* cid;
61  public:
71  : port(port), cid(output_id)
72  {
73  // cid is deleted/owned by the port's ConnectionManager.
74  }
75 
77  {
78  }
79 
87  bool inputReady()
88  {
90  }
91 
93 
97  virtual bool write(typename base::ChannelElement<T>::param_t sample)
98  { return false; }
99 
100  virtual void disconnect(bool forward)
101  {
102  // Call the base class: it does the common cleanup
104 
105  InputPort<T>* port = this->port;
106  if (port && forward)
107  {
108  this->port = 0;
109  port->removeConnection(cid);
110  }
111  }
112 
113  virtual bool signal()
114  {
115  InputPort<T>* port = this->port;
116 #ifdef ORO_SIGNALLING_PORTS
117  if (port && port->new_data_on_port_event)
118  (*port->new_data_on_port_event)(port);
119 #else
120  if (port )
121  port->signal();
122 #endif
123  return true;
124  }
125 
126  virtual bool data_sample(typename base::ChannelElement<T>::param_t sample)
127  {
128  return true;
129  }
130 
131  virtual base::PortInterface* getPort() const {
132  return this->port;
133  }
134 
135  virtual ConnID* getConnID() const {
136  return this->cid;
137  }
138 
139  std::string getElementName() const {
140  return std::string("ConnOutputEndpoint");
141  }
142 
143  };
144 
145 }}
146 
147 #endif
148 
ConnOutputEndpoint(InputPort< T > *port, ConnID *output_id)
Creates the connection end that represents the output and attach it to the input. ...
boost::call_traits< T >::param_type param_t
virtual ConnID * getConnID() const
Gets the Connection ID of this channel.
virtual bool write(typename base::ChannelElement< T >::param_t sample)
Writes a new sample on this connection This should never be called, as all connections are supposed t...
This is a channel element that represents the output endpoint of a connection, i.e.
virtual bool removeConnection(internal::ConnID *cid)
Removes the input channel.
std::string getElementName() const
Returns the class name of this element.
A component&#39;s data input port.
Definition: InputPort.hpp:63
virtual bool signal()
Signals that there is new data available on this channel By default, the channel element forwards the...
virtual base::PortInterface * getPort() const
Gets the port this channel element is connected to.
virtual bool data_sample(typename base::ChannelElement< T >::param_t sample)
virtual void disconnect(bool forward)
Performs a disconnection of this channel&#39;s endpoints.
virtual void disconnect(bool forward)
Performs a disconnection of this channel&#39;s endpoints.
A typed version of ChannelElementBase.
void signal()
The ConnOutputEndpoint signals that new data is available.
virtual bool inputReady()
This is called by an input port when it is ready to receive data.
This class is used in places where a permanent representation of a reference to a connection is neede...
Definition: ConnID.hpp:58
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:51
The base class of every data flow port.
bool inputReady()
Called by the connection factory to check that the connection is properly set up. ...