ConnOutputEndPoint.hpp
Go to the documentation of this file.
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             return base::ChannelElement<T>::inputReady();
00090         }
00091 
00092         using base::ChannelElement<T>::write;
00093 
00097         virtual bool write(typename base::ChannelElement<T>::param_t sample)
00098         { return false; }
00099 
00100         virtual void disconnect(bool forward)
00101         {
00102             // Call the base class: it does the common cleanup
00103             base::ChannelElement<T>::disconnect(forward);
00104 
00105             InputPort<T>* port = this->port;
00106             if (port && forward)
00107             {
00108                 this->port = 0;
00109                 port->removeConnection(cid);
00110             }
00111         }
00112 
00113         virtual bool signal()
00114         {
00115             InputPort<T>* port = this->port;
00116 #ifdef ORO_SIGNALLING_PORTS
00117             if (port && port->new_data_on_port_event)
00118                 (*port->new_data_on_port_event)(port);
00119 #else
00120             if (port )
00121                 port->signal();
00122 #endif
00123             return true;
00124         }
00125 
00126         virtual bool data_sample(typename base::ChannelElement<T>::param_t sample)
00127         {
00128             return true;
00129         }
00130 
00131         virtual base::PortInterface* getPort() const {
00132             return this->port;
00133         }
00134 
00135         virtual ConnID* getConnID() const { 
00136             return this->cid; 
00137         }
00138     };
00139 
00140 }}
00141 
00142 #endif
00143 


rtt
Author(s): RTT Developers
autogenerated on Sat Jun 8 2019 18:46:06