From edd376b4baf66f8e7a18d18adc6ce156e15dbd07 Mon Sep 17 00:00:00 2001 From: silverweed Date: Fri, 12 Jul 2024 10:25:58 +0200 Subject: [PATCH] separate root_iface type from RNTuple_Info --- Makefile | 14 +++++++++----- src/render.cpp | 2 +- src/rntuple.cpp | 18 +++++++++++------- src/rntuple.h | 6 ++++-- src/root/RMicroFileReader.cxx | 6 ++++++ src/root/RMicroFileReader.hxx | 4 ++++ 6 files changed, 35 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index c864491..3d0e3ca 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ ROOTLIBS = -L$(ROOT)/lib -lCore -lRIO -lROOTNTuple -lxxhash -Wl,-rpath,$(ROOT)/l LIBS = -lglfw MOLD = mold -run ROOT_IFACE = build/libroot_iface.so +ROOT_IFACE_DBG = build/libroot_iface_d.so .PHONY: all clean all: build/imgui.o $(ROOT_IFACE) noasan @@ -20,14 +21,17 @@ build/imgui.o: src/imgui_inc.cpp third_party/imgui/imgui.h # $(ROOT_IFACE): src/root/RMicroFileReader.cxx # $(CXX) -O3 -fPIC -c $(ROOTFLAGS) $< -o $@ -$(ROOT_IFACE): src/root/RMicroFileReader.cxx +$(ROOT_IFACE): src/root/RMicroFileReader.cxx src/root/RMicroFileReader.hxx $(CXX) -O3 -fPIC -shared $(ROOTFLAGS) $< -o $@ $(ROOTLIBS) -d: $(ROOT_IFACE) build/imgui.o - $(MOLD) $(CXX) -DDEBUG -g -O0 -DENABLE_ASAN $(CFLAGS) -fsanitize=undefined $(INC) -o rntviewer src/rntviewer.cpp build/imgui.o $(ROOT_IFACE) -lasan $(LIBS) +$(ROOT_IFACE_DBG): src/root/RMicroFileReader.cxx src/root/RMicroFileReader.hxx + $(CXX) -g -O0 -fPIC -shared $(ROOTFLAGS) $< -o $@ $(ROOTLIBS) + +d: $(ROOT_IFACE_DBG) build/imgui.o + $(MOLD) $(CXX) -DDEBUG -g -O0 -DENABLE_ASAN $(CFLAGS) $(INC) -o rntviewer src/rntviewer.cpp build/imgui.o -lasan $(ROOT_IFACE_DBG) $(LIBS) -noasan: $(ROOT_IFACE) build/imgui.o - $(MOLD) $(CXX) -DDEBUG -g -O0 $(CFLAGS) -fsanitize=undefined $(INC) -o rntviewer src/rntviewer.cpp build/imgui.o $(ROOT_IFACE) $(LIBS) +noasan: $(ROOT_IFACE_DBG) build/imgui.o + $(MOLD) $(CXX) -DDEBUG -g -O0 $(CFLAGS) -fsanitize=undefined $(INC) -o rntviewer src/rntviewer.cpp build/imgui.o $(ROOT_IFACE_DBG) $(LIBS) r: $(ROOT_IFACE) build/imgui.o $(MOLD) $(CXX) -O2 $(CFLAGS) $(INC) -o rntviewer src/rntviewer.cpp build/imgui.o $(ROOT_IFACE) $(LIBS) diff --git a/src/render.cpp b/src/render.cpp index ede6b91..09d9cd2 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -101,7 +101,7 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms) const auto main_win_flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDecoration; if (ImGui::Begin("main", nullptr, main_win_flags)) { - String8 ntpl_desc = rntuple_description(scratch.arena, app.rntinfo.anchor); + String8 ntpl_desc = rntuple_description(scratch.arena, app.rntinfo); ImGui::Text("RNTuple '%s' (%s) from file \"%s\"", app.ntpl_name, ntpl_desc.c(), app.inspected_fname); // Draw stats diff --git a/src/rntuple.cpp b/src/rntuple.cpp index 809046b..4c28e7e 100644 --- a/src/rntuple.cpp +++ b/src/rntuple.cpp @@ -1,11 +1,11 @@ internal -String8 rntuple_description(Arena *arena, const RNTuple_Anchor &anchor) +String8 rntuple_description(Arena *arena, const RNTuple_Info &ntuple) { String8 desc = push_str8f(arena, "version %u.%u.%u.%u", - anchor.fVersionEpoch, - anchor.fVersionMajor, - anchor.fVersionMinor, - anchor.fVersionPatch); + ntuple.version.epoch, + ntuple.version.major, + ntuple.version.minor, + ntuple.version.patch); return desc; } @@ -15,9 +15,13 @@ RNTuple_Info get_rntuple_info(const char *fname, const char *ntpl_name) RNTuple_Info info = {}; // TODO: proper error handling - RMicroFileReader file_reader { fname }; - RNTuple_File_Info file_info = file_reader.GetNTupleProper(ntpl_name); + root::RMicroFileReader file_reader { fname }; + root::RNTuple_File_Info file_info = file_reader.GetNTupleProper(ntpl_name); if (!file_info.failed) { + info.version.epoch = file_info.anchor.fVersionEpoch; + info.version.major = file_info.anchor.fVersionMajor; + info.version.minor = file_info.anchor.fVersionMinor; + info.version.patch = file_info.anchor.fVersionPatch; info.rng_header.start = file_info.anchor.fSeekHeader; info.rng_header.len = file_info.anchor.fNBytesHeader; info.rng_footer.start = file_info.anchor.fSeekFooter; diff --git a/src/rntuple.h b/src/rntuple.h index f47aec6..51942ad 100644 --- a/src/rntuple.h +++ b/src/rntuple.h @@ -6,8 +6,10 @@ struct Byte_Range { }; struct RNTuple_Info { - RNTuple_Anchor anchor; - + struct { + u16 epoch, major, minor, patch; + } version; + u64 root_file_header_size; u64 rblob_header_size; Byte_Range rng_anchor; diff --git a/src/root/RMicroFileReader.cxx b/src/root/RMicroFileReader.cxx index 1ab33ae..6c05835 100644 --- a/src/root/RMicroFileReader.cxx +++ b/src/root/RMicroFileReader.cxx @@ -1064,6 +1064,12 @@ static size_t ComputeNumChunks(size_t nbytes, size_t maxChunkSize) return nChunks; } +// ========================================================================================= +// PUBLIC INTERFACE +// ========================================================================================= + +using namespace root; + struct RMicroFileReader::Impl { std::unique_ptr fRawFile; std::uint64_t fMaxBlobSize; diff --git a/src/root/RMicroFileReader.hxx b/src/root/RMicroFileReader.hxx index a061245..ae87b30 100644 --- a/src/root/RMicroFileReader.hxx +++ b/src/root/RMicroFileReader.hxx @@ -2,6 +2,8 @@ #include +namespace root { + struct RNTuple_Anchor { /// Version of the RNTuple binary format that the writer supports (see specification). /// Changing the epoch indicates backward-incompatible changes @@ -61,3 +63,5 @@ public: struct Impl; Impl *impl; }; + +}