CorbaConsumer.h
Go to the documentation of this file.
1 // -*- C++ -*-
20 #ifndef RTC_CORBACONSUMER_H
21 #define RTC_CORBACONSUMER_H
22 
23 #include <iostream>
24 #ifdef ORB_IS_MICO
25 #include <CORBA.h>
26 #endif
27 #ifdef ORB_IS_OMNIORB
28 #ifdef WIN32
29 #pragma warning( disable : 4267 )
30 #pragma warning( disable : 4290 )
31 #pragma warning( disable : 4311 )
32 #pragma warning( disable : 4312 )
33 #endif // WIN32
34 #include <omniORB4/CORBA.h>
35 #ifdef WIN32
36 #pragma warning( default : 4267 )
37 #pragma warning( default : 4290 )
38 #pragma warning( default : 4311 )
39 #pragma warning( default : 4312 )
40 #endif // WIN32
41 #endif
42 #ifdef ORB_IS_ORBACUS
43 #include <OB/CORBA.h>
44 #endif
45 #ifdef ORB_IS_ORBIT2
46 #include <orbitcpp/orb-cpp/orbitcpp.h>
47 #endif
48 #ifdef ORB_IS_ORBIX
49 #include <CORBA.h>
50 #endif
51 #ifdef ORB_IS_TAO
52 #include <tao/corba.h>
53 #endif
54 
69 namespace RTC
70 {
95  {
96  public:
109 
126  : m_objref(CORBA::Object::_duplicate(x.m_objref))
127  {
128  }
129 
150  {
151  CorbaConsumerBase tmp(x);
152  tmp.swap(*this);
153  return *this;
154  }
155 
172  {
173  CORBA::Object_var tmpref = x.m_objref;
174  x.m_objref = this->m_objref;
175  this->m_objref = tmpref;
176  }
177 
189  virtual ~CorbaConsumerBase(void)
190  {
191  releaseObject();
192  };
193 
221  virtual bool setObject(CORBA::Object_ptr obj)
222  {
223  if (CORBA::is_nil(obj))
224  {
225  return false;
226  }
227  m_objref = CORBA::Object::_duplicate(obj);
228  return true;
229  }
230 
254  virtual CORBA::Object_ptr getObject()
255  {
256  return m_objref;
257  }
258 
276  virtual void releaseObject()
277  {
278  m_objref = CORBA::Object::_nil();
279  }
280 
281  protected:
289  CORBA::Object_var m_objref;
290  };
291 
335  template <class ObjectType,
336  typename ObjectTypePtr = typename ObjectType::_ptr_type,
337  typename ObjectTypeVar = typename ObjectType::_var_type>
339  : public CorbaConsumerBase
340  {
341  public:
354 
371  : m_var(ObjectType::_duplicate(x.m_var))
372  {
373  }
374 
395  {
396  CorbaConsumer tmp(x);
397  tmp.swap(*this);
398  return *this;
399  }
400 
402  {
404  ObjectTypeVar tmpref = x.m_var;
405  x.m_var = this->m_var;
406  this->m_var = tmpref;
407 
408  }
409 
421  virtual ~CorbaConsumer(void)
422  {
423  releaseObject();
424  };
425 
454  virtual bool setObject(CORBA::Object_ptr obj)
455  {
457  {
458  releaseObject();
459  return false; // object is nil
460  }
461 
462  ObjectTypeVar var = ObjectType::_narrow(m_objref);
463 
464  if (CORBA::is_nil(var))
465  {
466  releaseObject();
467  return false;
468  }
469 
470  m_var = var;
471  return true;
472  }
473 
498  inline ObjectTypePtr _ptr()
499  {
500  return m_var.inout();
501  }
502 
527  inline ObjectTypePtr operator->()
528  {
529  return m_var.inout();
530  }
531 
549  virtual void releaseObject()
550  {
552  m_var = ObjectType::_nil();
553  }
554 
555  protected:
563  ObjectTypeVar m_var;
564  };
565 }; // namespace RTC
566 #endif // RTC_CORBACONSUMER_H
ObjectTypeVar m_var
CORBA object which has been set.
virtual void releaseObject()
Clear CORBA object setting.
RT-Component.
CorbaConsumerBase & operator=(const CorbaConsumerBase &x)
Assignment operator.
virtual bool setObject(CORBA::Object_ptr obj)
Set CORBA Object.
virtual void releaseObject()
Clear CORBA object setting.
CorbaConsumer & operator=(const CorbaConsumer &x)
Assignment operator.
CORBA::Object_var m_objref
CORBA object which is set.
void swap(CorbaConsumer &x)
CorbaConsumerBase(const CorbaConsumerBase &x)
Copy Consructor.
virtual bool setObject(CORBA::Object_ptr obj)
Set Object.
virtual ~CorbaConsumerBase(void)
Virtual destructor.
ObjectTypePtr _ptr()
Get Object reference narrowed as ObjectType.
ObjectTypePtr operator->()
Get Object reference narrowed as ObjectType.
CorbaConsumerBase()
Consructor.
CorbaConsumer()
Consructor.
virtual ~CorbaConsumer(void)
Virtual destructor.
doil CORBA header
CorbaConsumer(const CorbaConsumer &x)
Copy constructor.
void swap(CorbaConsumerBase &x)
swap function
virtual CORBA::Object_ptr getObject()
Get CORBA Object.


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:25:58