[openrtm-beginners:00420] Re: Calling setModuleInitProc
Ando Noriaki
n-ando @ aist.go.jp
2013年 4月 15日 (月) 10:35:51 JST
Hello,
To what do you want to give "userData"?
If you want to give"userData" to RTC instances, how about the following way?
==========================
<in you RTC's *Comp.cpp>
void MyModuleInit(RTC::Manager* manager)
{
ConsoleInInit(manager);
RTC::RtcBase* comp;
// Create a component
std::cout << "Creating a component: \"ConsoleIn\"....";
comp = manager->createComponent("ConsoleIn?your_param0=your_value0&your_param1=your_value1");
==========================
Here, createComponent() is called in MyModuleInit() function, but you can call
createComponent() anywhere after manager->activateManager().
MyModuleInit() function is usually used only to load RTC's shared object.
After creating your RTC, you can get, your_param0, your_param1 like this,
==========================
<in your RTC>
ReturnCode_t onInitialize(ec)
{
std::cout << "your_param0: " << getProperties()["your_param0"] << std::endl;
std::cout << "your_param1: " << getProperties()["your_param1"] << std::endl;
}
==========================
You can get given parameters in all the onXXXX() call-back functions.
But, you cannot
get them in the constructor.
Best regards,
Noriaki Ando
2013/4/14 <jaysicks.reg @ gmail.com>:
> Hi, When creating an RT component, I have to do something similar to: void
> MyModuleInit(RTC::Manager* manager) { // ... } // ...
> manager->setModuleInitProc(MyModuleInit); // ... What if the MyModuleInit
> function has more arguments? Say it looks like this: void
> MyModuleInit(RTC::Manager* manager, MyCustomClass userData); I tried using
> functors and boost::bind without success. Is there a way to do this? In the
> end what I'm trying to achieve is to pass data from the main function to the
> component itself. Thanks
>
> _______________________________________________
> openrtm-beginners mailing list
> openrtm-beginners @ openrtm.org
> http://www.openrtm.org/mailman/listinfo/openrtm-beginners
More information about the openrtm-beginners
mailing list