Sending more than one double signal

Hello Rooters,

a litte question about the signal/slot mechanism. If I want a signal that emits two or more doubles, how would I create it?

I tried the following

MyClass::DoubleSignal(double first, double second)
{
   Long_t args[2];

   args[0] = (Long_t) first;
   args[1] = (Long_t) second;

   Emit("DoubleSignal(double,double)",args);
}

Unfortunatly this doesn’t work. The slot function does not get the right values.

MyOtherClass::ReceiveDoubleSignal(double rfist, double rsecond)
{
   cout << rfirst<<" "<<rsecond<<endl;
}

I connected both with the following command:

myclass->Connect("DoubleSignal(double,double)","MyOtherClass",otherclass,"ReceiveDoubleSignal(double, double)");

Maybe I am missing something obvious.
I was reading root.cern.ch/root/HowtoSignalSlot.html, but this didn’t help me out.

Thank you

Lutz

Hi Lutz,

Did you declare the DoubleSignal as // SIGNAL in the header file?

Cheers, Ilka

Hi Lutz,

Just additional info according to the Reference guide:

void TQObject::Emit(const char *signal_name, Long_t *paramArr)

Emit a signal with a varying number of arguments,
paramArr is an array of the parameters.
Note: any parameter should be converted to long type.
Example:
TQObject *processor; // data processor
TH1F *hist; // filled with processor results

processor->Connect("Evaluated(Float_t,Float_t)",
                   "TH1F",hist,"Fill12(Axis_t,Axis_t)");

Long_t args[2];
args[0] = (Long_t)processor->GetValue(1);
args[1] = (Long_t)processor->GetValue(2);

processor->Emit("Evaluated(Float_t,Float_t)",args);

Cheers, Ilka

Hi Ilka,

Yes, I did.

[quote]void TQObject::Emit(const char *signal_name, Long_t *paramArr)

Emit a signal with a varying number of arguments,
paramArr is an array of the parameters.
Note: any parameter should be converted to long type.
Example:
TQObject *processor; // data processor
TH1F *hist; // filled with processor results

processor->Connect(“Evaluated(Float_t,Float_t)”,
“TH1F”,hist,“Fill12(Axis_t,Axis_t)”);

Long_t args[2];
args[0] = (Long_t)processor->GetValue(1);
args[1] = (Long_t)processor->GetValue(2);

processor->Emit(“Evaluated(Float_t,Float_t)”,args); [/quote]

Well, I did convert the parameters to a Long_t. You will see that when you look at the example, that I’ve sent with the first post.

I believe that the signal will work with floats, because floats are represented by 32Bit, same as longs. But doubles are 64Bit variables, and I was wondering that this might be the problem with sending doubles. But how can one sent doubles using the signal/slot mechanism? Or is it only possible to send floats?

Thank you

Lutz

Hi Lutz,

I will check how the signals/slots mechanizm works with Double_t and will let you know.

Cheers, Ilka

Hi,
does this solution help?

Regards. Valeriy

Hi Valeriy,

I was thinking about this solution myself. But unfortunatly this will make things more complicated than they already are. But if there is no way to send more than one double, exept for a double array, then I have to rewrite the classes.

I already tried also the following:

[code]
Long_t args[2]

args[0] = (Long_t) &first;
args[1] = (Long_t) &second;[/code]
This works, if one has the follwing Signal:

void MyClass::DoubleSignal(double *first, double *second)

But again, it will make things more complicated for me. And I was just wondering wether there is something obvious, that I am missing in sending more than one double.

Thank you

Lutz

Hi Lutz,
the limitation with “doubles” is on
CINT lower level. Now it’s possible
to execute “pointers to longs” only.
I’ll try to discuss this problem with Masa.

As far as I understood you have problem
with sending several doubles in signal to some class method which is not possible
to change (it could be compiled class).
Is it true?

… for me not clear how to solve it …

Regards. Valeriy

Hi Valeriy,

[quote]As far as I understood you have problem
with sending several doubles in signal to some class method which is not possible
to change (it could be compiled class).
Is it true? [/quote]

Not exactly. I can change the class method. But it takes some time to rewrite it, so that everything is working again. It is just a lot of work :frowning:
Thats why I was wondering wether I am doing something wrong, or with root it is not possible to accomplish what I was trying to do.
I think I will stick to what you suggested earlier, sending a the doubles in an array.

Thank you,

Lutz