Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

TObject.h

Go to the documentation of this file.
00001 // @(#)root/base:$Name:  $:$Id: TObject.h,v 1.25 2003/05/01 07:42:36 brun Exp $
00002 // Author: Rene Brun   26/12/94
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TObject
00013 #define ROOT_TObject
00014 
00015 
00017 //                                                                      //
00018 // TObject                                                              //
00019 //                                                                      //
00020 // Mother of all ROOT objects.                                          //
00021 //                                                                      //
00022 // The TObject class provides default behaviour and protocol for all    //
00023 // objects in the ROOT system. It provides protocol for object I/O,     //
00024 // error handling, sorting, inspection, printing, drawing, etc.         //
00025 // Every object which inherits from TObject can be stored in the        //
00026 // ROOT collection classes.                                             //
00027 //                                                                      //
00029 
00030 #ifndef ROOT_Rtypes
00031 #include "Rtypes.h"
00032 #endif
00033 #ifndef ROOT_Varargs
00034 #include "Varargs.h"
00035 #endif
00036 #ifndef ROOT_TStorage
00037 #include "TStorage.h"
00038 #endif
00039 #ifndef ROOT_Riosfwd
00040 #include "Riosfwd.h"
00041 #endif
00042 
00043 #ifdef WIN32
00044 #undef RemoveDirectory
00045 #endif
00046 
00047 class TList;
00048 class TBrowser;
00049 class TBuffer;
00050 class TObjArray;
00051 class TMethod;
00052 class TTimer;
00053 
00054 
00055 //----- Global bits (can be set for any object and should not be reused).
00056 //----- Bits 0 - 13 are reserved as global bits. Bits 14 - 23 can be used
00057 //----- in different class hierarchies (make sure there is no overlap in
00058 //----- any given hierarchy).
00059 enum EObjBits {
00060    kCanDelete        = BIT(0),   // if object in a list can be deleted
00061    kMustCleanup      = BIT(3),   // if object destructor must call RecursiveRemove()
00062    kObjInCanvas      = BIT(3),   // for backward compatibility only, use kMustCleanup
00063    kIsReferenced     = BIT(4),   // if object is referenced by a TRef or TRefArray
00064    kHasUUID          = BIT(5),   // if object has a TUUID (its fUniqueID=UUIDNumber)
00065    kCannotPick       = BIT(6),   // if object in a pad cannot be picked
00066    kNoContextMenu    = BIT(8),   // if object does not want context menu
00067    kInvalidObject    = BIT(13)   // if object ctor succeeded but object should not be used
00068 };
00069 
00070 
00071 class TObject {
00072 
00073 private:
00074    UInt_t         fUniqueID;   //object unique identifier
00075    UInt_t         fBits;       //bit field status word
00076 
00077    static Long_t  fgDtorOnly;    //object for which to call dtor only (i.e. no delete)
00078    static Bool_t  fgObjectStat;  //if true keep track of objects in TObjectTable
00079 
00080 protected:
00081    void MakeZombie() { fBits |= kZombie; }
00082    virtual void DoError(int level, const char *location, const char *fmt, va_list va) const;
00083 
00084 public:
00085    //----- Private bits, clients can only test but not change them
00086    enum {
00087       kIsOnHeap      = 0x01000000,    // object is on heap
00088       kNotDeleted    = 0x02000000,    // object has not been deleted
00089       kZombie        = 0x04000000,    // object ctor failed
00090       kBitMask       = 0x00ffffff
00091    };
00092 
00093    //----- Write() options
00094    enum {
00095       kSingleKey     = BIT(0),        // write collection with single key
00096       kOverwrite     = BIT(1),        // overwrite existing object with same name
00097       kWriteDelete   = BIT(2)         // write object, then delete previous key with same name
00098    };
00099 
00100    TObject();
00101    TObject(const TObject &object);
00102    TObject &operator=(const TObject &rhs);
00103    virtual ~TObject();
00104 
00105    virtual void        AppendPad(Option_t *option="");
00106    virtual void        Browse(TBrowser *b);
00107    virtual const char *ClassName() const;
00108    virtual void        Clear(Option_t * /*option*/ ="") { }
00109    virtual TObject    *Clone(const char *newname="") const;
00110    virtual Int_t       Compare(const TObject *obj) const;
00111    virtual void        Copy(TObject &object) const;
00112    virtual void        Delete(Option_t *option=""); // *MENU*
00113    virtual Int_t       DistancetoPrimitive(Int_t px, Int_t py);
00114    virtual void        Draw(Option_t *option="");
00115    virtual void        DrawClass() const; // *MENU*
00116    virtual TObject    *DrawClone(Option_t *option="") const; // *MENU*
00117    virtual void        Dump() const; // *MENU*
00118    virtual void        Execute(const char *method,  const char *params, Int_t *error=0);
00119    virtual void        Execute(TMethod *method, TObjArray *params, Int_t *error=0);
00120    virtual void        ExecuteEvent(Int_t event, Int_t px, Int_t py);
00121    virtual TObject    *FindObject(const char *name) const;
00122    virtual TObject    *FindObject(const TObject *obj) const;
00123    virtual Option_t   *GetDrawOption() const;
00124    virtual UInt_t      GetUniqueID() const;
00125    virtual const char *GetName() const;
00126    virtual const char *GetIconName() const;
00127    virtual Option_t   *GetOption() const { return ""; }
00128    virtual char       *GetObjectInfo(Int_t px, Int_t py) const;
00129    virtual const char *GetTitle() const;
00130    virtual Bool_t      HandleTimer(TTimer *timer);
00131    virtual ULong_t     Hash() const;
00132    virtual Bool_t      InheritsFrom(const char *classname) const;
00133    virtual Bool_t      InheritsFrom(const TClass *cl) const;
00134    virtual void        Inspect() const; // *MENU*
00135    virtual Bool_t      IsFolder() const;
00136    virtual Bool_t      IsEqual(const TObject *obj) const;
00137    virtual Bool_t      IsSortable() const { return kFALSE; }
00138            Bool_t      IsOnHeap() const { return TestBit(kIsOnHeap); }
00139            Bool_t      IsZombie() const { return TestBit(kZombie); }
00140    virtual Bool_t      Notify();
00141    virtual void        ls(Option_t *option="") const;
00142    virtual void        Paint(Option_t *option="");
00143    virtual void        Pop();
00144    virtual void        Print(Option_t *option="") const;
00145    virtual Int_t       Read(const char *name);
00146    virtual void        RecursiveRemove(TObject *obj);
00147    virtual void        SavePrimitive(ofstream &out, Option_t *option);
00148    virtual void        SetDrawOption(Option_t *option="");  // *MENU*
00149    virtual void        SetUniqueID(UInt_t uid);
00150    virtual void        UseCurrentStyle();
00151    virtual Int_t       Write(const char *name=0, Int_t option=0, Int_t bufsize=0);
00152 
00153    //----- operators
00154    void    *operator new(size_t sz) { return TStorage::ObjectAlloc(sz); }
00155    void    *operator new[](size_t sz) { return TStorage::ObjectAlloc(sz); }
00156    void    *operator new(size_t sz, void *vp) { return TStorage::ObjectAlloc(sz, vp); }
00157    void    *operator new[](size_t sz, void *vp) { return TStorage::ObjectAlloc(sz, vp); }
00158    void     operator delete(void *ptr);
00159    void     operator delete[](void *ptr);
00160 #ifdef R__PLACEMENTDELETE
00161    void     operator delete(void *ptr, void *vp);
00162    void     operator delete[](void *ptr, void *vp);
00163 #endif
00164 
00165    //----- bit manipulation
00166    void     SetBit(UInt_t f, Bool_t set);
00167    void     SetBit(UInt_t f) { fBits |= f & kBitMask; }
00168    void     ResetBit(UInt_t f) { fBits &= ~(f & kBitMask); }
00169    Bool_t   TestBit(UInt_t f) const { return (Bool_t) ((fBits & f) != 0); }
00170    Int_t    TestBits(UInt_t f) const { return (Int_t) (fBits & f); }
00171    void     InvertBit(UInt_t f) { fBits ^= f & kBitMask; }
00172 
00173    //---- error handling
00174    virtual void     Info(const char *method, const char *msgfmt, ...) const;
00175    virtual void     Warning(const char *method, const char *msgfmt, ...) const;
00176    virtual void     Error(const char *method, const char *msgfmt, ...) const;
00177    virtual void     SysError(const char *method, const char *msgfmt, ...) const;
00178    virtual void     Fatal(const char *method, const char *msgfmt, ...) const;
00179 
00180    void     AbstractMethod(const char *method) const;
00181    void     MayNotUse(const char *method) const;
00182 
00183    //---- static functions
00184    static Long_t    GetDtorOnly();
00185    static void      SetDtorOnly(void *obj);
00186    static Bool_t    GetObjectStat();
00187    static void      SetObjectStat(Bool_t stat);
00188 
00189    ClassDef(TObject,1)  //Basic ROOT object
00190 };
00191 
00192 #ifndef ROOT_TBuffer
00193 #include "TBuffer.h"
00194 #endif
00195 
00196 #endif

Generated on Thu Dec 18 14:52:22 2003 for ROOT by doxygen1.2.16