00001 // @(#)root/base:$Id: TMemberStreamer.h 25450 2008-09-18 21:13:42Z pcanal $ 00002 // Author: Victor Perev and Philippe Canal 08/05/02 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2003, Rene Brun, Fons Rademakers and al. * 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_TMemberStreamer 00013 #define ROOT_TMemberStreamer 00014 00015 #include "Rtypes.h" 00016 #include "TClassRef.h" 00017 00018 ////////////////////////////////////////////////////////////////////////// 00019 // // 00020 // TMemberStreamer is used to stream a data member. // 00021 // // 00022 // The address passed to operator() will be the address of the data // 00023 // member. // 00024 // // 00025 ////////////////////////////////////////////////////////////////////////// 00026 00027 class TMemberStreamer { 00028 protected: 00029 TMemberStreamer() : fStreamer(0) {}; 00030 00031 public: 00032 TMemberStreamer(MemberStreamerFunc_t pointer) : fStreamer(pointer) {}; 00033 TMemberStreamer(const TMemberStreamer &rhs) : fStreamer(rhs.fStreamer) {}; 00034 00035 virtual ~TMemberStreamer(){}; 00036 00037 virtual void SetOnFileClass( const TClass* cl ) { fOnFileClass = const_cast<TClass*>(cl); } 00038 virtual const TClass* GetOnFileClass() const { return fOnFileClass; } 00039 00040 virtual void operator()(TBuffer &b, void *pmember, Int_t size=0) 00041 { 00042 // The address passed to operator() will be the address of the data member. 00043 // If the data member is a variable size array, 'size' is the number of elements 00044 // to read/write 00045 00046 (*fStreamer)(b,pmember,size); 00047 } 00048 00049 private: 00050 MemberStreamerFunc_t fStreamer; 00051 TClassRef fOnFileClass; 00052 }; 00053 00054 #endif