00001
00020 #ifndef RTC_OUTPORTCORBACDRCONSUMER_H
00021 #define RTC_OUTPORTCORBACDRCONSUMER_H
00022
00023 #include <rtm/idl/DataPortSkel.h>
00024 #include <rtm/CorbaConsumer.h>
00025 #include <rtm/OutPortConsumer.h>
00026 #include <rtm/ConnectorListener.h>
00027 #include <rtm/ConnectorBase.h>
00028
00029 namespace RTC
00030 {
00031
00032
00059 class OutPortCorbaCdrConsumer
00060 : public OutPortConsumer,
00061 public CorbaConsumer< ::OpenRTM::OutPortCdr >
00062 {
00063 public:
00064 DATAPORTSTATUS_ENUM
00065
00083 OutPortCorbaCdrConsumer();
00084
00098 virtual ~OutPortCorbaCdrConsumer(void);
00099
00127 virtual void init(coil::Properties& prop);
00128
00154 virtual void setBuffer(CdrBufferBase* buffer);
00162 virtual void setListener(ConnectorInfo& info,
00163 ConnectorListeners* listeners);
00164
00186 virtual ReturnCode get(cdrMemoryStream& data);
00187
00210 virtual bool subscribeInterface(const SDOPackage::NVList& properties);
00211
00229 virtual void unsubscribeInterface(const SDOPackage::NVList& properties);
00230
00231 private:
00239 OutPortConsumer::ReturnCode convertReturn(::OpenRTM::PortStatus status,
00240 const cdrMemoryStream& data);
00241
00242
00246 inline void onBufferWrite(const cdrMemoryStream& data)
00247 {
00248 m_listeners->
00249 connectorData_[ON_BUFFER_WRITE].notify(m_profile, data);
00250 }
00251
00252 inline void onBufferFull(const cdrMemoryStream& data)
00253 {
00254 m_listeners->
00255 connectorData_[ON_BUFFER_FULL].notify(m_profile, data);
00256 }
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282 inline void onReceived(const cdrMemoryStream& data)
00283 {
00284 m_listeners->
00285 connectorData_[ON_RECEIVED].notify(m_profile, data);
00286 }
00287
00288 inline void onReceiverFull(const cdrMemoryStream& data)
00289 {
00290 m_listeners->
00291 connectorData_[ON_RECEIVER_FULL].notify(m_profile, data);
00292 }
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321 inline void onSenderEmpty()
00322 {
00323 m_listeners->
00324 connector_[ON_SENDER_EMPTY].notify(m_profile);
00325 }
00326
00327 inline void onSenderTimeout()
00328 {
00329 m_listeners->
00330 connector_[ON_SENDER_TIMEOUT].notify(m_profile);
00331 }
00332
00333 inline void onSenderError()
00334 {
00335 m_listeners->
00336 connector_[ON_SENDER_ERROR].notify(m_profile);
00337 }
00338
00339
00340 CdrBufferBase* m_buffer;
00341 ConnectorListeners* m_listeners;
00342 ConnectorInfo m_profile;
00343 };
00344 };
00345
00346 extern "C"
00347 {
00348 void OutPortCorbaCdrConsumerInit(void);
00349 };
00350
00351 #endif // RTC_OUTPORTCORBACDRCONSUMER_H