Logo ROOT  
Reference Guide
TQObject Class Reference

This is the ROOT implementation of the Qt object communication mechanism (see also http://www.troll.no/qt/metaobjects.html)

Signals and slots are used for communication between objects. When an object has changed in some way that might be interesting for the outside world, it emits a signal to tell whoever is listening. All slots that are connected to this signal will be activated (called). It is even possible to connect a signal directly to another signal (this will emit the second signal immediately whenever the first is emitted.) There is no limitation on the number of slots that can be connected to a signal. The slots will be activated in the order they were connected to the signal. This mechanism allows objects to be easily reused, because the object that emits a signal does not need to know to which objects the signals are connected. Together, signals and slots make up a powerfull component programming mechanism.

Signals

virtual void Destroyed()
Definition: TQObject.h:196

Signal emitted when object is destroyed. This signal could be connected to some garbage-collector object.

ChangedBy(const char *method_name)
virtual void ChangedBy(const char *method)
Definition: TQObject.h:198

This signal is emitted when some important data members of the object were changed. method_name parameter can be used as an identifier of the modifier method.

Message(const char *msg)
virtual void Message(const char *msg)
Definition: TQObject.h:200

General purpose message signal

Definition at line 48 of file TQObject.h.

Public Member Functions

 TQObject ()
 TQObject Constructor. More...
 
virtual ~TQObject ()
 TQObject Destructor. More...
 
Bool_t AreSignalsBlocked () const
 
Bool_t BlockSignals (Bool_t b)
 
virtual void ChangedBy (const char *method)
 
void CollectClassSignalLists (TList &list, TClass *cls)
 Collect class signal lists from class cls and all its base-classes. More...
 
Bool_t Connect (const char *signal, const char *receiver_class, void *receiver, const char *slot)
 Non-static method is used to connect from the signal of this object to the receiver slot. More...
 
virtual void Connected (const char *)
 
virtual void Destroyed ()
 
Bool_t Disconnect (const char *signal=0, void *receiver=0, const char *slot=0)
 Disconnects signal of this object from slot of receiver. More...
 
virtual void Disconnected (const char *)
 
void Emit (const char *signal)
 Acitvate signal without args. More...
 
template<typename T >
void Emit (const char *signal, const T &arg)
 Activate signal with single parameter. More...
 
template<typename... T>
void EmitVA (const char *signal_name, Int_t, const T &... params)
 Emit a signal with a varying number of arguments. More...
 
TListGetListOfClassSignals () const
 Returns pointer to list of signals of this class. More...
 
TListGetListOfConnections () const
 
TListGetListOfSignals () const
 
virtual Bool_t HasConnection (const char *signal_name) const
 Return true if there is any object connected to this signal. More...
 
virtual void HighPriority (const char *signal_name, const char *slot_name=0)
 
virtual void LowPriority (const char *signal_name, const char *slot_name=0)
 
virtual void Message (const char *msg)
 
virtual Int_t NumberOfConnections () const
 Return number of connections for this object. More...
 
virtual Int_t NumberOfSignals () const
 Return number of signals for this object. More...
 

Static Public Member Functions

static Bool_t AreAllSignalsBlocked ()
 Returns true if all signals are blocked. More...
 
static Bool_t BlockAllSignals (Bool_t b)
 Block or unblock all signals. Returns the previous block status. More...
 
static Bool_t Connect (const char *sender_class, const char *signal, const char *receiver_class, void *receiver, const char *slot)
 This method allows to make a connection from any object of the same class to a single slot. More...
 
static Bool_t Connect (TQObject *sender, const char *signal, const char *receiver_class, void *receiver, const char *slot)
 Create connection between sender and receiver. More...
 
static Bool_t Disconnect (const char *class_name, const char *signal, void *receiver=0, const char *slot=0)
 Disconnects "class signal". More...
 
static Bool_t Disconnect (TQObject *sender, const char *signal=0, void *receiver=0, const char *slot=0)
 Disconnects signal in object sender from slot_method in object receiver. More...
 

Protected Member Functions

virtual voidGetSender ()
 
virtual const char * GetSenderClassName () const
 

Static Protected Member Functions

static Int_t CheckConnectArgs (TQObject *sender, TClass *sender_class, const char *signal, TClass *receiver_class, const char *slot)
 Checking of consitency of sender/receiver methods/arguments. More...
 
static TString CompressName (const char *method_name)
 Removes "const" words and blanks from full (with prototype) method name and resolve any typedefs in the method signature. More...
 
static Bool_t ConnectToClass (const char *sender_class, const char *signal, TClass *receiver_class, void *receiver, const char *slot)
 This method allows to make connection from any object of the same class to the receiver object. More...
 
static Bool_t ConnectToClass (TQObject *sender, const char *signal, TClass *receiver_class, void *receiver, const char *slot)
 Create connection between sender and receiver. More...
 

Protected Attributes

TListfListOfConnections
 list of signals from this object More...
 
TListfListOfSignals
 
Bool_t fSignalsBlocked
 list of connections to this object More...
 

Static Protected Attributes

static Bool_t fgAllSignalsBlocked = kFALSE
 flag used for suppression of signals More...
 

Private Member Functions

 TQObject (const TQObject &tqo)
 
TQObjectoperator= (const TQObject &tqo)
 

#include <TQObject.h>

Inheritance diagram for TQObject:
[legend]

Constructor & Destructor Documentation

◆ TQObject() [1/2]

TQObject::TQObject ( const TQObject tqo)
private

◆ TQObject() [2/2]

TQObject::TQObject ( )

TQObject Constructor.

Comment:

  • In order to minimize memory allocation fListOfSignals and fListOfConnections are allocated only if it is neccesary
  • When fListOfSignals/fListOfConnections are empty they will be deleted

Definition at line 393 of file TQObject.cxx.

◆ ~TQObject()

TQObject::~TQObject ( )
virtual

TQObject Destructor.

  • delete all connections and signal list

Definition at line 404 of file TQObject.cxx.

Member Function Documentation

◆ AreAllSignalsBlocked()

Bool_t TQObject::AreAllSignalsBlocked ( )
static

Returns true if all signals are blocked.

Definition at line 1047 of file TQObject.cxx.

◆ AreSignalsBlocked()

Bool_t TQObject::AreSignalsBlocked ( ) const
inline

Definition at line 91 of file TQObject.h.

◆ BlockAllSignals()

Bool_t TQObject::BlockAllSignals ( Bool_t  b)
static

Block or unblock all signals. Returns the previous block status.

Definition at line 1055 of file TQObject.cxx.

◆ BlockSignals()

Bool_t TQObject::BlockSignals ( Bool_t  b)
inline

Definition at line 92 of file TQObject.h.

◆ ChangedBy()

virtual void TQObject::ChangedBy ( const char *  method)
inlinevirtual

Definition at line 198 of file TQObject.h.

◆ CheckConnectArgs()

Int_t TQObject::CheckConnectArgs ( TQObject sender,
TClass sender_class,
const char *  signal,
TClass receiver_class,
const char *  slot 
)
staticprotected

Checking of consitency of sender/receiver methods/arguments.

Returns -1 on error, otherwise number or arguments of signal function. Static method.

Definition at line 181 of file TQObject.cxx.

◆ CollectClassSignalLists()

void TQObject::CollectClassSignalLists ( TList list,
TClass cls 
)

Collect class signal lists from class cls and all its base-classes.

The recursive traversal is not performed for classes not deriving from TQClass.

Definition at line 451 of file TQObject.cxx.

◆ CompressName()

TString TQObject::CompressName ( const char *  method_name)
staticprotected

Removes "const" words and blanks from full (with prototype) method name and resolve any typedefs in the method signature.

If a null or empty string is passed in, an empty string is returned.

Example:

CompressName(" Draw(const char *, const char *,
Option_t * , Int_t , Int_t)");
static TString CompressName(const char *method_name)
Removes "const" words and blanks from full (with prototype) method name and resolve any typedefs in t...
Definition: TQObject.cxx:100

returns the string "Draw(char*,char*,char*,int,int)".

Definition at line 100 of file TQObject.cxx.

◆ Connect() [1/3]

Bool_t TQObject::Connect ( const char *  class_name,
const char *  signal,
const char *  cl,
void receiver,
const char *  slot 
)
static

This method allows to make a connection from any object of the same class to a single slot.

Signal and slot string must have a form: "Draw(char*, Option_t* ,Int_t)" All blanks and "const" words will be removed,

cl != 0 - class name, it can be class with or without dictionary, e.g interpreted class. Example:

TGButton *myButton;
TH2F *myHist;
TQObject::Connect("TGButton", "Clicked()",
"TH2F", myHist, "Draw(Option_t*)");
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:251
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition: TQObject.cxx:867

cl == 0 - corresponds to function (interpereted or global) the name of the function is defined by the slot string, parameter receiver should be 0. Example:

TGButton *myButton;
TH2F *myHist;
TQObject::Connect("TGButton", "Clicked()",
0, 0, "hsimple()");

Warning:

If receiver class not derived from TQObject and going to be deleted, disconnect all connections to this receiver. In case of class derived from TQObject it is done automatically.

Definition at line 793 of file TQObject.cxx.

◆ Connect() [2/3]

Bool_t TQObject::Connect ( const char *  signal,
const char *  receiver_class,
void receiver,
const char *  slot 
)

Non-static method is used to connect from the signal of this object to the receiver slot.

Warning! No check on consistency of sender/receiver classes/methods.

This method makes possible to have connection/signals from interpreted class. See also RQ_OBJECT.h.

Definition at line 867 of file TQObject.cxx.

◆ Connect() [3/3]

Bool_t TQObject::Connect ( TQObject sender,
const char *  signal,
const char *  cl,
void receiver,
const char *  slot 
)
static

Create connection between sender and receiver.

Signal and slot string must have a form: "Draw(char*, Option_t* ,Int_t)" All blanks and "const" words will be removed,

cl != 0 - class name, it can be class with or without dictionary, e.g interpreted class. Example:

TGButton *myButton;
TH2F *myHist;
TQObject::Connect(myButton,"Clicked()",
"TH2F", myHist,"Draw(Option_t*)");

cl == 0 - corresponds to function (interpereted or global) the name of the function is defined by the slot string, parameter receiver should be 0. Example:

TGButton *myButton;
TH2F *myHist;
TQObject::Connect(myButton,"Clicked()",
0, 0,"hsimple()");

Warning: If receiver is class not derived from TQObject and going to be deleted, disconnect all connections to this receiver. In case of class derived from TQObject it is done automatically.

Definition at line 701 of file TQObject.cxx.

◆ Connected()

virtual void TQObject::Connected ( const char *  )
inlinevirtual

Definition at line 193 of file TQObject.h.

◆ ConnectToClass() [1/2]

Bool_t TQObject::ConnectToClass ( const char *  class_name,
const char *  signal,
TClass cl,
void receiver,
const char *  slot 
)
staticprotected

This method allows to make connection from any object of the same class to the receiver object.

Receiver class needs to have a dictionary.

Definition at line 617 of file TQObject.cxx.

◆ ConnectToClass() [2/2]

Bool_t TQObject::ConnectToClass ( TQObject sender,
const char *  signal,
TClass cl,
void receiver,
const char *  slot 
)
staticprotected

Create connection between sender and receiver.

Receiver class needs to have a dictionary.

Definition at line 561 of file TQObject.cxx.

◆ Destroyed()

virtual void TQObject::Destroyed ( )
inlinevirtual

Reimplemented in TQConnection.

Definition at line 196 of file TQObject.h.

◆ Disconnect() [1/3]

Bool_t TQObject::Disconnect ( const char *  class_name,
const char *  signal,
void receiver = 0,
const char *  slot = 0 
)
static

Disconnects "class signal".

The class is defined by class_name. See also Connect(class_name,signal,receiver,slot).

Definition at line 1006 of file TQObject.cxx.

◆ Disconnect() [2/3]

Bool_t TQObject::Disconnect ( const char *  signal = 0,
void receiver = 0,
const char *  slot = 0 
)

Disconnects signal of this object from slot of receiver.

Equivalent to Disconnect(this, signal, receiver, slot)

Definition at line 1025 of file TQObject.cxx.

◆ Disconnect() [3/3]

Bool_t TQObject::Disconnect ( TQObject sender,
const char *  signal = 0,
void receiver = 0,
const char *  slot = 0 
)
static

Disconnects signal in object sender from slot_method in object receiver.

For objects derived from TQObject signal-slot connection is removed when either of the objects involved are destroyed.

Disconnect() is typically used in three ways, as the following examples shows:

  • Disconnect everything connected to an object's signals:
    Disconnect(myObject);
    Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
    Disconnects signal of this object from slot of receiver.
    Definition: TQObject.cxx:1025
  • Disconnect everything connected to a signal:
    Disconnect(myObject, "mySignal()");
  • Disconnect a specific receiver:
    Disconnect(myObject, 0, myReceiver, 0);

0 may be used as a wildcard in three of the four arguments, meaning "any signal", "any receiving object" or "any slot in the receiving object", respectively.

The sender has no default and may never be 0 (you cannot disconnect signals from more than one object).

If signal is 0, it disconnects receiver and slot_method from any signal. If not, only the specified signal is disconnected.

If receiver is 0, it disconnects anything connected to signal. If not, slots in objects other than receiver are not disconnected

If slot_method is 0, it disconnects anything that is connected to receiver. If not, only slots named slot_method will be disconnected, and all other slots are left alone. The slot_method must be 0 if receiver is left out, so you cannot disconnect a specifically-named slot on all objects.

Definition at line 958 of file TQObject.cxx.

◆ Disconnected()

virtual void TQObject::Disconnected ( const char *  )
inlinevirtual

Definition at line 194 of file TQObject.h.

◆ Emit() [1/2]

void TQObject::Emit ( const char *  signal)
inline

Acitvate signal without args.

Example: theButton->Emit("Clicked()");

Definition at line 173 of file TQObject.h.

◆ Emit() [2/2]

template<typename T >
void TQObject::Emit ( const char *  signal,
const T &  arg 
)
inline

Activate signal with single parameter.

Example:

theButton->Emit("Progress(Long64_t)",processed)

If we call Emit with an array of the parameters, they 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);
long Long_t
Definition: RtypesCore.h:50
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:571
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Definition: TQObject.h:48
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164

