Orocos Real-Time Toolkit
2.6.0
|
00001 /*************************************************************************** 00002 tag: Peter Soetens Thu Oct 22 11:59:07 CEST 2009 RemotePorts.hpp 00003 00004 RemotePorts.hpp - description 00005 ------------------- 00006 begin : Thu October 22 2009 00007 copyright : (C) 2009 Peter Soetens 00008 email : peter@thesourcworks.com 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 RTT_CORBA_REMOTE_PORTS_HPP 00040 #define RTT_CORBA_REMOTE_PORTS_HPP 00041 00042 #include "../../base/PortInterface.hpp" 00043 #include "../../base/ChannelElement.hpp" 00044 #include "../../InputPort.hpp" 00045 #include "../../OutputPort.hpp" 00046 #include "DataFlowI.h" 00047 #include <cassert> 00048 00049 namespace RTT { 00050 namespace corba { 00061 template<typename PortClass> 00062 class RemotePort : public PortClass 00063 { 00064 protected: 00065 types::TypeInfo const* type_info; 00066 CDataFlowInterface_var dataflow; 00067 PortableServer::POA_var mpoa; 00068 00069 bool connectionAdded( base::ChannelElementBase::shared_ptr channel, ConnPolicy const& policy ) { assert(false && "Can/Should not add connection to remote port object !");return false; } 00070 00071 public: 00072 RemotePort(types::TypeInfo const* type_info, 00073 CDataFlowInterface_ptr dataflow, 00074 std::string const& name, 00075 PortableServer::POA_ptr poa); 00076 00077 PortableServer::POA_ptr _default_POA(); 00078 CDataFlowInterface_ptr getDataFlowInterface() const; 00079 00080 internal::ConnID* getPortID() const; 00081 00082 types::TypeInfo const* getTypeInfo() const; 00083 int serverProtocol() const; 00084 bool connected() const; 00085 bool createStream( const ConnPolicy& policy ); 00086 virtual bool addConnection(internal::ConnID* port_id, base::ChannelElementBase::shared_ptr channel_input, ConnPolicy const& policy); 00087 void disconnect(); 00088 bool disconnect(base::PortInterface* p); 00089 }; 00090 00096 class RemoteOutputPort 00097 : public RemotePort<base::OutputPortInterface> 00098 { 00099 public: 00100 RemoteOutputPort(types::TypeInfo const* type_info, 00101 CDataFlowInterface_ptr dataflow, 00102 std::string const& name, 00103 PortableServer::POA_ptr poa); 00104 00105 bool keepsLastWrittenValue() const; 00106 void keepLastWrittenValue(bool new_flag); 00107 00108 using base::OutputPortInterface::createConnection; 00109 bool createConnection( base::InputPortInterface& sink, ConnPolicy const& policy ); 00110 00111 virtual base::DataSourceBase::shared_ptr getDataSource() const; 00112 00113 base::PortInterface* clone() const; 00114 base::PortInterface* antiClone() const; 00115 }; 00116 00123 class RemoteInputPort 00124 : public RemotePort<base::InputPortInterface> 00125 { 00126 typedef std::map<base::ChannelElementBase*,RTT::corba::CChannelElement_var> ChannelMap; 00127 ChannelMap channel_map; 00128 protected: 00136 virtual bool addConnection(internal::ConnID* port_id, base::ChannelElementBase::shared_ptr channel_input, ConnPolicy const& policy) { return true; } 00137 public: 00138 RemoteInputPort(types::TypeInfo const* type_info, 00139 CDataFlowInterface_ptr dataflow, 00140 std::string const& name, 00141 PortableServer::POA_ptr poa); 00142 00155 base::ChannelElementBase::shared_ptr buildRemoteChannelOutput( 00156 base::OutputPortInterface& output_port, 00157 types::TypeInfo const* type, 00158 base::InputPortInterface& reader_, 00159 ConnPolicy const& policy); 00160 00161 base::PortInterface* clone() const; 00162 base::PortInterface* antiClone() const; 00163 00164 base::DataSourceBase* getDataSource(); 00165 00173 virtual bool channelReady(base::ChannelElementBase::shared_ptr channel); 00174 }; 00175 } 00176 } 00177 00178 #endif 00179