[prev in list] [next in list] [prev in thread] [next in thread] 

List:       omniorb-list
Subject:    Re: [omniORB] simple question on general Corba
From:       Anton Idukov <idukov () crtc ! spb ! ru>
Date:       2001-09-12 6:48:41
[Download RAW message or body]

>
>
>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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic