Orocos Real-Time Toolkit
2.6.0
|
00001 /*************************************************************************** 00002 tag: FMTC do nov 2 13:06:20 CET 2006 DataFlowI.h 00003 00004 DataFlowI.h - description 00005 ------------------- 00006 begin : do november 02 2006 00007 copyright : (C) 2006 FMTC 00008 email : peter.soetens@fmtc.be 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 #ifndef DATAFLOWI_H_ 00039 #define DATAFLOWI_H_ 00040 00041 #include "corba.h" 00042 #ifdef CORBA_IS_TAO 00043 #include "DataFlowS.h" 00044 #else 00045 #include "DataFlowC.h" 00046 #endif 00047 #include "CorbaConversion.hpp" 00048 #include "../../base/ChannelElement.hpp" 00049 #include "../../internal/DataSources.hpp" 00050 #include "CorbaTypeTransporter.hpp" 00051 #include <list> 00052 #include <rtt/os/Mutex.hpp> 00053 00054 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00055 #pragma once 00056 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00057 00058 00059 namespace RTT { 00060 00061 namespace corba { 00062 class CDataFlowInterface_i; 00063 00069 class RTT_CORBA_API CRemoteChannelElement_i 00070 : public POA_RTT::corba::CRemoteChannelElement 00071 , public virtual PortableServer::RefCountServantBase 00072 { 00073 protected: 00074 CRemoteChannelElement_var remote_side; 00075 RTT::corba::CorbaTypeTransporter const& transport; 00076 PortableServer::POA_var mpoa; 00077 CDataFlowInterface_i* mdataflow; 00078 00079 public: 00080 // standard constructor 00081 CRemoteChannelElement_i(corba::CorbaTypeTransporter const& transport, 00082 PortableServer::POA_ptr poa); 00083 virtual ~CRemoteChannelElement_i(); 00084 00085 virtual RTT::corba::CRemoteChannelElement_ptr activate_this() { 00086 PortableServer::ObjectId_var oid = mpoa->activate_object(this); // ref count=2 00087 _remove_ref(); // ref count=1 00088 return _this(); 00089 } 00090 00091 virtual void transferSamples() = 0; 00092 00093 void setCDataFlowInterface(CDataFlowInterface_i* dataflow) { 00094 mdataflow = dataflow; 00095 } 00096 00097 PortableServer::POA_ptr _default_POA(); 00098 00099 void setRemoteSide(CRemoteChannelElement_ptr remote) ACE_THROW_SPEC (( 00100 CORBA::SystemException 00101 )); 00102 }; 00103 00111 class RTT_CORBA_API CDataFlowInterface_i 00112 : public virtual POA_RTT::corba::CDataFlowInterface 00113 { 00114 DataFlowInterface* mdf; 00115 PortableServer::POA_var mpoa; 00116 00120 typedef std::list< 00121 std::pair<RTT::corba::CDataFlowInterface_var, DataFlowInterface*> 00122 > ServantMap; 00123 static ServantMap s_servant_map; 00124 00125 typedef std::list< 00126 std::pair<RTT::corba::CChannelElement_var, base::ChannelElementBase::shared_ptr> 00127 > ChannelList; 00128 ChannelList channel_list; 00129 // Lock that should be taken before access to channel_list 00130 RTT::os::Mutex channel_list_mtx; 00131 public: 00132 // standard constructor 00133 CDataFlowInterface_i(DataFlowInterface* interface, PortableServer::POA_ptr poa); 00134 virtual ~CDataFlowInterface_i(); 00135 00136 static void registerServant(CDataFlowInterface_ptr objref, DataFlowInterface* obj); 00137 static void deregisterServant(DataFlowInterface* obj); 00138 static void clearServants(); 00139 static DataFlowInterface* getLocalInterface(CDataFlowInterface_ptr objref); 00140 00142 void deregisterChannel(CChannelElement_ptr channel); 00143 00148 static CDataFlowInterface_ptr getRemoteInterface(DataFlowInterface* dfi, PortableServer::POA_ptr poa); 00149 00150 virtual RTT::corba::CDataFlowInterface_ptr activate_this() { 00151 PortableServer::ObjectId_var oid = mpoa->activate_object(this); // ref count=2 00152 //_remove_ref(); // ref count=1 00153 return _this(); 00154 } 00155 00156 PortableServer::POA_ptr _default_POA(); 00157 00158 // methods corresponding to defined IDL attributes and operations 00159 RTT::corba::CDataFlowInterface::CPortNames* getPorts() ACE_THROW_SPEC (( 00160 CORBA::SystemException 00161 )); 00162 RTT::corba::CDataFlowInterface::CPortDescriptions* getPortDescriptions() ACE_THROW_SPEC (( 00163 CORBA::SystemException 00164 )); 00165 RTT::corba::CPortType getPortType(const char* port_name) ACE_THROW_SPEC (( 00166 CORBA::SystemException 00167 ,::RTT::corba::CNoSuchPortException 00168 )); 00169 char* getDataType(const char* port_name) ACE_THROW_SPEC (( 00170 CORBA::SystemException 00171 ,::RTT::corba::CNoSuchPortException 00172 )); 00173 ::CORBA::Boolean isConnected(const char* port_name) ACE_THROW_SPEC (( 00174 CORBA::SystemException 00175 ,::RTT::corba::CNoSuchPortException 00176 )); 00177 ::CORBA::Boolean channelReady(const char* port_name, RTT::corba::CChannelElement_ptr channel) ACE_THROW_SPEC (( 00178 CORBA::SystemException 00179 ,::RTT::corba::CNoSuchPortException 00180 )); 00181 void disconnectPort(const char* port_name) ACE_THROW_SPEC (( 00182 CORBA::SystemException 00183 ,::RTT::corba::CNoSuchPortException 00184 )); 00185 00186 CChannelElement_ptr buildChannelOutput(const char* reader_port, RTT::corba::CConnPolicy& policy) ACE_THROW_SPEC (( 00187 CORBA::SystemException 00188 ,::RTT::corba::CNoCorbaTransport 00189 ,::RTT::corba::CNoSuchPortException 00190 )); 00191 CChannelElement_ptr buildChannelInput(const char* writer_port, RTT::corba::CConnPolicy& policy) ACE_THROW_SPEC (( 00192 CORBA::SystemException 00193 ,::RTT::corba::CNoCorbaTransport 00194 ,::RTT::corba::CNoSuchPortException 00195 )); 00196 00197 ::CORBA::Boolean createConnection( const char* writer_port, 00198 CDataFlowInterface_ptr reader_interface, 00199 const char* reader_port, 00200 RTT::corba::CConnPolicy & policy) ACE_THROW_SPEC (( 00201 CORBA::SystemException 00202 ,::RTT::corba::CNoSuchPortException 00203 )); 00204 bool removeConnection( const char* writer_port, 00205 CDataFlowInterface_ptr reader_interface, 00206 const char* reader_port) ACE_THROW_SPEC (( 00207 CORBA::SystemException 00208 ,::RTT::corba::CNoSuchPortException 00209 )); 00210 00211 ::CORBA::Boolean createStream( const char* port, 00212 RTT::corba::CConnPolicy & policy) ACE_THROW_SPEC (( 00213 CORBA::SystemException 00214 ,::RTT::corba::CNoSuchPortException 00215 )); 00216 void removeStream( const char* port, const char* stream_name) ACE_THROW_SPEC (( 00217 CORBA::SystemException 00218 ,::RTT::corba::CNoSuchPortException 00219 )); 00220 }; 00221 } 00222 }; 00223 00224 00225 #endif /* DATAFLOWI_H_ */ 00226