次のコードを使用して、2 レベルアップのモジュールに移動しようとしています:-
cModule* parentmod = getParentModule();
cModule* grantParentmod = parentmod->getParentModule();
for (cSubModIterator iter(*grantParentmod); !iter.end();iter++)
EV<<"Current module is "<< iter()->getFullName() <<endl;
出力は次のとおりです。
Current module is notificationBoard
Current module is mobility
Current module is udpApp[0]
Current module is udpApp[1]
Current module is udp
Current module is networkLayer
Current module is routingTable
Current module is interfaceTable
Current module is wlan[0]
ただし、次のコードを使用して udpApp[0] に直接アクセスしようとすると:-
cModule* parentmod = getParentModule();
cModule* grantParentmod = parentmod->getParentModule();
cModule* udpmod = parentmod->getParentModule()->getSubmodule("udpApp[0]");
EV<<"Current module is "<< udpmod->getFullName() <<endl;
シミュレーションは実行時に次のエラーで終了します: シミュレーションは終了コード: 139で終了しました。これはセグメンテーション違反を意味します。ただし、「udpApp[0]」の代わりに「mobility」などの他のモジュールを使用すると、正常に動作します。
誰でも、この状況を解決するための可能な方法を見つけ出すのを手伝ってくれませんか?