DataFlowI.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 #ifndef DATAFLOWI_H_
00070 #define DATAFLOWI_H_
00071
00072 #include "../rtt-config.h"
00073 #include "corba.h"
00074 #ifdef CORBA_IS_TAO
00075 #include "DataFlowS.h"
00076 #else
00077 #include "DataFlowC.h"
00078 #endif
00079 #include "../DataFlowInterface.hpp"
00080 #include "../BufferInterface.hpp"
00081 #include "CorbaConversion.hpp"
00082
00083 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00084 #pragma once
00085 #endif
00086
00087
00088
00089
00090 template< class T>
00091 class RTT_Corba_BufferChannel_i : public virtual POA_RTT::Corba::BufferChannel, public virtual PortableServer::RefCountServantBase
00092 {
00093 typename RTT::BufferInterface<T>::shared_ptr mbuf;
00094 public:
00095
00096 RTT_Corba_BufferChannel_i (typename RTT::BufferInterface<T>::shared_ptr buf)
00097 : mbuf(buf)
00098 {}
00099
00100
00101
00102 virtual ~RTT_Corba_BufferChannel_i (void) {}
00103
00104 virtual CORBA::Boolean push (const ::CORBA::Any & data)
00105 ACE_THROW_SPEC ((
00106 CORBA::SystemException
00107 ))
00108 {
00109 using namespace RTT;
00110
00111
00112
00113 T value;
00114 if ( AnyConversion<T>::update( data, value ) == false ) {
00115 Logger::log() <<Logger::Error << "Could not accept remote value: wrong data type."<<Logger::endl;
00116 return false;
00117 }
00118
00119 return mbuf->Push( value );
00120 }
00121
00122 virtual CORBA::Boolean pull ( ::CORBA::Any_out data)
00123 ACE_THROW_SPEC ((
00124 CORBA::SystemException
00125 ))
00126 {
00127 using namespace RTT;
00128
00129
00130 T result;
00131 if ( mbuf->Pop( result ) == false ) {
00132 data = new CORBA::Any();
00133 return false;
00134 }
00135 CORBA::Any_var toset = AnyConversion<T>::createAny( result );
00136 data = toset._retn();
00137 return true;
00138 }
00139
00140 virtual
00141 ::CORBA::Any_ptr front(
00142
00143 )
00144 ACE_THROW_SPEC ((
00145 CORBA::SystemException
00146 )) {
00147 return RTT::AnyConversion<T>::createAny( mbuf->front() );
00148 }
00149
00150 virtual
00151 CORBA::Boolean full (
00152
00153 )
00154 ACE_THROW_SPEC ((
00155 CORBA::SystemException
00156 )) {
00157 return mbuf->full();
00158 }
00159
00160 virtual
00161 CORBA::Boolean empty (
00162
00163 )
00164 ACE_THROW_SPEC ((
00165 CORBA::SystemException
00166 )) {
00167 return mbuf->empty();
00168 }
00169
00170 virtual
00171 CORBA::Long capacity (
00172
00173 )
00174 ACE_THROW_SPEC ((
00175 CORBA::SystemException
00176 )){
00177 return mbuf->capacity();
00178 }
00179
00180 virtual
00181 CORBA::Long size (
00182
00183 )
00184 ACE_THROW_SPEC ((
00185 CORBA::SystemException
00186 )) {
00187 return mbuf->size();
00188 }
00189
00190 virtual
00191 void clear (
00192
00193 )
00194 ACE_THROW_SPEC ((
00195 CORBA::SystemException
00196 )) {
00197 mbuf->clear();
00198 }
00199 };
00200
00204 template<>
00205 class RTT_Corba_BufferChannel_i<RTT::detail::UnknownType> : public virtual POA_RTT::Corba::BufferChannel, public virtual PortableServer::RefCountServantBase
00206 {
00207 RTT::BufferBase::shared_ptr mbuf;
00208 public:
00209
00210 RTT_Corba_BufferChannel_i ( RTT::BufferBase::shared_ptr buf)
00211 : mbuf(buf)
00212 {}
00213
00214
00215 virtual ~RTT_Corba_BufferChannel_i (void) {}
00216
00217 virtual CORBA::Boolean push (const ::CORBA::Any & data)
00218 ACE_THROW_SPEC ((
00219 CORBA::SystemException
00220 ))
00221 {
00222 using namespace RTT;
00223 Logger::In in("CorbaBufferChannelI::push");
00224 log(Error) << "Don't know how to interprete this data type."<<endlog();
00225 return false;
00226 }
00227
00228 virtual CORBA::Boolean pull ( ::CORBA::Any_out data)
00229 ACE_THROW_SPEC ((
00230 CORBA::SystemException
00231 ))
00232 {
00233 using namespace RTT;
00234 data = new CORBA::Any();
00235 Logger::In in("CorbaBufferChannelI::pull");
00236 log(Error) << "Don't know how to transfer this data type."<<endlog();
00237 return false;
00238 }
00239
00240 virtual
00241 ::CORBA::Any_ptr front(
00242
00243 )
00244 ACE_THROW_SPEC ((
00245 CORBA::SystemException
00246 )) {
00247 return new CORBA::Any();
00248 }
00249
00250 virtual
00251 CORBA::Boolean full (
00252
00253 )
00254 ACE_THROW_SPEC ((
00255 CORBA::SystemException
00256 )) {
00257 return mbuf->full();
00258 }
00259
00260 virtual
00261 CORBA::Boolean empty (
00262
00263 )
00264 ACE_THROW_SPEC ((
00265 CORBA::SystemException
00266 )) {
00267 return mbuf->full();
00268 }
00269
00270 virtual
00271 CORBA::Long capacity (
00272
00273 )
00274 ACE_THROW_SPEC ((
00275 CORBA::SystemException
00276 )){
00277 return mbuf->capacity();
00278 }
00279
00280 virtual
00281 CORBA::Long size (
00282
00283 )
00284 ACE_THROW_SPEC ((
00285 CORBA::SystemException
00286 )) {
00287 return mbuf->size();
00288 }
00289
00290 virtual
00291 void clear (
00292
00293 )
00294 ACE_THROW_SPEC ((
00295 CORBA::SystemException
00296 )) {
00297 mbuf->clear();
00298 }
00299 };
00300
00301
00302 class RTT_Corba_DataFlowInterface_i : public virtual POA_RTT::Corba::DataFlowInterface, public virtual PortableServer::RefCountServantBase
00303 {
00304 RTT::DataFlowInterface* mdf;
00305 public:
00306
00307 RTT_Corba_DataFlowInterface_i (RTT::DataFlowInterface* dfi);
00308
00309
00310 virtual ~RTT_Corba_DataFlowInterface_i (void);
00311
00312 virtual
00313 ::RTT::Corba::DataFlowInterface::PortNames * getPorts (
00314
00315 )
00316 ACE_THROW_SPEC ((
00317 CORBA::SystemException
00318 ));
00319
00320 virtual
00321 ::RTT::Corba::AssignableExpression_ptr createDataChannel (
00322 const char * port_name
00323 )
00324 ACE_THROW_SPEC ((
00325 CORBA::SystemException
00326 ));
00327
00328 virtual
00329 ::RTT::Corba::BufferChannel_ptr createBufferChannel (
00330 const char * port_name
00331 )
00332 ACE_THROW_SPEC ((
00333 CORBA::SystemException
00334 ));
00335
00336 virtual
00337 ::RTT::Corba::Expression_ptr createDataObject (
00338 const char * port_name
00339 )
00340 ACE_THROW_SPEC ((
00341 CORBA::SystemException
00342 ));
00343
00344 virtual
00345 ::RTT::Corba::DataFlowInterface::ConnectionModel getConnectionModel (
00346 const char * port_name
00347 )
00348 ACE_THROW_SPEC ((
00349 CORBA::SystemException
00350 ));
00351
00352 virtual
00353 ::RTT::Corba::DataFlowInterface::PortType getPortType (
00354 const char * port_name
00355 )
00356 ACE_THROW_SPEC ((
00357 CORBA::SystemException
00358 ));
00359
00360 virtual
00361 char* getDataType (
00362 const char * port_name
00363 )
00364 ACE_THROW_SPEC ((
00365 CORBA::SystemException
00366 ));
00367
00368 virtual
00369 CORBA::Boolean isConnected (
00370 const char * port_name
00371 )
00372 ACE_THROW_SPEC ((
00373 CORBA::SystemException
00374 ));
00375
00376 virtual
00377 void disconnect (
00378 const char * port_name
00379 )
00380 ACE_THROW_SPEC ((
00381 CORBA::SystemException
00382 ));
00383
00384 virtual
00385 CORBA::Boolean connectDataPort (
00386 const char * port_name,
00387 ::RTT::Corba::AssignableExpression_ptr data
00388 )
00389 ACE_THROW_SPEC ((
00390 CORBA::SystemException
00391 ));
00392
00393 virtual
00394 CORBA::Boolean connectBufferPort (
00395 const char * port_name,
00396 ::RTT::Corba::BufferChannel_ptr buffer
00397 )
00398 ACE_THROW_SPEC ((
00399 CORBA::SystemException
00400 ));
00401
00402 virtual
00403 CORBA::Boolean connectPorts (
00404 const char * local_port,
00405 ::RTT::Corba::DataFlowInterface_ptr remote_ports,
00406 const char * remote_port
00407 )
00408 ACE_THROW_SPEC ((
00409 CORBA::SystemException
00410 ));
00411 };
00412
00413
00414 #endif
00415