Definition at line 164 of file TQObject.h.

◆ EmitVA()

template<typename... T>
void TQObject::EmitVA ( const char *  signal_name,
Int_t  ,
const T &...  params 
)
inline

Emit a signal with a varying number of arguments.

Definition at line 100 of file TQObject.h.

◆ GetListOfClassSignals()

TList * TQObject::GetListOfClassSignals ( ) const

Returns pointer to list of signals of this class.

Definition at line 435 of file TQObject.cxx.

◆ GetListOfConnections()

TList * TQObject::GetListOfConnections ( ) const
inline

Definition at line 89 of file TQObject.h.

◆ GetListOfSignals()

TList * TQObject::GetListOfSignals ( ) const
inline

Definition at line 88 of file TQObject.h.

◆ GetSender()

virtual void * TQObject::GetSender ( )
inlineprotectedvirtual

◆ GetSenderClassName()

virtual const char * TQObject::GetSenderClassName ( ) const
inlineprotectedvirtual

Reimplemented in TQObjSender.

Definition at line 58 of file TQObject.h.

◆ HasConnection()

Bool_t TQObject::HasConnection ( const char *  signal_name) const
virtual

Return true if there is any object connected to this signal.

Only checks for object signals.

Definition at line 525 of file TQObject.cxx.

