[omniORB] Tie Classes
Sai-Lai Lo
S.Lo@orl.co.uk
26 Jun 1998 13:59:39 +0100
Tie class generation has been implemented and will be available in the next
snapshot.
For each interface, a template class is generated.
To use the template in eg3_impl.cc for example:
Echo_i *myimpl = new Echo_i();
_tie_Echo<Echo_i,1> *myobj = new _tie_Echo<Echo_i,1>(myimpl);
myobj->_obj_is_ready(boa);
The template class looks like this:
template <class T,CORBA::Boolean release>
class _tie_Echo : public virtual _sk_Echo
{
public:
_tie_Echo (T* o) : pd_obj(o), pd_release(release) {}
_tie_Echo (T* o, const omniORB::objectKey& k) : _sk_Echo(k), pd_obj(o),
pd_release(release) {}
~_tie_Echo() { if (pd_release) delete pd_obj; }
virtual char * echoString ( const char * mesg ) {
return pd_obj->echoString ( mesg ); }
private:
T* pd_obj;
CORBA::Boolean pd_release;
_tie_Echo();
};
The second parameter <release> to the template class tells the class
instance whether to call delete on the implementation when _dispose is
called. Usually <release> is always 1 except when the same implementation
is used to support multiple interfaces, in which case, only one or zero of
the template class instances should have the <release> flag set to 1.
Sai-Lai
Nick Reeves <nickr@harlequin.co.uk> writes:
> I have a vague memory this question may have been asked before but I
> can't find it in the archives.
>
> Are there any plans to add Tie class generation to the IDL compiler as
> is provided with many other IDL compilers ?
>
> This frees the servants from having to inherit from the implementation base
> class by providing Tie classes which simply delegate all operations to
> the servant.
>
> If not how do other people handle implementing inheritance among
> servant classes, and would work on extending the IDL compiler to
> generate Tie classes be considered appropriate for merging back into
> the main source.
>
--
Dr. Sai-Lai Lo | Research Scientist
|
E-mail: S.Lo@orl.co.uk | Olivetti & Oracle Research Lab
| 24a Trumpington Street
Tel: +44 223 343000 | Cambridge CB2 1QA
Fax: +44 223 313542 | ENGLAND