初期化処理の後、サーバアプリケーションで実装するインタフェースの処理を記述します。インタフェース実装関数の第1パラメタにはオブジェクトリファレンスが渡され、次にIDLで定義したパラメタ、最後にCORBA_Environment構造体へのポインタが渡されます。
なお、アプリケーションで使用可能なCORBAのデータ型については、“3.7 データ型に対するマッピング”を参照してください。
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; }