#include "TLeafO.h"
#include "TBranch.h"
#include "TClonesArray.h"
#include "Riostream.h"
ClassImp(TLeafO)
TLeafO::TLeafO(): TLeaf()
{
fValue = 0;
fPointer = 0;
}
TLeafO::TLeafO(TBranch *parent, const char *name, const char *type)
:TLeaf(parent,name,type)
{
fLenType = sizeof(bool);
fMinimum = 0;
fMaximum = 0;
fValue = 0;
fPointer = 0;
}
TLeafO::~TLeafO()
{
if (ResetAddress(0,kTRUE)) delete [] fValue;
}
void TLeafO::Export(TClonesArray *list, Int_t n)
{
Int_t j = 0;
for (Int_t i=0;i<n;i++) {
memcpy((char*)list->UncheckedAt(i) + fOffset,&fValue[j], fLen);
j += fLen;
}
}
void TLeafO::FillBasket(TBuffer &b)
{
Int_t len = GetLen();
if (fPointer) fValue = *fPointer;
b.WriteFastArray(fValue,len);
}
const char *TLeafO::GetTypeName() const
{
return "Bool_t";
}
void TLeafO::Import(TClonesArray *list, Int_t n)
{
Int_t j = 0;
for (Int_t i=0;i<n;i++) {
memcpy(&fValue[j],(char*)list->UncheckedAt(i) + fOffset, fLen);
j += fLen;
}
}
void TLeafO::PrintValue(Int_t l) const
{
char *value = (char*)GetValuePointer();
printf("%d",(Int_t)value[l]);
}
void TLeafO::ReadBasket(TBuffer &b)
{
if (!fLeafCount && 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=%d\n",GetName(),len,fLeafCount->GetMaximum());
len = fLeafCount->GetMaximum();
}
fNdata = len*fLen;
b.ReadFastArray(fValue,len*fLen);
} else {
b.ReadFastArray(fValue,fLen);
}
}
}
void TLeafO::ReadBasketExport(TBuffer &b, TClonesArray *list, Int_t n)
{
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 TLeafO::ReadValue(ifstream &s)
{
char *value = (char*)GetValuePointer();
s >> value;
}
void TLeafO::SetAddress(void *add)
{
if (ResetAddress(add)) {
delete [] fValue;
}
if (add) {
if (TestBit(kIndirectAddress)) {
fPointer = (Bool_t**) add;
Int_t ncountmax = fLen;
if (fLeafCount) ncountmax = fLen*(fLeafCount->GetMaximum() + 1);
if ((fLeafCount && ncountmax > Int_t(fLeafCount->GetValue())) ||
ncountmax > fNdata || *fPointer == 0) {
if (*fPointer) delete [] *fPointer;
if (ncountmax > fNdata) fNdata = ncountmax;
*fPointer = new Bool_t[fNdata];
}
fValue = *fPointer;
} else {
fValue = (bool*)add;
}
} else {
fValue = new bool[fNdata];
fValue[0] = 0;
}
}
Last change: Wed Jun 25 08:47:52 2008
Last generated: 2008-06-25 08:47
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.