How do I Create a Method with more than 1 argumnent? (error compiling).

Hello guys.

I am having problems creating a method with more than one arguments. The problem, I guess, is on the constructor of the code. The following code works well good.

source.h === ... Method<bool(double)> sendVoltageRTT; bool sendVoltage(double bit); ... ===

source.c === source::source(string name): TaskContext(name), sendVoltageRTT("sendVoltage", &source::sendVoltage,this) {
    this->methods()->addMethod(&sendVoltageRTT, "send Voltage.","bit","bit value in 0-4095");
}

... ===

This method has only one argument as the examples at the manual show. In the manual, it is written that I could create methods with more than one argument. The following code do not work.

source.h === ... Method<bool(double)> sendVoltageRTT; bool sendVoltage(double bit);

Method<bool(double,int) readVoltageRTT; bool readVoltage(int subdevice, int channel); ... ===

source.c === ... source::source(string name): TaskContext(name), sendVoltageRTT("sendVoltage", &source::sendVoltage,this), readVoltageRTT("readVoltage", &source::readVoltage, this) {

this->methods()->addMethod(&sendVoltageRTT, "send Voltage.","bit","bit value in 0-4095");

this->methods()->addMethod(&readVoltageRTT, "read voltage a channel at a subdevice","subdevice","subdevice number","channel", "channel number"); }

... ===

The error is on the last commando, on addMethod. I don't know how many paramaeters I need to put at the commando.

Anybody already used a Method with more than one argument? What is the sintax?

)

Best Regards. Alexandre.

How do I Create a Method with more than 1 argumnent? (error comp

Hi Alexandre,

On Fri, Jul 30, 2010 at 7:07 PM, <Alexandrenagy [..] ...> wrote:
> Hello guys.
>
>
> I am having problems creating a method with more than one arguments. The problem, I guess, is on the constructor of the code. The following code works well good.
...
> source.h
> ===
> ...
> Method<bool(double)> sendVoltageRTT;
> bool sendVoltage(double bit);
>
> Method<bool(double,int) readVoltageRTT;
> bool readVoltage(int subdevice, int channel);

The problem is here: you should have written:

Method<bool(int,int)> readVoltageRTT;

so replace the double with the int.

You can escape from such typo errors by using the method() helper
function. Then you can omit the Method<> line and directly write in
your constructor:

this->methods()->addMethod(
method("readVoltage",&source::readVoltage,this) , "read voltage a
channel at a subdevice","subdevice","subdevice number","channel",
"channel number");

The one that wants to call the method still needs to use the Method<>
helper, there's no way around that one.

Peter

How do I Create a Method with more than 1 argumnent?

Alexandrenagy wrote:
Hello guys.

I am having problems creating a method with more than one arguments. The problem, I guess, is on the constructor of the code. The following code works well good.

source.h
(begin)

Method<bool(double)> sendVoltageRTT;
bool sendVoltage(double bit);
(end)

source.cpp
(begin)
source::source(string name): TaskContext(name),
sendVoltageRTT("sendVoltage", &source::sendVoltage,this)
{
this->methods()->addMethod(&sendVoltageRTT, "send Voltage.","bit","bit value in 0-4095");
}
(end)

This method has only one argument as the examples at the manual show. In the manual, it is written that I could create methods with more than one argument. The following code do not work.

source.h

(begin)
Method<bool(double)> sendVoltageRTT;
bool sendVoltage(double bit);

Method<bool(double,int) readVoltageRTT;
bool readVoltage(int subdevice, int channel);

(end)

source.c
(begin)
source::source(string name): TaskContext(name),
sendVoltageRTT("sendVoltage", &source::sendVoltage,this),
readVoltageRTT("readVoltage", &source::readVoltage, this)
{

this->methods()->addMethod(&sendVoltageRTT, "send Voltage.","bit","bit value in 0-4095");

this->methods()->addMethod(&readVoltageRTT, "read voltage a channel at a subdevice","subdevice","subdevice number","channel", "channel number");
}(end)

The error is on the last commando, on addMethod. I don't know how many paramaeters I need to put at the commando.

Anybody already used a Method with more than one argument? What is the sintax?

:)

Best Regards.
Alexandre.

FIXING THE CODE!

How do I Create a Method with more than 1 argumnent? (error comp

Hello guys.

I am having problems creating a method with more than one arguments. The problem, I guess, is on the constructor of the code. The following code works well good.

source.h
===
...
Method<bool(double)> sendVoltageRTT;
bool sendVoltage(double bit);
...
===

source.c
===
source::source(string name): TaskContext(name),
sendVoltageRTT("sendVoltage", &source::sendVoltage,this)
{
this->methods()->addMethod(&sendVoltageRTT, "send Voltage.","bit","bit value in 0-4095");
}
...
===

This method has only one argument as the examples at the manual show. In the manual, it is written that I could create methods with more than one argument. The following code do not work.

source.h
===
...
Method<bool(double)> sendVoltageRTT;
bool sendVoltage(double bit);

Method<bool(double,int) readVoltageRTT;
bool readVoltage(int subdevice, int channel);
...
===

source.c
===
...
source::source(string name): TaskContext(name),
sendVoltageRTT("sendVoltage", &source::sendVoltage,this),
readVoltageRTT("readVoltage", &source::readVoltage, this)
{

this->methods()->addMethod(&sendVoltageRTT, "send Voltage.","bit","bit value in 0-4095");

this->methods()->addMethod(&readVoltageRTT, "read voltage a channel at a subdevice","subdevice","subdevice number","channel", "channel number");
}
...
===

The error is on the last commando, on addMethod. I don't know how many paramaeters I need to put at the commando.

Anybody already used a Method with more than one argument? What is the sintax?

:)

Best Regards.
Alexandre.

Re: How do I Create a Method with more than 1 argumnent?

Alexandrenagy wrote:
Hello guys.

I am having problems creating a method with more than one arguments. The problem, I guess, is on the constructor of the code. The following code works well good.

source.h (begin)

Method<bool(double)> sendVoltageRTT; bool sendVoltage(double bit); (end)

source.cpp (begin) source::source(string name): TaskContext(name), sendVoltageRTT("sendVoltage", &source::sendVoltage,this) {this->methods()->addMethod(&sendVoltageRTT, "send Voltage.","bit","bit value in 0-4095"); }

(end)

This method has only one argument as the examples at the manual show. In the manual, it is written that I could create methods with more than one argument. The following code do not work.

source.h

(begin) Method<bool(double)> sendVoltageRTT; bool sendVoltage(double bit);

Method<bool(double,int) readVoltageRTT; bool readVoltage(int subdevice, int channel);

(end)

source.c (begin) source::source(string name): TaskContext(name), sendVoltageRTT("sendVoltage", &source::sendVoltage,this), readVoltageRTT("readVoltage", &source::readVoltage, this) {

this->methods()->addMethod(&sendVoltageRTT, "send Voltage.","bit","bit value in 0-4095");

this->methods()->addMethod(&readVoltageRTT, "read voltage a channel at a subdevice","subdevice","subdevice number","channel", "channel number"); }(end)

The error is on the last commando, on addMethod. I don't know how many paramaeters I need to put at the commando.

Anybody already used a Method with more than one argument? What is the sintax?

)

Best Regards. Alexandre.

FIXING THE CODE!