00001 /*************************************************************************** 00002 tag: Peter Soetens Thu Oct 22 11:59:07 CEST 2009 InputPortInterface.hpp 00003 00004 InputPortInterface.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_INPUT_PORT_INTERFACE_HPP 00040 #define ORO_INPUT_PORT_INTERFACE_HPP 00041 00042 #include <string> 00043 #include "PortInterface.hpp" 00044 #include "ChannelElement.hpp" 00045 #include "../internal/rtt-internal-fwd.hpp" 00046 #include "../internal/ConnectionManager.hpp" 00047 #ifdef ORO_SIGNALLING_PORTS 00048 #include "../internal/Signal.hpp" 00049 #endif 00050 #include "../base/DataSourceBase.hpp" 00051 00052 namespace RTT 00053 { namespace base { 00054 00055 00060 class RTT_API InputPortInterface : public PortInterface 00061 { 00062 #ifdef ORO_SIGNALLING_PORTS 00063 public: 00064 typedef internal::Signal<void(PortInterface*)> NewDataOnPortEvent; 00065 typedef NewDataOnPortEvent::SlotFunction SlotFunction; 00066 #endif 00067 00068 protected: 00069 internal::ConnectionManager cmanager; 00070 ConnPolicy default_policy; 00071 #ifdef ORO_SIGNALLING_PORTS 00072 NewDataOnPortEvent* new_data_on_port_event; 00073 #else 00074 bool msignal_interface; 00078 void signal(); 00079 #endif 00080 00081 InputPortInterface(const InputPortInterface& orig); 00082 public: 00083 00084 InputPortInterface(std::string const& name, ConnPolicy const& default_policy = ConnPolicy()); 00085 00086 virtual ~InputPortInterface(); 00087 00091 void clear(); 00092 00093 ConnPolicy getDefaultPolicy() const; 00094 00095 virtual bool addConnection(internal::ConnID* port_id, ChannelElementBase::shared_ptr channel_input, ConnPolicy const& policy = ConnPolicy() ); 00096 00105 virtual bool removeConnection(internal::ConnID* cid); 00106 00110 virtual DataSourceBase* getDataSource() = 0; 00111 00117 virtual FlowStatus read(DataSourceBase::shared_ptr source, bool copy_old_data = true); 00118 00122 virtual void disconnect(); 00123 00127 virtual bool disconnect(PortInterface* port); 00128 00129 00131 virtual bool connected() const; 00132 00141 virtual bool channelReady(base::ChannelElementBase::shared_ptr channel); 00142 00143 #ifdef ORO_SIGNALLING_PORTS 00144 00147 NewDataOnPortEvent* getNewDataOnPortEvent(); 00148 #else 00149 00152 void signalInterface(bool true_false); 00153 #endif 00154 00155 virtual bool connectTo(PortInterface* other, ConnPolicy const& policy); 00156 00157 virtual bool connectTo(PortInterface* other); 00158 00159 virtual const internal::ConnectionManager* getManager() const { return &cmanager; } 00160 00166 virtual base::ChannelElementBase::shared_ptr buildRemoteChannelOutput( 00167 base::OutputPortInterface& output_port, 00168 types::TypeInfo const* type_info, 00169 base::InputPortInterface& input, const ConnPolicy& policy); 00170 00171 }; 00172 00173 }} 00174 00175 #endif