Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RRawFileTFile.hxx
Go to the documentation of this file.
1// Author: Jonas Hahnfeld
2
3/*************************************************************************
4 * Copyright (C) 1995-2024, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOT_RRawFileTFile
12#define ROOT_RRawFileTFile
13
14#include <ROOT/RRawFile.hxx>
15
16#include <TFile.h>
17
18#include <stdexcept>
19
20namespace ROOT {
21namespace Internal {
22
23/**
24 * \class RRawFileTFile RRawFileTFile.hxx
25 * \ingroup IO
26 *
27 * The RRawFileTFile wraps an open TFile, but does not take ownership.
28 */
29class RRawFileTFile : public RRawFile {
30private:
32
33protected:
34 void OpenImpl() final { fOptions.fBlockSize = 0; }
35
36 size_t ReadAtImpl(void *buffer, size_t nbytes, std::uint64_t offset) final
37 {
38 if (fFile->ReadBuffer(static_cast<char *>(buffer), offset, nbytes)) {
39 throw std::runtime_error("failed to read expected number of bytes");
40 }
41 return nbytes;
42 }
43
44 std::uint64_t GetSizeImpl() final { return fFile->GetSize(); }
45
46public:
47 RRawFileTFile(TFile *file) : RRawFile(file->GetEndpointUrl()->GetFile(), {}), fFile(file) {}
48
49 std::unique_ptr<ROOT::Internal::RRawFile> Clone() const final { return std::make_unique<RRawFileTFile>(fFile); }
50
51 int GetFeatures() const final { return kFeatureHasSize; }
52};
53
54} // namespace Internal
55} // namespace ROOT
56
57#endif
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
The RRawFileTFile wraps an open TFile, but does not take ownership.
int GetFeatures() const final
Derived classes shall inform the user about the supported functionality, which can possibly depend on...
void OpenImpl() final
OpenImpl() is called at most once and before any call to either DoReadAt or DoGetSize.
size_t ReadAtImpl(void *buffer, size_t nbytes, std::uint64_t offset) final
Derived classes should implement low-level reading without buffering.
std::unique_ptr< ROOT::Internal::RRawFile > Clone() const final
Create a new RawFile that accesses the same resource. The file pointer is reset to zero.
std::uint64_t GetSizeImpl() final
Derived classes should return the file size or kUnknownFileSize.
The RRawFile provides read-only access to local and remote files.
Definition RRawFile.hxx:43
static constexpr int kFeatureHasSize
GetSize() does not return kUnknownFileSize.
Definition RRawFile.hxx:52
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
virtual Long64_t GetSize() const
Returns the current file size.
Definition TFile.cxx:1347
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Read a buffer from the file.
Definition TFile.cxx:1770
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
int fBlockSize
Read at least fBlockSize bytes at a time.
Definition RRawFile.hxx:65