[omniORB] TIE approach and reference counting
Hautesserres, Thomas
thomas.hautesserres@managedstorage.fr
Mon Feb 3 13:04:02 2003
Hi,
I am using the TIE approach to implement my servant objects, but as I have
just discovered, the generated _tie classes do not inherit from
PortableServer::RefCountServantBase but only from
PortableServer::ServantBase. As one can guess, the main difference is that
when one of my TIEd servant is deactivated from its POA, it is not
automatically deleted.
So here are my two questions:
- Why are the generated _tie classes not inheriting from
RefCountServantBase? Is that a question of CORBA-standard complicance, or is
there any good reason not to do that? In my opinion, inheriting from
PortableServer::RefCountServantBase would be OK as one can use the "r" (for
release) parameter in the _tie class constructor to indicate that the
associated object should not be released, thus having exactly the same
behaviour as now.
- At the end of this message is what I have done to force my TIE servant to
use the RefCountServantBase. Is here any other (more standard) way to
achieve that?
Thanks in advance,
Thomas
--------------------------------------
// Server side implementation of the IDL interface dn::MyInterface
// As we are using the TIE approach, no specific inheritance is declared.
class MyServerImpl
{
public:
// ...
protected:
// Create and return a new servant associated with this implementation.
// The returned object will the activated in the POA.
PortableServer::Servant getServant()
{ return new MyTIEServant (this); }
private:
// Private servant class: Inherit from both the _tie class and
RefCountBaseClass.
// Note: using public virtual inheritance doesn't compile with VC++.
class MyTIEServant
: public POA_dn::MyInterface_tie<MyServerImpl>,
public PortableServer::RefCountServantBase
{
public:
MyTIEServant (MyServerImpl *impl)
: POA_dn::MyInterface_tie<MyServerImpl>(impl) {}
};
};