◆ HighPriority()

void TQObject::HighPriority ( const char *  signal_name,
const char *  slot_name = 0 
)
virtual
  1. If slot_name = 0 => makes signal defined by the signal_name to be the first in the fListOfSignals, this decreases the time for lookup.
  2. If slot_name != 0 => makes slot defined by the slot_name to be executed first when signal_name is emitted. Signal name is not compressed.

Definition at line 477 of file TQObject.cxx.

◆ LowPriority()

void TQObject::LowPriority ( const char *  signal_name,
const char *  slot_name = 0 
)
virtual
  1. If slot_name = 0 => makes signal defined by the signal_name to be the last in the fListOfSignals, this increase the time for lookup.
  2. If slot_name != 0 => makes slot defined by the slot_name to be executed last when signal_name is emitted. Signal name is not compressed.

Definition at line 503 of file TQObject.cxx.

◆ Message()

virtual void TQObject::Message ( const char *  msg)
inlinevirtual

Reimplemented in TTreeViewer.

Definition at line 200 of file TQObject.h.

◆ NumberOfConnections()

Int_t TQObject::NumberOfConnections ( ) const
virtual

Return number of connections for this object.

Definition at line 549 of file TQObject.cxx.

◆ NumberOfSignals()

Int_t TQObject::NumberOfSignals ( ) const
virtual

Return number of signals for this object.

Only checks for object signals.

Definition at line 539 of file TQObject.cxx.

◆ operator=()

TQObject & TQObject::operator= ( const TQObject tqo)
private

Member Data Documentation

◆ fgAllSignalsBlocked

Bool_t TQObject::fgAllSignalsBlocked = kFALSE
staticprotected

flag used for suppression of signals

Definition at line 55 of file TQObject.h.

◆ fListOfConnections

TList* TQObject::fListOfConnections
protected

list of signals from this object

Definition at line 52 of file TQObject.h.

◆ fListOfSignals

TList* TQObject::fListOfSignals
protected

Definition at line 51 of file TQObject.h.

◆ fSignalsBlocked

Bool_t TQObject::fSignalsBlocked
protected

list of connections to this object

Definition at line 53 of file TQObject.h.


The documentation for this class was generated from the following files: