TObject.h

Go to the documentation of this file.
00001 // @(#)root/base:$Id: TObject.h 34221 2010-06-30 10:23:33Z rdm $
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 
00016 //////////////////////////////////////////////////////////////////////////
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 //                                                                      //
00028 //////////////////////////////////////////////////////////////////////////
00029 
00030 #ifndef ROOT_Rtypes
00031 #include "Rtypes.h"
00032 #endif
00033 #ifndef ROOT_TStorage
00034 #include "TStorage.h"
00035 #endif
00036 #ifndef ROOT_TVersionCheck
00037 #include "TVersionCheck.h"
00038 #endif
00039 #ifndef ROOT_Riosfwd
00040 #include "Riosfwd.h"
00041 #endif
00042 #include <stdarg.h>
00043 
00044 #ifdef WIN32
00045 #undef RemoveDirectory
00046 #endif
00047 
00048 class TList;
00049 class TBrowser;
00050 class TBuffer;
00051 class TObjArray;
00052 class TMethod;
00053 class TTimer;
00054 
00055 
00056 class TObject {
00057 
00058 private:
00059    UInt_t         fUniqueID;   //object unique identifier
00060    UInt_t         fBits;       //bit field status word
00061 
00062    static Long_t  fgDtorOnly;    //object for which to call dtor only (i.e. no delete)
00063    static Bool_t  fgObjectStat;  //if true keep track of objects in TObjectTable
00064 
00065 protected:
00066    void MakeZombie() { fBits |= kZombie; }
00067    virtual void DoError(int level, const char *location, const char *fmt, va_list va) const;
00068 
00069 public:
00070    //----- Global bits (can be set for any object and should not be reused).
00071    //----- Bits 0 - 13 are reserved as global bits. Bits 14 - 23 can be used
00072    //----- in different class hierarchies (make sure there is no overlap in
00073    //----- any given hierarchy).
00074    enum EStatusBits {
00075       kCanDelete        = BIT(0),   // if object in a list can be deleted
00076       kMustCleanup      = BIT(3),   // if object destructor must call RecursiveRemove()
00077       kObjInCanvas      = BIT(3),   // for backward compatibility only, use kMustCleanup
00078       kIsReferenced     = BIT(4),   // if object is referenced by a TRef or TRefArray
00079       kHasUUID          = BIT(5),   // if object has a TUUID (its fUniqueID=UUIDNumber)
00080       kCannotPick       = BIT(6),   // if object in a pad cannot be picked
00081       kNoContextMenu    = BIT(8),   // if object does not want context menu
00082       kInvalidObject    = BIT(13)   // if object ctor succeeded but object should not be used
00083    };
00084 
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        SaveAs(const char *filename="",Option_t *option="") const; // *MENU*
00148    virtual void        SavePrimitive(ostream &out, Option_t *option = "");
00149    virtual void        SetDrawOption(Option_t *option="");  // *MENU*
00150    virtual void        SetUniqueID(UInt_t uid);
00151    virtual void        UseCurrentStyle();
00152    virtual Int_t       Write(const char *name=0, Int_t option=0, Int_t bufsize=0);
00153    virtual Int_t       Write(const char *name=0, Int_t option=0, Int_t bufsize=0) const;
00154 
00155    //----- operators
00156    void    *operator new(size_t sz) { return TStorage::ObjectAlloc(sz); }
00157    void    *operator new[](size_t sz) { return TStorage::ObjectAlloc(sz); }
00158    void    *operator new(size_t sz, void *vp) { return TStorage::ObjectAlloc(sz, vp); }
00159    void    *operator new[](size_t sz, void *vp) { return TStorage::ObjectAlloc(sz, vp); }
00160    void     operator delete(void *ptr);
00161    void     operator delete[](void *ptr);
00162 #ifdef R__PLACEMENTDELETE
00163    void     operator delete(void *ptr, void *vp);
00164    void     operator delete[](void *ptr, void *vp);
00165 #endif
00166 
00167    //----- bit manipulation
00168    void     SetBit(UInt_t f, Bool_t set);
00169    void     SetBit(UInt_t f) { fBits |= f & kBitMask; }
00170    void     ResetBit(UInt_t f) { fBits &= ~(f & kBitMask); }
00171    Bool_t   TestBit(UInt_t f) const { return (Bool_t) ((fBits & f) != 0); }
00172    Int_t    TestBits(UInt_t f) const { return (Int_t) (fBits & f); }
00173    void     InvertBit(UInt_t f) { fBits ^= f & kBitMask; }
00174 
00175    //---- error handling
00176    virtual void     Info(const char *method, const char *msgfmt, ...) const
00177 #if defined(__GNUC__) && !defined(__CINT__)
00178    __attribute__((format(printf, 3, 4)))   /* 1 is the this pointer */
00179 #endif
00180    ;
00181    virtual void     Warning(const char *method, const char *msgfmt, ...) const
00182 #if defined(__GNUC__) && !defined(__CINT__)
00183    __attribute__((format(printf, 3, 4)))   /* 1 is the this pointer */
00184 #endif
00185    ;
00186    virtual void     Error(const char *method, const char *msgfmt, ...) const
00187 #if defined(__GNUC__) && !defined(__CINT__)
00188    __attribute__((format(printf, 3, 4)))   /* 1 is the this pointer */
00189 #endif
00190    ;
00191    virtual void     SysError(const char *method, const char *msgfmt, ...) const
00192 #if defined(__GNUC__) && !defined(__CINT__)
00193    __attribute__((format(printf, 3, 4)))   /* 1 is the this pointer */
00194 #endif
00195    ;
00196    virtual void     Fatal(const char *method, const char *msgfmt, ...) const
00197 #if defined(__GNUC__) && !defined(__CINT__)
00198    __attribute__((format(printf, 3, 4)))   /* 1 is the this pointer */
00199 #endif
00200    ;
00201 
00202    void     AbstractMethod(const char *method) const;
00203    void     MayNotUse(const char *method) const;
00204 
00205    //---- static functions
00206    static Long_t    GetDtorOnly();
00207    static void      SetDtorOnly(void *obj);
00208    static Bool_t    GetObjectStat();
00209    static void      SetObjectStat(Bool_t stat);
00210 
00211    ClassDef(TObject,1)  //Basic ROOT object
00212 };
00213 
00214 // Global bits (can be set for any object and should not be reused).
00215 // Only here for backward compatibility reasons.
00216 // For detailed description see TObject::EStatusBits above.
00217 enum EObjBits {
00218    kCanDelete        = TObject::kCanDelete,
00219    kMustCleanup      = TObject::kMustCleanup,
00220    kObjInCanvas      = TObject::kObjInCanvas,
00221    kIsReferenced     = TObject::kIsReferenced,
00222    kHasUUID          = TObject::kHasUUID,
00223    kCannotPick       = TObject::kCannotPick,
00224    kNoContextMenu    = TObject::kNoContextMenu,
00225    kInvalidObject    = TObject::kInvalidObject
00226 };
00227 
00228 #ifndef ROOT_TBuffer
00229 #include "TBuffer.h"
00230 #endif
00231 
00232 #endif

Generated on Tue Jul 5 14:10:28 2011 for ROOT_528-00b_version by  doxygen 1.5.1