Logo ROOT  
Reference Guide
TFileInfo.h
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Andreas-Joachim Peters 20/9/2005
3
4/*************************************************************************
5 * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TFileInfo
13#define ROOT_TFileInfo
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// TFileInfo //
18// //
19// Class describing a generic file including meta information. //
20// //
21//////////////////////////////////////////////////////////////////////////
22
23#include "TNamed.h"
24
25#include "TUrl.h"
26
27#include "TUUID.h"
28
29#include "TMD5.h"
30
31#include "TList.h"
32
33class TFileInfoMeta;
34
35
36class TFileInfo : public TNamed {
37
38private:
39 TUrl *fCurrentUrl; //! current URL to access the file, points to URL
40 // in the fUrlList or 0, if the list end is reached
41 TList *fUrlList; // list of file URLs
42 Long64_t fSize; // file size
43 TUUID *fUUID; //-> uuid of the referenced file
44 TMD5 *fMD5; //-> md5 digest of the file
45 TList *fMetaDataList; // generic list of file meta data object(s)
46
47 Int_t fIndex; // Index to be used when sorting with index
48
49 void ParseInput(const char *in);
50
51 TFileInfo& operator=(const TFileInfo&); // not implemented
52
53public:
55 kStaged = BIT(15),
57 kSortWithIndex = BIT(17) // Use index when sorting (in Compare)
58 };
59
60 TFileInfo(const char *url = 0, Long64_t size = -1, const char *uuid = 0,
61 const char *md5 = 0, TObject *meta = 0);
62 TFileInfo(const TFileInfo &);
63
64 virtual ~TFileInfo();
65
67 TUrl *NextUrl();
68 TUrl *GetCurrentUrl() const;
69 TUrl *GetFirstUrl() const { return (TUrl*)fUrlList->First(); }
70 TUrl *GetUrlAt(Int_t i) const { return (TUrl*)fUrlList->At(i); }
72 Int_t GetNUrls() const { return fUrlList->GetEntries(); }
73
74 Bool_t SetCurrentUrl(const char *url);
76
77 Long64_t GetSize() const { return fSize; }
78 TUUID *GetUUID() const { return fUUID; }
79 TMD5 *GetMD5() const { return fMD5; }
80 TList *GetMetaDataList() const { return fMetaDataList; }
81 TFileInfoMeta *GetMetaData(const char *meta = 0) const;
82
83 void SetSize(Long64_t size) { fSize = size; }
84 void SetUUID(const char *uuid);
85
86 TUrl *FindByUrl(const char *url, Bool_t withDeflt = kFALSE);
87
88 Bool_t AddUrl(const char *url, Bool_t infront = kFALSE);
89 Bool_t RemoveUrl(const char *url);
91 Bool_t RemoveMetaData(const char *meta = 0);
92
93 Bool_t IsSortable() const { return kTRUE; }
94 Int_t Compare(const TObject *obj) const;
95
96 Int_t GetIndex() const { return fIndex; }
97 void SetIndex(Int_t idx) { fIndex = idx; }
98
99 void Print(Option_t *options="") const;
100
101 ClassDef(TFileInfo,4) // Describes generic file info including meta data information
102};
103
104
105class TFileInfoMeta : public TNamed {
106
107private:
108 Long64_t fEntries; // number of entries in tree or number of objects
109 Long64_t fFirst; // first valid tree entry
110 Long64_t fLast; // last valid tree entry
111 Bool_t fIsTree; // true if type is a TTree (or TTree derived)
112 Long64_t fTotBytes; // uncompressed size in bytes
113 Long64_t fZipBytes; // compressed size in bytes
114
115 TFileInfoMeta& operator=(const TFileInfoMeta&); // not implemented
116
117public:
118 enum EStatusBits { kExternal = BIT(15) };
119
123 TFileInfoMeta(const char *objPath, const char *objClass = "TTree",
124 Long64_t entries = -1, Long64_t first = 0, Long64_t last = -1,
125 Long64_t totbytes = -1, Long64_t zipbytes = -1);
126 TFileInfoMeta(const char *objPath, const char *objDir,
127 const char *objClass, Long64_t entries = -1,
128 Long64_t first = 0, Long64_t last = -1,
129 Long64_t totbytes = -1, Long64_t zipbytes = -1);
131
132 virtual ~TFileInfoMeta() { }
133
134 const char *GetObject() const;
135 const char *GetClass() const { return GetTitle(); }
136 const char *GetDirectory() const;
137 Long64_t GetEntries() const { return fEntries; }
138 Long64_t GetFirst() const { return fFirst; }
139 Long64_t GetLast() const { return fLast; }
140 Bool_t IsTree() const { return fIsTree; }
141 Long64_t GetTotBytes() const { return fTotBytes; }
142 Long64_t GetZipBytes() const { return fZipBytes; }
143
144 void SetEntries(Long64_t entries) { fEntries = entries; }
146 void SetLast(Long64_t last) { fLast = last; }
147 void SetTotBytes(Long64_t tot) { fTotBytes = tot; }
148 void SetZipBytes(Long64_t zip) { fZipBytes = zip; }
149
150 void Print(Option_t *options="") const;
151
152 ClassDef(TFileInfoMeta,2) // Describes TFileInfo meta data
153};
154
155#endif
int Int_t
Definition: RtypesCore.h:43
const Bool_t kFALSE
Definition: RtypesCore.h:90
bool Bool_t
Definition: RtypesCore.h:61
long long Long64_t
Definition: RtypesCore.h:71
const Bool_t kTRUE
Definition: RtypesCore.h:89
const char Option_t
Definition: RtypesCore.h:64
#define ClassDef(name, id)
Definition: Rtypes.h:322
#define BIT(n)
Definition: Rtypes.h:83
virtual Int_t GetEntries() const
Definition: TCollection.h:177
Long64_t GetZipBytes() const
Definition: TFileInfo.h:142
Long64_t GetFirst() const
Definition: TFileInfo.h:138
Long64_t GetLast() const
Definition: TFileInfo.h:139
virtual ~TFileInfoMeta()
Definition: TFileInfo.h:132
Bool_t IsTree() const
Definition: TFileInfo.h:140
const char * GetDirectory() const
Get the object's directory in the ROOT file.
Definition: TFileInfo.cxx:580
void Print(Option_t *options="") const
Print information about this object.
Definition: TFileInfo.cxx:597
Long64_t GetTotBytes() const
Definition: TFileInfo.h:141
void SetFirst(Long64_t first)
Definition: TFileInfo.h:145
Bool_t fIsTree
Definition: TFileInfo.h:111
Long64_t fZipBytes
Definition: TFileInfo.h:113
Long64_t fFirst
Definition: TFileInfo.h:109
Long64_t fTotBytes
Definition: TFileInfo.h:112
void SetLast(Long64_t last)
Definition: TFileInfo.h:146
TFileInfoMeta & operator=(const TFileInfoMeta &)
Long64_t fLast
Definition: TFileInfo.h:110
const char * GetObject() const
Get the object name, with path stripped off.
Definition: TFileInfo.cxx:589
void SetTotBytes(Long64_t tot)
Definition: TFileInfo.h:147
Long64_t fEntries
Definition: TFileInfo.h:108
Long64_t GetEntries() const
Definition: TFileInfo.h:137
void SetZipBytes(Long64_t zip)
Definition: TFileInfo.h:148
const char * GetClass() const
Definition: TFileInfo.h:135
void SetEntries(Long64_t entries)
Definition: TFileInfo.h:144
Class describing a generic file including meta information.
Definition: TFileInfo.h:36
virtual ~TFileInfo()
Destructor.
Definition: TFileInfo.cxx:119
Int_t Compare(const TObject *obj) const
Compare TFileInfo object by their first urls.
Definition: TFileInfo.cxx:443
TList * fUrlList
current URL to access the file, points to URL
Definition: TFileInfo.h:41
void Print(Option_t *options="") const
Print information about this object.
Definition: TFileInfo.cxx:477
Int_t GetIndex() const
Definition: TFileInfo.h:96
TUrl * fCurrentUrl
Definition: TFileInfo.h:39
TUUID * fUUID
Definition: TFileInfo.h:43
@ kSortWithIndex
Definition: TFileInfo.h:57
@ kCorrupted
Definition: TFileInfo.h:56
TUrl * NextUrl()
Iterator function, start iteration by calling ResetUrl().
Definition: TFileInfo.cxx:260
Bool_t AddUrl(const char *url, Bool_t infront=kFALSE)
Add a new URL.
Definition: TFileInfo.cxx:295
Bool_t RemoveUrlAt(Int_t i)
Remove URL at given position. Returns kTRUE on success, kFALSE on error.
Definition: TFileInfo.cxx:336
Bool_t AddMetaData(TObject *meta)
Add's a meta data object to the file info object.
Definition: TFileInfo.cxx:384
Bool_t RemoveUrl(const char *url)
Remove an URL. Returns kTRUE if successful, kFALSE otherwise.
Definition: TFileInfo.cxx:320
Int_t fIndex
Definition: TFileInfo.h:47
TUrl * GetFirstUrl() const
Definition: TFileInfo.h:69
TList * GetMetaDataList() const
Definition: TFileInfo.h:80
Bool_t RemoveMetaData(const char *meta=0)
Remove the metadata object.
Definition: TFileInfo.cxx:401
Long64_t GetSize() const
Definition: TFileInfo.h:77
TUUID * GetUUID() const
Definition: TFileInfo.h:78
Long64_t fSize
Definition: TFileInfo.h:42
Int_t GetNUrls() const
Definition: TFileInfo.h:72
TMD5 * GetMD5() const
Definition: TFileInfo.h:79
Bool_t SetCurrentUrl(const char *url)
Set 'url' as current URL, if in the list Return kFALSE if not in the list.
Definition: TFileInfo.cxx:354
TUrl * GetUrlAt(Int_t i) const
Definition: TFileInfo.h:70
Bool_t IsSortable() const
Definition: TFileInfo.h:93
TUrl * FindByUrl(const char *url, Bool_t withDeflt=kFALSE)
Find an element from a URL. Returns 0 if not found.
Definition: TFileInfo.cxx:276
void ResetUrl()
Definition: TFileInfo.h:66
TFileInfo(const char *url=0, Long64_t size=-1, const char *uuid=0, const char *md5=0, TObject *meta=0)
Constructor.
Definition: TFileInfo.cxx:31
void SetIndex(Int_t idx)
Definition: TFileInfo.h:97
TUrl * GetCurrentUrl() const
Return the current url.
Definition: TFileInfo.cxx:248
TFileInfoMeta * GetMetaData(const char *meta=0) const
Get meta data object with specified name.
Definition: TFileInfo.cxx:424
void SetUUID(const char *uuid)
Set the UUID to the value associated to the string 'uuid'.
Definition: TFileInfo.cxx:237
TList * fMetaDataList
Definition: TFileInfo.h:45
TFileInfo & operator=(const TFileInfo &)
TMD5 * fMD5
Definition: TFileInfo.h:44
void ParseInput(const char *in)
Parse the input line to extract init information from 'in'; the input string is tokenized on ' '; the...
Definition: TFileInfo.cxx:156
void SetSize(Long64_t size)
Definition: TFileInfo.h:83
A doubly linked list.
Definition: TList.h:44
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:356
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:658
This code implements the MD5 message-digest algorithm.
Definition: TMD5.h:44
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
Mother of all ROOT objects.
Definition: TObject.h:37
void ResetBit(UInt_t f)
Definition: TObject.h:186
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
Definition: TUUID.h:42
This class represents a WWW compatible URL.
Definition: TUrl.h:35
Definition: first.py:1
auto * m
Definition: textangle.C:8