Hi Stefano, to use signal/slot communication a class containing the slots needs to have a dictionary (i.e. it must be known to the interpreter). In case you interpret class timer (.L timer3.C) it implicitely has a dictionary since it is loaded by CINT. When you compile it it does not automatically have a dictionary. The solution is to add ClassDef/ClassImp, run rootcint and compile and link the generated dictionary to your application. In the latest version of ROOT you will get an error message, in the compiled version, saying that slot TimeOut() does not exist instead of total silence in the previous version. Cheers, Fons. Stefano Argiro' wrote: > hi, > > could somebody explain to the ignorants (myself) > why the interpreted class timer (as in timer3.C below) does what I want > (prints "Timeout ! " > every 1 sec), > while the compiled class timer (as in timer2.C) does not ? (root v3.0) > > > > > Thanks > Stefano > > > > ---------------------------------------------------------- > Stefano Argiro', Ph.D. > University of Turin, Experimental Physics Department > and INFN > via P. Giuria 1 > 10125 Torino > Italy > > tel +39-011-670-7334 > fax +39-011-669-1104 > > > > > > File timer3.C > ----------------------------------------------------------------- > // interpret it ! . > // .L timer3.C > // timer * t = new timer; > // prints "Timeout !" every second > > class timer { > private: > > TTimer *ftim; > > public: > > timer (){ > > ftim = new TTimer(1000); > ftim->Connect("Timeout","timer", this, "TimeOut()"); > > // gSystem->AddTimer(ftim); > // ftim->TurnOn(); > ftim->Start(); > } > > void TimeOut(){cout << "Timeout !"<<endl;} > > }; > > ------------------------------------------------------------------------ > File timer2.C > ------------------------------------------------------------------------ > > > #include "TTimer.h" > #include "TROOT.h" > #include "TApplication.h" > #include "TSystem.h" > #include <iostream.h> > > > /* Compile with > > gcc -I $ROOTSYS/include -L$ROOTSYS/lib -lCore \ > -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript \ > -lMatrix -lPhysics -lm -ldl -lpthread -rdynamic -lm -ldl -rdynamic > -lThread\ > -o prova timer2.C > > does nothing ! > > */ > > class timer { > private: > > TTimer *ftim; > > public: > > timer (){ > > ftim = new TTimer(1000); > ftim->Connect("Timeout","timer", this, "TimeOut()"); > > // gSystem->AddTimer(ftim); > // ftim->TurnOn(); > ftim->Start(); > } > > void TimeOut(){cout << "Timeout !"<<endl;} > > }; > > > > int main (int argc, char ** argv ){ > > TROOT r("p","q"); > TApplication *app = new TApplication("App", &argc, argv,NULL,0); > > cout << "creating and starting timer" <<endl; > > timer *t = new timer; > > gSystem->ProcessEvents(); > > app->Run(); > > > // while (1); > > return 1; > } > > -- Org: CERN, European Laboratory for Particle Physics. Mail: 1211 Geneve 23, Switzerland E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248 WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7679480
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:11 MET