tie implementation question

tie implementation question

Post by vin.. » Fri, 06 Feb 1998 04:00:00



consider the following idl snippet

interface calc {
  long add(in long x, in long y);

Quote:};

interface factory {
  calc create_obj(in string name);
..

Quote:};

Suppose I am using tie mechanism to implement both calc & factory.
For the tie implementation, the template created for factory has the
following code

template <class T>
class _tie_factory : public factory {
...
calc_ptr create_obj(  const char* name)
{
    return _ref.create_obj(  name);
 }

Quote:}

The question is : should'nt create_obj return a ptr to a Tie object ?

vinay

 
 
 

tie implementation question

Post by John Lace » Fri, 06 Feb 1998 04:00:00



> interface calc { long add(in long x, in long y); };
> interface factory { calc create_obj(in string name); };

> Suppose I am using tie mechanism to implement both calc & factory.
> For the tie implementation, the template created for factory has the
> following code

> template <class T>
> class _tie_factory : public factory {
> ...
> calc_ptr create_obj(  const char* name)
> {
>     return _ref.create_obj(  name);
>  }
> }

> The question is : should'nt create_obj return a ptr to a Tie object ?

Generally, yes, T::create_obj should return a _tie_calc<T> *.

The three choices for the return value are:

_tie_calc<T> *
T * (where T inherits from _sk_calc)
_tie_calc<T> * (where T inherits from _sk_calc)

I don't know a reason other than an obfuscated CORBA contest for
either of the latter two choices, given that we are using the tie
classes; otherwise the second choice is perfectly valid. We could
of course substitute _sk_calc for T in the latter two choices.

John L