// @(#)root/tree:$Name: $:$Id: TLeafB.cxx,v 1.1.1.1 2000/05/16 17:00:45 rdm Exp $
// Author: Rene Brun 12/01/96
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
//////////////////////////////////////////////////////////////////////////
// //
// A TLeaf for an 8 bit Integer data type. //
//////////////////////////////////////////////////////////////////////////
#include "TLeafB.h"
#include "TBranch.h"
ClassImp(TLeafB)
//______________________________________________________________________________
TLeafB::TLeafB(): TLeaf()
{
//*-*-*-*-*-*Default constructor for LeafB*-*-*-*-*-*-*-*-*-*-*-*-*-*
//*-* ============================
fValue = 0;
}
//______________________________________________________________________________
TLeafB::TLeafB(const char *name, const char *type)
:TLeaf(name,type)
{
//*-*-*-*-*-*-*-*-*-*-*-*-*Create a LeafB*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
//*-* ==============
//*-*
fLenType = 1;
fMinimum = 0;
fMaximum = 0;
fValue = 0;
}
//______________________________________________________________________________
TLeafB::~TLeafB()
{
//*-*-*-*-*-*Default destructor for a LeafB*-*-*-*-*-*-*-*-*-*-*-*
//*-* ===============================
if (ResetAddress(0,kTRUE)) delete [] fValue;
}
//______________________________________________________________________________
void TLeafB::Export(TClonesArray *list, Int_t n)
{
//*-*-*-*-*-*Export element from local leaf buffer to ClonesArray*-*-*-*-*
//*-* ====================================================
Int_t j = 0;
for (Int_t i=0;i<n;i++) {
memcpy((char*)list->UncheckedAt(i) + fOffset,&fValue[j], fLen);
j += fLen;
}
}
//______________________________________________________________________________
void TLeafB::FillBasket(TBuffer &b)
{
//*-*-*-*-*-*-*-*-*-*-*Pack leaf elements in Basket output buffer*-*-*-*-*-*-*
//*-* ==========================================
Int_t i;
Int_t len = GetLen();
if (IsUnsigned()) {
for (i=0;i<len;i++) b << (UChar_t)fValue[i];
} else {
b.WriteFastArray(fValue,len);
}
}
//______________________________________________________________________________
const char *TLeafB::GetTypeName() const
{
//*-*-*-*-*-*-*-*Returns name of leaf type*-*-*-*-*-*-*-*-*-*-*-*
//*-* =========================
if (fIsUnsigned) return "UChar_t";
return "Char_t";
}
//______________________________________________________________________________
void TLeafB::Import(TClonesArray *list, Int_t n)
{
//*-*-*-*-*-*Import element from ClonesArray into local leaf buffer*-*-*-*-*
//*-* ======================================================
Int_t j = 0;
for (Int_t i=0;i<n;i++) {
memcpy(&fValue[j],(char*)list->UncheckedAt(i) + fOffset, fLen);
j += fLen;
}
}
//______________________________________________________________________________
void TLeafB::Print(Option_t *option)
{
//*-*-*-*-*-*-*-*-*-*-*Print a description of this leaf*-*-*-*-*-*-*-*-*
//*-* ================================
TLeaf::Print(option);
}
//______________________________________________________________________________
void TLeafB::ReadBasket(TBuffer &b)
{
//*-*-*-*-*-*-*-*-*-*-*Read leaf elements from Basket input buffer*-*-*-*-*-*
//*-* ===========================================
if (fNdata == 1) {
b >> fValue[0];
}else {
if (fLeafCount) {
Int_t len = Int_t(fLeafCount->GetValue());
if (len > fLeafCount->GetMaximum()) {
printf("ERROR leaf:%s, len=%d and max=%dn",GetName(),len,fLeafCount->GetMaximum());
len = fLeafCount->GetMaximum();
}
b.ReadFastArray(fValue,len*fLen);
} else {
b.ReadFastArray(fValue,fLen);
}
}
}
//______________________________________________________________________________
void TLeafB::ReadBasketExport(TBuffer &b, TClonesArray *list, Int_t n)
{
//*-*-*-*-*-*-*-*-*-*-*Read leaf elements from Basket input buffer*-*-*-*-*-*
// and export buffer to TClonesArray objects
b.ReadFastArray(fValue,n*fLen);
Int_t j = 0;
for (Int_t i=0;i<n;i++) {
memcpy((char*)list->UncheckedAt(i) + fOffset,&fValue[j], fLen);
j += fLen;
}
}
//______________________________________________________________________________
void TLeafB::SetAddress(void *add)
{
//*-*-*-*-*-*-*-*-*-*-*Set leaf buffer data address*-*-*-*-*-*
//*-* ============================
if (ResetAddress(add)) delete [] fValue;
if (add) fValue = (char*)add;
else fValue = new char[fNdata];
}
ROOT page - Class index - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.