Interstage Application Server アプリケーション作成ガイド (CORBAサービス編)
目次 索引 前ページ次ページ

第4章 アプリケーションの開発(C言語)> 4.4 サーバアプリケーションのプログラミング(静的スケルトンインタフェース)

4.4.3 インタフェース実装関数

 初期化処理の後、サーバアプリケーションで実装するインタフェースの処理を記述します。インタフェース実装関数の第1パラメタにはオブジェクトリファレンスが渡され、次にIDLで定義したパラメタ、最後にCORBA_Environment構造体へのポインタが渡されます。

  ODdemo_calculator_result            /* 復帰値の型 */
  ODdemo_calculator_calculate(        /* calculateメソッドの実装関数 */
      ODdemo_calculator   obj,        /* サーバのオブジェクトリファレンス */
      CORBA_long          a,          /* 入力値 */
      CORBA_long          b,          /* 入力値 */
      CORBA_Environment   *env )      /* エラー値 */
  {
      ODdemo_calculator_result  res;  /* 復帰値 */

      res.add_result = 0; 
      res.subtract_result = 0; 
      res.multiple_result = 0; 
      res.divide_result = 0; 

      if( b == 0 ){                   /* 除算チェック */
          CORBA_BOA_set_exception(
              boa, 
              CORBA_USER_EXCEPTION, 
              ex_ODdemo_calculator_ZEROPARAM, 
              NULL, 
              env ); 
          return( res ) ; 
      }
      res.add_result = a+b;                  /* 加算結果設定 */
      res.subtract_result = a-b;             /* 減算結果設定 */
      res.multiple_result = a*b;             /* 乗算結果設定 */
      res.divide_result = (CORBA_float)a/b;  /* 除算結果設定 */
      return res;
  }

目次 索引 前ページ次ページ

All Rights Reserved, Copyright(C) 富士通株式会社 2005