OpenRTM-aist 2.0.2
Loading...
Searching...
No Matches
CorbaConsumer.h
Go to the documentation of this file.
1// -*- C++ -*-
20#ifndef RTC_CORBACONSUMER_H
21#define RTC_CORBACONSUMER_H
22
23#include <utility>
24#include <iostream>
25#ifdef ORB_IS_MICO
26#include <CORBA.h>
27#endif
28#ifdef ORB_IS_OMNIORB
29#include <omniORB4/CORBA.h>
30#endif
31#ifdef ORB_IS_ORBACUS
32#include <OB/CORBA.h>
33#endif
34#ifdef ORB_IS_ORBIT2
35#include <orbitcpp/orb-cpp/orbitcpp.h>
36#endif
37#ifdef ORB_IS_ORBIX
38#include <CORBA.h>
39#endif
40#ifdef ORB_IS_TAO
41#include <tao/corba.h>
42#endif
43
58namespace RTC
59{
84 {
85 public:
97 CorbaConsumerBase() = default;
98
115#ifdef ORB_IS_ORBEXPRESS
116 : m_objref(CORBA::Object::_duplicate(x.m_objref.in()))
117#else
118 : m_objref(CORBA::Object::_duplicate(x.m_objref))
119#endif
120 {
121 }
122
143 {
144 CorbaConsumerBase tmp(x);
145 tmp.swap(*this);
146 return *this;
147 }
148
165 {
166 CORBA::Object_var tmpref = x.m_objref;
167 x.m_objref = this->m_objref;
168 this->m_objref = tmpref;
169 }
170
183 {
185 }
186
214 virtual bool setObject(CORBA::Object_ptr obj)
215 {
216 if (CORBA::is_nil(obj))
217 {
218 return false;
219 }
220 m_objref = CORBA::Object::_duplicate(obj);
221 return true;
222 }
223
247 virtual CORBA::Object_ptr getObject()
248 {
249 return m_objref;
250 }
251
269 virtual void releaseObject()
270 {
271 m_objref = CORBA::Object::_nil();
272 }
273
274 protected:
282 CORBA::Object_var m_objref;
283 };
284
328 template <class ObjectType,
329 typename ObjectTypePtr = typename ObjectType::_ptr_type,
330 typename ObjectTypeVar = typename ObjectType::_var_type>
332 : public CorbaConsumerBase
333 {
334 public:
347
365#ifdef ORB_IS_ORBEXPRESS
366 , m_var(ObjectType::_duplicate(x.m_var.in()))
367#else
368 , m_var(ObjectType::_duplicate(x.m_var))
369#endif
370 {
371 }
372
393 {
394 CorbaConsumer tmp(x);
395 tmp.swap(*this);
396 return *this;
397 }
398
400 {
402 ObjectTypeVar tmpref = x.m_var;
403 x.m_var = this->m_var;
404 this->m_var = tmpref;
405
406 }
407
419 ~CorbaConsumer() override
420 {
422 }
423
452 bool setObject(CORBA::Object_ptr obj) override
453 {
455 {
457 return false; // object is nil
458 }
459
460 ObjectTypeVar var = ObjectType::_narrow(m_objref);
461
462 if (CORBA::is_nil(var))
463 {
465 return false;
466 }
467
468 m_var = var;
469 return true;
470 }
471
496 inline ObjectTypePtr _ptr()
497 {
498 return m_var.inout();
499 }
500
525 inline ObjectTypePtr operator->()
526 {
527 return m_var.inout();
528 }
529
547 void releaseObject() override
548 {
550 m_var = ObjectType::_nil();
551 }
552
553 protected:
561 ObjectTypeVar m_var;
562 };
563
564 // No inline for gcc warning, too big
565 template <class T, class U, class V>
567} // namespace RTC
568#endif // RTC_CORBACONSUMER_H
Definition CorbaConsumer.h:84
CORBA::Object_var m_objref
CORBA object which is set. .
Definition CorbaConsumer.h:282
CorbaConsumerBase(const CorbaConsumerBase &x)
Copy Consructor.
Definition CorbaConsumer.h:114
CorbaConsumerBase & operator=(const CorbaConsumerBase &x)
Assignment operator.
Definition CorbaConsumer.h:142
CorbaConsumerBase()=default
Consructor.
void swap(CorbaConsumerBase &x)
swap function
Definition CorbaConsumer.h:164
virtual bool setObject(CORBA::Object_ptr obj)
Set CORBA Object.
Definition CorbaConsumer.h:214
virtual void releaseObject()
Clear CORBA object setting.
Definition CorbaConsumer.h:269
virtual ~CorbaConsumerBase()
Virtual destructor.
Definition CorbaConsumer.h:182
virtual CORBA::Object_ptr getObject()
Get CORBA Object.
Definition CorbaConsumer.h:247
Definition CorbaConsumer.h:333
void releaseObject() override
Clear CORBA object setting.
Definition CorbaConsumer.h:547
~CorbaConsumer() override
Virtual destructor.
Definition CorbaConsumer.h:419
CorbaConsumer(const CorbaConsumer &x)
Copy constructor.
Definition CorbaConsumer.h:363
void swap(CorbaConsumer &x)
Definition CorbaConsumer.h:399
bool setObject(CORBA::Object_ptr obj) override
Set Object.
Definition CorbaConsumer.h:452
CorbaConsumer()
Consructor.
ObjectTypePtr _ptr()
Get Object reference narrowed as ObjectType.
Definition CorbaConsumer.h:496
ObjectTypeVar m_var
CORBA object which has been set. .
Definition CorbaConsumer.h:561
ObjectTypePtr operator->()
Get Object reference narrowed as ObjectType.
Definition CorbaConsumer.h:525
CorbaConsumer & operator=(const CorbaConsumer &x)
Assignment operator.
Definition CorbaConsumer.h:392
RT-Component.