I'm a newbie in OMNet. In my project, I dynamically create a simple module, and I want to use the object created by this module. Does anyone can give me some help?
Source is here:
cModuleType* moduleType = cModuleType::get("Person");
cModule *mod = moduleType->create("per", this->getParentModule());
mod->buildInside();
mod->scheduleStart(simTime());
mod->callInitialize();
job->mod = 开发者_JAVA技巧mod;
Basically, I want to find the object related to the "mod".
Thank you
I'm not sure what you mean "find" the object you created. You already have the object you created, you probably just need to cast it to do anything useful with it.
If you mean you want to operate on the module "mod", you can do this by casting "mod" to the module type which you've declared (say MyModule).
MyModule *my_mod = check_and_cast<MyModule *>(mod);
You can then define some public functions in the class of MyModule (usually MyModule.cc) that do whatever you want to do.
MyModule::my_method() {some code}
If you've done this, in the current function, you can just go:
my_mod->my_method();
I hope this answers your question.
精彩评论