CORBA 2.6.1 Programmer's Guide for C++

Appendix C. Servant Reference Counting in NonStop CORBA
Appendix C. Servant Reference Counting in NonStop CORBA
The OMG specification for CORBA 2.6.1 defines two options for servant reference counting:
Reference counting using the RefCountServantBase mix-in class
No reference counting
NonStop CORBA supports both these options and adds a third: reference counting within the CORBA::Object associated with the servant. This
option provides backward compatibility with earlier versions of the NonStop CORBA product (then called NonStop DOM).
The ORB can detect whether or not the servant is derived from RefCountServantBase. If so, then the application is using OMG standard
reference counting. If not, then the application is using
CORBA::Object reference counting (the default). Therefore, a properly working NonStop
DOM 2.0 servant will work as expected under CORBA 2.6.1 because, by default, CORBA 2.6.1 is backward compatible with NonStop DOM 2.0.
If your application is using no reference counting at all for a servant, the servant must override the method Servant::_uses_which_ref_type()
with an implementation that returns a value of zero.
NSDOM_ServantBase::NSDOM_Ref_Type
NSDOM_ServantBase::_uses_which_ref_type()
{
return Uses_NSDOM_ref_count;
// must be overridden by OMG compliant programs which do not use
// reference counting.
}
void
NSDOM_ServantBase::_add_nsd_ref()
{
if (_uses_which_ref_type() == Uses_NSDOM_ref_count)
{
CORBA::Object::_duplicate( this->_this_reference() );
} else
this->_add_ref();
}
void
NSDOM_ServantBase::_remove_nsd_ref()
{
if (_uses_which_ref_type() == Uses_NSDOM_ref_count)
{
CORBA::release( this->_this_reference() );
} else
this->_remove_ref();
}
Appendix B. Object References Index