Non-obvious behaviour with addMethod()

The attached test case demonstrates what I think is non-obvious behaviour. Wondering if you agree?
## First addMethod() call succeeds but the method is not available in the TaskBrowser.
## Second addMethod() fails to compile due to "arity==0" test in indicated function.
## Third addMethod() succeeds and the method is available in the TaskBrowser.

It appears that the various addMethod() functions either take no description and then the method doesn't appear in the TaskBrowser, OR, the addMethod() functions force you to describe each parameter to the method. I don't see this indicated anywhere, though I did notice that the Component Builder's Manual does document each parameter to a method (and hence is case 3 above).

YMMV
Stephen
{{{
#include
#include
#include
#include
#include
#include

#include

using namespace Orocos;

class MyTask : public RTT::TaskContext
{
private:
RTT::Method d_logState;

public:
MyTask(std::string name):
RTT::TaskContext(name),
d_logState("logState", &MyTask::logState, this)
{
// suceeds but not available in TaskBrowser
// methods()->addMethod(&d_logState);
// fails with STATIC ASSERT in RTT::MethodRepository::addMethod()
// methods()->addMethod(&d_logState, "log");
// suceeds and available in TaskBrowser
methods()->addMethod(&d_logState, "log", "v", "name");
}

void logState(const std::string& name)
{
log(Info) << "state = " << name << endlog();
}
};

int ORO_main(int arc, char* argv[])
{
log().setLogLevel( Logger::Debug );

MyTask myTask("myTask");
PeriodicActivity myTask_activity(
ORO_SCHED_RT, RTT::OS::HighestPriority, 1.0 / 1, myTask.engine());

myTask_activity.start();

TaskBrowser browser( &myTask );
browser.setColorTheme( TaskBrowser::whitebg );
browser.loop();

myTask_activity.stop();

return 0;
}

}}}

Non-obvious behaviour with addMethod()

On Tuesday 22 April 2008 19:53:33 snrkiwi wrote:
> The attached test case demonstrates what I think is non-obvious behaviour.
> Wondering if you agree? ## First addMethod() call succeeds but the method
> is not available in the TaskBrowser. ## Second addMethod() fails to compile
> due to "arity==0" test in indicated function. ## Third addMethod() succeeds
> and the method is available in the TaskBrowser.

This is intended behaviour and was created for 'embedded' use. The third
addMethod() consumes more memory (because it uses scripting) than the first
addMethod(), which is only available in C++.

See

>
> It appears that the various addMethod() functions either take no
> description and then the method doesn't appear in the TaskBrowser, OR, the
> addMethod() functions force you to describe each parameter to the method. I
> don't see this indicated anywhere, though I did notice that the Component
> Builder's Manual does document each parameter to a method (and hence is
> case 3 above).

Then the manual is not complete enough. The difference is explained at another
place, in the 'deployment' section :

Which explains that there is a 'scripting/CORBA/full' interface and a pure C++
(minimal) interface of a TaskContext. Your implementation can choose which
one to use by specifying the description strings or not. I guess that was a
bad idea, and confusing for newcommers...

Peter