Orocos Real-Time Toolkit
2.5.0
|
00001 /*************************************************************************** 00002 tag: Peter Soetens Thu Oct 22 11:59:08 CEST 2009 ConnOutputEndPoint.hpp 00003 00004 ConnOutputEndPoint.hpp - description 00005 ------------------- 00006 begin : Thu October 22 2009 00007 copyright : (C) 2009 Sylvain Joyeux 00008 email : sylvain.joyeux@m4x.org 00009 00010 *************************************************************************** 00011 * This library is free software; you can redistribute it and/or * 00012 * modify it under the terms of the GNU General Public * 00013 * License as published by the Free Software Foundation; * 00014 * version 2 of the License. * 00015 * * 00016 * As a special exception, you may use this file as part of a free * 00017 * software library without restriction. Specifically, if other files * 00018 * instantiate templates or use macros or inline functions from this * 00019 * file, or you compile this file and link it with other files to * 00020 * produce an executable, this file does not by itself cause the * 00021 * resulting executable to be covered by the GNU General Public * 00022 * License. This exception does not however invalidate any other * 00023 * reasons why the executable file might be covered by the GNU General * 00024 * Public License. * 00025 * * 00026 * This library is distributed in the hope that it will be useful, * 00027 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00028 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00029 * Lesser General Public License for more details. * 00030 * * 00031 * You should have received a copy of the GNU General Public * 00032 * License along with this library; if not, write to the Free Software * 00033 * Foundation, Inc., 59 Temple Place, * 00034 * Suite 330, Boston, MA 02111-1307 USA * 00035 * * 00036 ***************************************************************************/ 00037 00038 00039 #ifndef ORO_CONN_OUTPUT_ENDPOINT_HPP 00040 #define ORO_CONN_OUTPUT_ENDPOINT_HPP 00041 00042 #include "Channels.hpp" 00043 #include "ConnID.hpp" 00044 00045 namespace RTT 00046 { namespace internal { 00047 00056 template<typename T> 00057 class ConnOutputEndpoint : public base::ChannelElement<T> 00058 { 00059 InputPort<T>* port; 00060 ConnID* cid; 00061 public: 00070 ConnOutputEndpoint(InputPort<T>* port, ConnID* output_id ) 00071 : port(port), cid(output_id) 00072 { 00073 // cid is deleted/owned by the port's ConnectionManager. 00074 } 00075 00076 ~ConnOutputEndpoint() 00077 { 00078 } 00079 00087 bool inputReady() 00088 { 00089 // cid is deleted/owned by the ConnectionManager. 00090 port->addConnection(cid, this); 00091 return base::ChannelElement<T>::inputReady(); 00092 } 00093 00094 using base::ChannelElement<T>::write; 00095 00099 virtual bool write(typename base::ChannelElement<T>::param_t sample) 00100 { return false; } 00101 00102 virtual void disconnect(bool forward) 00103 { 00104 // Call the base class: it does the common cleanup 00105 base::ChannelElement<T>::disconnect(forward); 00106 00107 InputPort<T>* port = this->port; 00108 if (port && forward) 00109 { 00110 this->port = 0; 00111 port->removeConnection(cid); 00112 } 00113 } 00114 00115 virtual bool signal() 00116 { 00117 InputPort<T>* port = this->port; 00118 #ifdef ORO_SIGNALLING_PORTS 00119 if (port && port->new_data_on_port_event) 00120 (*port->new_data_on_port_event)(port); 00121 #else 00122 if (port ) 00123 port->signal(); 00124 #endif 00125 return true; 00126 } 00127 00128 virtual bool data_sample(typename base::ChannelElement<T>::param_t sample) 00129 { 00130 return true; 00131 } 00132 00133 virtual base::PortInterface* getPort() const { 00134 return this->port; 00135 } 00136 }; 00137 00138 }} 00139 00140 #endif 00141