00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TArray
00013 #define ROOT_TArray
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ROOT_Rtypes
00027 #include "Rtypes.h"
00028 #endif
00029 #include <string.h>
00030
00031 class TBuffer;
00032
00033 class TArray {
00034
00035 protected:
00036 Bool_t BoundsOk(const char *where, Int_t at) const;
00037 Bool_t OutOfBoundsError(const char *where, Int_t i) const;
00038
00039 public:
00040 Int_t fN;
00041
00042 TArray(): fN(0) { }
00043 TArray(Int_t n): fN(n) { }
00044 TArray(const TArray &a): fN(a.fN) { }
00045 TArray &operator=(const TArray &rhs)
00046 {if(this!=&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 virtual Double_t GetAt(Int_t i) const = 0;
00053 virtual void SetAt(Double_t v, Int_t i) = 0;
00054
00055 static TArray *ReadArray(TBuffer &b, const TClass *clReq);
00056 static void WriteArray(TBuffer &b, const TArray *a);
00057
00058 friend TBuffer &operator<<(TBuffer &b, const TArray *obj);
00059
00060 ClassDef(TArray,1)
00061 };
00062
00063 #if defined R__TEMPLATE_OVERLOAD_BUG
00064 template <>
00065 #endif
00066 inline TBuffer &operator>>(TBuffer &buf, TArray *&obj)
00067 {
00068
00069
00070 obj = (TArray *) TArray::ReadArray(buf, TArray::Class());
00071 return buf;
00072 }
00073
00074 #if defined R__TEMPLATE_OVERLOAD_BUG
00075 template <>
00076 #endif
00077 TBuffer &operator<<(TBuffer &b, const TArray *obj);
00078
00079 inline Bool_t TArray::BoundsOk(const char *where, Int_t at) const
00080 {
00081 return (at < 0 || at >= fN)
00082 ? OutOfBoundsError(where, at)
00083 : kTRUE;
00084 }
00085
00086 #endif