25.2.3 valuetypeベースクラスの継承

IDLのコンパイル後,valuetypeのインプリメンテーションを作成します。インプリメンテーションクラスは,ベースクラスを継承します。このクラスには,ValueFactoryで呼び出されたコンストラクタがあり,IDLで宣言された変数とメソッドのすべてを含んでいます。

例えばobv¥PntImpl.hでは,コードサンプル25-1で示すようにPointImplクラスはIDLから生成されたPointクラスを継承します。

例えばobv¥PointImpl.javaでは,コードサンプル25-2で示すようにPointImplクラスはIDLから生成されたPointクラスを継承します。

コードサンプル25-1 valuetypeベースクラスの継承(C++)

class PointImpl : public Map::OBV_Point,
     public CORBA::DefaultValueRefCountBase {
  public:
     PointImpl(){}
     virtual ~PointImpl(){}
     CORBA_ValueBase* _copy_value() {
        return new PointImpl(x(), y(),
              new Map::Label(CORBA::string_dup(label())));
     }
     PointImpl( CORBA::Long x, CORBA::Long y,
           Map::Label_ptr label )
           : OBV_Point( x,y,label->_boxed_in())
     {}
     virtual void print() {
        cout << "Point is [" << label() << ": ("
           << x() << ", " << y() << ")]" << endl << endl;
     }
};

コードサンプル25-2 valuetypeベースクラスの継承(Java)

public class PointImpl extends Point {
  public PointImpl() {}
  public PointImpl(int a_x, int a_y, String a_label) {
     x = a_x;
     y = a_y;
     label = a_label;
  }
  public void print() {
     System.out.println("Point is [" + label +
                        ": (" + x + ", " + y + ")]");
  }
}