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

TArray.h

Go to the documentation of this file.
00001 // @(#)root/cont:$Name:  $:$Id: TArray.h,v 1.7 2002/07/25 18:03:46 rdm Exp $
00002 // Author: Fons Rademakers   21/10/97
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_TArray
00013 #define ROOT_TArray
00014 
00015 
00017 //                                                                      //
00018 // TArray                                                               //
00019 //                                                                      //
00020 // Abstract array base class. Used by TArrayC, TArrayS, TArrayI,        //
00021 // TArrayL, TArrayF and TArrayD.                                        //
00022 // Data member is public for historical reasons.                        //
00023 //                                                                      //
00025 
00026 #ifndef ROOT_Htypes
00027 #include "Htypes.h"
00028 #endif
00029 #include <string.h>
00030 
00031 class TBuffer;
00032 
00033 
00034 class TArray {
00035 
00036 protected:
00037    Bool_t        BoundsOk(const char *where, Int_t at) const;
00038    Bool_t        OutOfBoundsError(const char *where, Int_t i) const;
00039 
00040 public:
00041    Int_t     fN;            //Number of array elements
00042 
00043    TArray() { fN = 0; }
00044    TArray(Int_t n) { fN = n; }
00045    TArray(const TArray &a) { fN = a.fN; }
00046    TArray         &operator=(const TArray &rhs) { fN = rhs.fN; return *this; }
00047    virtual        ~TArray() { fN = 0; }
00048 
00049    Int_t          GetSize() const { return fN; }
00050    virtual void   Set(Int_t n) = 0;
00051 
00052    static TArray *ReadArray(TBuffer &b, const TClass *clReq);
00053    static void    WriteArray(TBuffer &b, const TArray *a);
00054 
00055    friend TBuffer &operator<<(TBuffer &b, const TArray *obj);
00056 
00057    ClassDef(TArray,1)  //Abstract array base class
00058 };
00059 
00060 #if defined R__TEMPLATE_OVERLOAD_BUG
00061 template <>
00062 #endif
00063 inline TBuffer &operator>>(TBuffer &buf, TArray *&obj)
00064 {
00065    // Read TArray object from buffer.
00066 
00067    obj = (TArray *) TArray::ReadArray(buf, TArray::Class());
00068    return buf;
00069 }
00070 
00071 #if defined R__TEMPLATE_OVERLOAD_BUG
00072 template <>
00073 #endif
00074 TBuffer &operator<<(TBuffer &b, const TArray *obj);
00075 
00076 inline Bool_t TArray::BoundsOk(const char *where, Int_t at) const
00077 {
00078    return (at < 0 || at >= fN)
00079                   ? OutOfBoundsError(where, at)
00080                   : kTRUE;
00081 }
00082 
00083 #endif

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