AddOperation in OCL Component question: overloaded methods
Submitted by Enea Scioni on Thu, 2011-05-19 11:15 |
Hi Everyone,
I got an compiling error on addOperation: in particular my Orocos component has two different prototype of the same method, let's say void DoSomething(int *number) and int DoSomething(). Now, this method implement one service, so I use Operation interface like that:"addOperation("NameService",&MyComponent::DoSomething,this,OwnThread).doc("description")".
Overloading the method in that example, I expect that the second version will be used (int DoSomething() ), since I didn't specify any argument, instead I got the following compiling error: error: no matching function for call to ‘RTT::Service::addOperation(const char [15], <unresolved overloaded function type>, MyComponent* const, RTT::ExecutionThread)
How can I use overloaded methods as Operator? (A solution could be simply use different names for different implementations...but I'm wondering if I miss something or if exist an alternative/better solution..)
Thank You!
Regards, Enea Scioni
AddOperation in OCL Component question: overloaded methods
On Thu, May 19, 2011 at 1:15 PM, <enea [dot] scioni [..] ...> wrote:
> Hi Everyone,
>
> I got an compiling error on addOperation: in particular my Orocos component has two different prototype of the same method, let's say void DoSomething(int *number) and int DoSomething(). Now, this method implement one service, so I use Operation interface like that:"addOperation("NameService",&MyComponent::DoSomething,this,OwnThread).doc("description")".
>
> Overloading the method in that example, I expect that the second version will be used (int DoSomething() ), since I didn't specify any argument, instead I got the following compiling error:
> error: no matching function for call to ‘RTT::Service::addOperation(const char [15], <unresolved overloaded function type>, MyComponent* const, RTT::ExecutionThread)
>
> How can I use overloaded methods as Operator? (A solution could be simply use different names for different implementations...but I'm wondering if I miss something or if exist an alternative/better solution..)
The solution is to tell the compiler which version to use by using a
cast in front of the function :
Scripting doesn't support overloading, so you need to rename it anyway
in scripting if you wish to expose both variants.
Peter
--
Orocos-Users mailing list
Orocos-Users [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users