Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include "TList.h"
25
26#ifdef R__LESS_INCLUDES
27class TUrl;
28class TUUID;
29class TMD5;
30#else
31#include "TUrl.h"
32#include "TUUID.h"
33#include "TMD5.h"
34#endif
35
36class TFileInfoMeta;
37
38
39class TFileInfo : public TNamed {
40
41private:
42 TUrl *fCurrentUrl; ///<! current URL to access the file, points to URL in the fUrlList or 0, if the list end is reached
43 TList *fUrlList; // list of file URLs
44 Long64_t fSize; // file size
45 TUUID *fUUID; //-> uuid of the referenced file
46 TMD5 *fMD5; //-> md5 digest of the file
47 TList *fMetaDataList; // generic list of file meta data object(s)
48
49 Int_t fIndex; // Index to be used when sorting with index
50
51 void ParseInput(const char *in);
52
53 TFileInfo& operator=(const TFileInfo&) = delete;
54
55public:
57 kStaged = BIT(15),
59 kSortWithIndex = BIT(17) // Use index when sorting (in Compare)
60 };
61
62 TFileInfo(const char *url = nullptr, Long64_t size = -1, const char *uuid = nullptr,
63 const char *md5 = nullptr, TObject *meta = nullptr);
64 TFileInfo(const TFileInfo &);
65
66 virtual ~TFileInfo();
67
69 TUrl *NextUrl();
70 TUrl *GetCurrentUrl() const;
71 TUrl *GetFirstUrl() const { return (TUrl*)fUrlList->First(); }
72 TUrl *GetUrlAt(Int_t i) const { return (TUrl*)fUrlList->At(i); }
74 Int_t GetNUrls() const { return fUrlList->GetEntries(); }
75
76 Bool_t SetCurrentUrl(const char *url);
78
79 Long64_t GetSize() const { return fSize; }
80 TUUID *GetUUID() const { return fUUID; }
81 TMD5 *GetMD5() const { return fMD5; }
82 TList *GetMetaDataList() const { return fMetaDataList; }
83 TFileInfoMeta *GetMetaData(const char *meta = nullptr) const;
84
86 void SetUUID(const char *uuid);
87
88 TUrl *FindByUrl(const char *url, Bool_t withDeflt = kFALSE);
89
90 Bool_t AddUrl(const char *url, Bool_t infront = kFALSE);
91 Bool_t RemoveUrl(const char *url);
93 Bool_t RemoveMetaData(const char *meta = nullptr);
94
95 Bool_t IsSortable() const override { return kTRUE; }
96 Int_t Compare(const TObject *obj) const override;
97
98 Int_t GetIndex() const { return fIndex; }
99 void SetIndex(Int_t idx) { fIndex = idx; }
100
101 void Print(Option_t *options="") const override;
102
103 ClassDefOverride(TFileInfo,4) // Describes generic file info including meta data information
104};
105
106
107class TFileInfoMeta : public TNamed {
108
109private:
110 Long64_t fEntries; // number of entries in tree or number of objects
111 Long64_t fFirst; // first valid tree entry
112 Long64_t fLast; // last valid tree entry
113 Bool_t fIsTree; // true if type is a TTree (or TTree derived)
114 Long64_t fTotBytes; // uncompressed size in bytes
115 Long64_t fZipBytes; // compressed size in bytes
116
118
119public:
120 enum EStatusBits { kExternal = BIT(15) };
121
125 TFileInfoMeta(const char *objPath, const char *objClass = "TTree",
126 Long64_t entries = -1, Long64_t first = 0, Long64_t last = -1,
128 TFileInfoMeta(const char *objPath, const char *objDir,
129 const char *objClass, Long64_t entries = -1,
130 Long64_t first = 0, Long64_t last = -1,
133
134 virtual ~TFileInfoMeta() { }
135
136 const char *GetObject() const;
137 const char *GetClass() const { return GetTitle(); }
138 const char *GetDirectory() const;
139 Long64_t GetEntries() const { return fEntries; }
140 Long64_t GetFirst() const { return fFirst; }
141 Long64_t GetLast() const { return fLast; }
142 Bool_t IsTree() const { return fIsTree; }
143 Long64_t GetTotBytes() const { return fTotBytes; }
144 Long64_t GetZipBytes() const { return fZipBytes; }
145
146 void SetEntries(Long64_t entries) { fEntries = entries; }
147 void SetFirst(Long64_t first) { fFirst = first; }
148 void SetLast(Long64_t last) { fLast = last; }
151
152 void Print(Option_t *options="") const override;
153
154 ClassDefOverride(TFileInfoMeta,2) // Describes TFileInfo meta data
155};
156
157#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
#define BIT(n)
Definition Rtypes.h:91
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
virtual Int_t GetEntries() const
Long64_t GetZipBytes() const
Definition TFileInfo.h:144
Long64_t GetFirst() const
Definition TFileInfo.h:140
Long64_t GetLast() const
Definition TFileInfo.h:141
TFileInfoMeta & operator=(const TFileInfoMeta &)=delete
virtual ~TFileInfoMeta()
Definition TFileInfo.h:134
Bool_t IsTree() const
Definition TFileInfo.h:142
const char * GetDirectory() const
Get the object's directory in the ROOT file.
Long64_t GetTotBytes() const
Definition TFileInfo.h:143
void SetFirst(Long64_t first)
Definition TFileInfo.h:147
Bool_t fIsTree
Definition TFileInfo.h:113
Long64_t fZipBytes
Definition TFileInfo.h:115
Long64_t fFirst
Definition TFileInfo.h:111
Long64_t fTotBytes
Definition TFileInfo.h:114
void SetLast(Long64_t last)
Definition TFileInfo.h:148
Long64_t fLast
Definition TFileInfo.h:112
const char * GetObject() const
Get the object name, with path stripped off.
void SetTotBytes(Long64_t tot)
Definition TFileInfo.h:149
Long64_t fEntries
Definition TFileInfo.h:110
Long64_t GetEntries() const
Definition TFileInfo.h:139
void Print(Option_t *options="") const override
Print information about this object.
void SetZipBytes(Long64_t zip)
Definition TFileInfo.h:150
const char * GetClass() const
Definition TFileInfo.h:137
void SetEntries(Long64_t entries)
Definition TFileInfo.h:146
Class describing a generic file including meta information.
Definition TFileInfo.h:39
virtual ~TFileInfo()
Destructor.
TList * fUrlList
Definition TFileInfo.h:43
Int_t GetIndex() const
Definition TFileInfo.h:98
TUrl * fCurrentUrl
! current URL to access the file, points to URL in the fUrlList or 0, if the list end is reached
Definition TFileInfo.h:42
TUUID * fUUID
Definition TFileInfo.h:45
@ kSortWithIndex
Definition TFileInfo.h:59
TUrl * NextUrl()
Iterator function, start iteration by calling ResetUrl().
Bool_t AddUrl(const char *url, Bool_t infront=kFALSE)
Add a new URL.
Bool_t RemoveUrlAt(Int_t i)
Remove URL at given position. Returns kTRUE on success, kFALSE on error.
Bool_t AddMetaData(TObject *meta)
Add's a meta data object to the file info object.
Bool_t RemoveUrl(const char *url)
Remove an URL. Returns kTRUE if successful, kFALSE otherwise.
Int_t fIndex
Definition TFileInfo.h:49
TUrl * GetFirstUrl() const
Definition TFileInfo.h:71
TList * GetMetaDataList() const
Definition TFileInfo.h:82
TFileInfoMeta * GetMetaData(const char *meta=nullptr) const
Get meta data object with specified name.
Long64_t GetSize() const
Definition TFileInfo.h:79
TUUID * GetUUID() const
Definition TFileInfo.h:80
Bool_t RemoveMetaData(const char *meta=nullptr)
Remove the metadata object.
Long64_t fSize
Definition TFileInfo.h:44
Int_t GetNUrls() const
Definition TFileInfo.h:74
Int_t Compare(const TObject *obj) const override
Compare TFileInfo object by their first urls.
TMD5 * GetMD5() const
Definition TFileInfo.h:81
Bool_t SetCurrentUrl(const char *url)
Set 'url' as current URL, if in the list Return kFALSE if not in the list.
TUrl * GetUrlAt(Int_t i) const
Definition TFileInfo.h:72
TUrl * FindByUrl(const char *url, Bool_t withDeflt=kFALSE)
Find an element from a URL. Returns 0 if not found.
void ResetUrl()
Definition TFileInfo.h:68
TFileInfo & operator=(const TFileInfo &)=delete
void SetIndex(Int_t idx)
Definition TFileInfo.h:99
TUrl * GetCurrentUrl() const
Return the current url.
void SetUUID(const char *uuid)
Set the UUID to the value associated to the string 'uuid'.
TList * fMetaDataList
Definition TFileInfo.h:47
TFileInfo(const char *url=nullptr, Long64_t size=-1, const char *uuid=nullptr, const char *md5=nullptr, TObject *meta=nullptr)
Constructor.
Definition TFileInfo.cxx:30
Bool_t IsSortable() const override
Definition TFileInfo.h:95
TMD5 * fMD5
Definition TFileInfo.h:46
void ParseInput(const char *in)
Parse the input line to extract init information from 'in'; the input string is tokenized on ' '; the...
void Print(Option_t *options="") const override
Print information about this object.
void SetSize(Long64_t size)
Definition TFileInfo.h:85
A doubly linked list.
Definition TList.h:38
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:789
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:487
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
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
Mother of all ROOT objects.
Definition TObject.h:42
void ResetBit(UInt_t f)
Definition TObject.h:203
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:33
TMarker m
Definition textangle.C:8