application クラス : AppNotice(class,string) メソッド
説明
ハンドラを"AppNotice"イベントに割り当てます。
構文
instance.AppNotice(class handleClass, string signature)
引数
| クラス | 名前 | 説明 |
| class | handleClass | ハンドラをメンバとして持つインスタンス。 |
| string | signature | ハンドラのシグネチャ。 |
返り値
| クラス | 説明 |
| switch | ハンドラの実行を制御するインスタンス。 |
サンプルコード
次のクラス定義があるとします。
| 1: | class handle |
| 2: | open method void ANHandler(dictionary dic) |
| 3: | application sender = dic.Sender; |
| 4: | switch sw = dic.Switch; |
| 5: | string data = dic.Data; |
| 6: | endmethod |
| 7: | endclass |
ハンドラの割り当ては次のとおりです。
| 1: | application aap; |
| 2: | handle h = new handle(); |
| 3: | switch sw = app.AppNotice(h,"ANHandler(dictionary)"); |
| 4: | sw.Start(); |
注意
"AppNotice"イベントはRiceスクリプト間での通知です。
Cookerでは複数のRiceスクリプトが同時に実行される可能性があります。このイベントでスクリプト間での通知を行えます。
"AppNotice"イベントのハンドラは、dictionaryクラスの引数を一つ持つopenメソッドでなければなりません。
つまり、ハンドラのメソッド名が "handlerName"の場合、ハンドラの定義は次のようになります。
open method void handlerName(dictionary dic)
...
endmethod
この場合、第2引数で指定されるハンドラのシグネチャは "handlerName(dictionary)"です。
イベント発生時にハンドラに渡される dictionary は以下の key と value のペアを持ちます。
| key | value(クラス) | value(説明) |
| Sender | application | イベントの発生元。 |
| Switch | switch | ハンドラの割り当てで返される switch と同じインスタンス。 |
| Data | string | 通知データ。 |
参照リンク
無し。


