#include "TFileInfo.h"
#include "Riostream.h"
ClassImp(TFileInfo)
TFileInfo::TFileInfo(const char *url , Long64_t size, const char *uuid,
const char *md5, Long64_t entries, Long64_t first, Long64_t last,
TObject *meta) : fCurrentUrl(0), fUrlList(0), fSize(size), fUUID(0),
fMD5(0), fEntries(entries), fFirst(first), fLast(last), fMetaDataObject(meta)
{
if (uuid)
fUUID = new TUUID(uuid);
else
fUUID = new TUUID;
if (md5)
fMD5 = new TMD5((const UChar_t*)md5);
else
fMD5 = new TMD5;
SetName(fUUID->AsString());
SetTitle("TFileInfo");
fCurrentUrl = 0;
if (url) {
fUrlList = new TList();
fUrlList->SetOwner();
AddUrl(url);
}
}
TFileInfo::TFileInfo(const TFileInfo& fi) :
TNamed(fi),
fCurrentUrl(fi.fCurrentUrl),
fUrlList(fi.fUrlList),
fSize(fi.fSize),
fUUID(fi.fUUID),
fMD5(fi.fMD5),
fEntries(fi.fEntries),
fFirst(fi.fFirst),
fLast(fi.fLast),
fMetaDataObject(fi.fMetaDataObject)
{
}
TFileInfo& TFileInfo::operator=(const TFileInfo& fi)
{
if(this!=&fi) {
TNamed::operator=(fi);
fCurrentUrl=fi.fCurrentUrl;
fUrlList=fi.fUrlList;
fSize=fi.fSize;
fUUID=fi.fUUID;
fMD5=fi.fMD5;
fEntries=fi.fEntries;
fFirst=fi.fFirst;
fLast=fi.fLast;
fMetaDataObject=fi.fMetaDataObject;
}
return *this;
}
TFileInfo::~TFileInfo()
{
SafeDelete(fMetaDataObject);
SafeDelete(fUUID);
SafeDelete(fMD5);
SafeDelete(fUrlList);
}
TUrl *TFileInfo::NextUrl()
{
if (fCurrentUrl && (fCurrentUrl == fUrlList->First())) {
TUrl *returl = GetCurrentUrl();
fCurrentUrl = (TUrl*)fUrlList->After((TObject*)fCurrentUrl);
return returl;
}
if (fCurrentUrl)
fCurrentUrl = (TUrl*)fUrlList->After((TObject*)fCurrentUrl);
return GetCurrentUrl();
}
TUrl *TFileInfo::FindByUrl(const char *url)
{
TIter nextUrl(fUrlList);
TUrl *urlelement;
while ( (urlelement = (TUrl*) nextUrl() ) ) {
if ( TString(urlelement->GetUrl()) == TString(url) ) {
return urlelement;
}
}
return 0;
}
Bool_t TFileInfo::AddUrl(const char *url)
{
if (FindByUrl(url)) {
return kFALSE;
}
TUrl *newurl = new TUrl(url);
if (fUrlList->GetSize() == 0) {
fCurrentUrl = newurl;
}
fUrlList->Add( newurl );
return kTRUE;
}
Bool_t TFileInfo::RemoveUrl(const char *url)
{
TUrl *lurl;
if ((lurl=(TUrl*)FindByUrl(url))) {
fUrlList->Remove((TObject*) lurl);
return kTRUE;
}
return kFALSE;
}
void TFileInfo::AddMetaDataObject(TObject *obj)
{
if (obj) {
if (fMetaDataObject)
delete fMetaDataObject;
fMetaDataObject = obj;
}
}
void TFileInfo::RemoveMetaDataObject()
{
if (fMetaDataObject) {
delete fMetaDataObject;
fMetaDataObject = 0;
}
}
Int_t TFileInfo::Compare(const TObject *obj) const
{
if (this == obj) return 0;
if (TFileInfo::Class() != obj->IsA()) return -1;
return (GetFirstUrl()->Compare(((TFileInfo*)obj)->GetFirstUrl()));
}
void TFileInfo::Print(Option_t * ) const
{
cout << "UUID: " << GetUUID()->AsString() << " Size: " << GetSize() << " MD5: " << GetMD5()->AsString() << endl;
TIter next(fUrlList);
TObject* obj;
while ( (obj = next() ) ){
const char *url = ((TUrl*)obj)->GetUrl();
cout << " URL: " << url << endl;
}
}
ROOT page - Class index - Class Hierarchy - 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.