Re: [ROOT] TObject user bits

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sat Sep 20 2003 - 10:55:44 MEST


John,

The information in TObject.h is correct:

 Global bits (can be set for any object and should not be reused).
 Bits 0 - 13 are reserved as global bits. Bits 14 - 23 can be used
 in different class hierarchies (make sure there is no overlap in
 any given hierarchy).

Note that you do not set bit 18 bit SetBit(18) but with SetBit(1<<18).
It is convenient to use the macro BIT(i) to set a enum with the selected 
bit. We have plenty of examples in the ROOT classes. See TH1.h for 
example. I mention this example just to show that the ROOT classes
may use some of the forbidden bits. You should not use these bits
for your classes.
As you say using the TObject bits is an interesting feature:
 -no need to add new data members for boolean types
 -no need to change the ClassDef version if you decide to use a new bit
 -possibility to test with maksk bits instead of if (a &&b &7c)
 -you save space in short objects

Rene Brun

 On Fri, 19 Sep 2003, Frankland 
John wrote:

> Hi ROOT-fiends
> 
> I'm having some trouble understanding the so-called "user bits" in TObject.
> I would like to have a TObject-derived object in which I use the 
> existing bits as
> flags rather than adding extra member variables, like this:
> 
> class BitClass : public TObject
> {
> public:
>     SetOn() { SetBit(0); };
>     SetOff() { ResetBit(0); };
>     GetStatus() { return TestBit(0); };
> }
> 
> The question is : which bit numbers can I use with Set/Test/ResetBit ?
> According to the TObject ctor doc "the high 8 bits are reserved for 
> system usage and the low 24 bits are user settable".
> But in TObject.h I see
> 
> //----- Global bits (can be set for any object and should not be reused).
> //----- Bits 0 - 13 are reserved as global bits. Bits 14 - 23 can be used
> //----- in different class hierarchies (make sure there is no overlap in
> //----- any given hierarchy).
> 
> D'ou slight confusion in my head. Sorry if this is trivial, but I have 
> another "bit" question:
> which are the "high 8 bits" ? SetBit(0) through to SetBit(7) or 
> SetBit(25) through to SetBit(32) ?
> 
> Thanks a lot
> John
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:15 MET