00001 // @(#)root/io:$Id: TVirtualArray.h 25450 2008-09-18 21:13:42Z pcanal $ 00002 // Author: Philippe Canal July, 2008 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_TVirtualArray 00013 #define ROOT_TVirtualArray 00014 00015 00016 ////////////////////////////////////////////////////////////////////////// 00017 // // 00018 // TVirtualArray // 00019 // // 00020 // Wrapper around an object and giving indirect access to its content // 00021 // even if the object is not of a class in the Cint/Reflex dictionary. // 00022 // // 00023 ////////////////////////////////////////////////////////////////////////// 00024 00025 #include "TClassRef.h" 00026 00027 class TVirtualArray { 00028 public: 00029 TClassRef fClass; 00030 UInt_t fSize; 00031 char *fArray; //[fSize] 00032 00033 TVirtualArray( TClass *cl, UInt_t size ) : fClass(cl), fSize(size), fArray( (char*)( cl ? cl->NewArray(size) : 0) ) {}; 00034 ~TVirtualArray() { if (fClass) fClass->DeleteArray( fArray ); } 00035 00036 TClass *GetClass() { return fClass; } 00037 char *operator[](UInt_t ind) const { return GetObjectAt(ind); } 00038 char *GetObjectAt(UInt_t ind) const { return fArray+fClass->Size()*ind; } 00039 00040 }; 00041 00042 #endif // ROOT_TVirtualArray