[omniORB] simple question on general Corba

Anton Idukov idukov@crtc.spb.ru
Wed, 12 Sep 2001 10:48:41 +0400


>
>
>If you know all the "derived" types at the time you write the IDL, you
>can use a union:
>
>  enum UnitKind { UNIT_PARAM, UNIT_OPTION };
>
>  union UnitValue switch (UnitKind) {
>    case UNIT_PARAM:  double d_value;
>    case UNIT_OPTION: long   int_value;
>  };
>
>  struct Unit {
>    string    name;
>    string    unit;
>    string    operation;
>    UnitValue value;
>  };
>
>
>If you don't know the types, an Any is the right thing to use.
>
>Another option might be to use objects by value, but omniORB doesn't
>support them yet.
>
>
As I write You may use tie implementation with castom class inheritance 
with attributes...
Or use private inheritance with helper class

class UnitHelper
{
  public:
    //ctor 
  public:
    char* name();
    void name( const char* );
   
    char* unit();
    void unit ( const char* );

    char* operation();
    void operation( const char* );
   
  private:
    //data fields

};

class UnitImpl: public POA_Unit, private UnitHelper //, some other parents
{
    //decls
};

//method implementations.
char* UnitImpl::name()
{
    return UnitHelper::name();
};
//etc...

class ParamImpl: public POA_Param, private UnitHelper //,some other parents
{
    //decls
};
//method impls.
char* ParamImpl::name()
{
    return UnitHelper::name();
};
//etc.

But I think TIE is more good way.


    Anton