-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
conform to file interface (PR#4) (#33)
* use FileInterface with numpy --------- Co-authored-by: Bechir <[email protected]>
- Loading branch information
1 parent
dc9fb51
commit d07f867
Showing
22 changed files
with
387 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
// Your First C++ Program | ||
#include "aare/ContextManager.hpp" | ||
#include "aare/File.hpp" | ||
#include "aare/utils/logger.hpp" | ||
#include <iostream> | ||
#include <iostream> | ||
|
||
#define AARE_ROOT_DIR_VAR "PROJECT_ROOT_DIR" | ||
|
||
void test(File *f, int frame_number) { | ||
void test(File &f, int frame_number) { | ||
std::cout << "frame number: " << frame_number << std::endl; | ||
Frame frame = f->get_frame(frame_number); | ||
Frame frame = f.iread(frame_number); | ||
std::cout << *((uint16_t *)frame.get(0, 0)) << std::endl; | ||
std::cout << *((uint16_t *)frame.get(0, 1)) << std::endl; | ||
std::cout << *((uint16_t *)frame.get(0, 1)) << std::endl; | ||
std::cout << *((uint16_t *)frame.get(255, 1023)) << std::endl; | ||
std::cout << *((uint16_t *)frame.get(511, 1023)) << std::endl; | ||
} | ||
|
||
int main() { | ||
ContextManager ctx_manager; | ||
auto PROJECT_ROOT_DIR = std::filesystem::path(getenv(AARE_ROOT_DIR_VAR)); | ||
std::filesystem::path fpath(PROJECT_ROOT_DIR / "data" / "jungfrau" / "jungfrau_double_master_0.json"); | ||
std::cout << fpath << std::endl; | ||
|
||
File *file = ctx_manager.get_file(fpath); | ||
File file(fpath, "r"); | ||
test(file, 0); | ||
test(file, 9); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,30 @@ | ||
#pragma once | ||
|
||
#include "SubFile.hpp" | ||
#include "aare/Frame.hpp" | ||
#include "aare/defs.hpp" | ||
#include <filesystem> | ||
#include <fmt/core.h> | ||
#include <iostream> | ||
|
||
class File { | ||
|
||
public: | ||
virtual Frame get_frame(size_t frame_number) =0; | ||
|
||
#include "aare/FileInterface.hpp" | ||
class File : public FileInterface { | ||
private: | ||
// comment | ||
FileInterface *file_impl; | ||
|
||
public: | ||
virtual ~File() = default; | ||
std::filesystem::path fname; | ||
std::filesystem::path base_path; | ||
std::string base_name, ext; | ||
int findex; | ||
size_t total_frames{}; | ||
size_t max_frames_per_file{}; | ||
|
||
std::string version; | ||
DetectorType type; | ||
TimingMode timing_mode; | ||
bool quad{false}; | ||
|
||
ssize_t rows{}; | ||
ssize_t cols{}; | ||
ssize_t bitdepth{}; | ||
// File(); | ||
|
||
inline size_t bytes_per_frame() const { return rows * cols * bitdepth / 8; } | ||
inline size_t pixels() const { return rows * cols; } | ||
|
||
// size_t total_frames(); | ||
}; | ||
// options: | ||
// - r reading | ||
// - w writing (overwrites existing file) | ||
// - a appending (appends to existing file) | ||
// TODO! do we need to support w+, r+ and a+? | ||
File(std::filesystem::path fname, std::string mode); | ||
Frame read() override; | ||
std::vector<Frame> read(size_t n_frames) override; | ||
void read_into(std::byte *image_buf) override; | ||
void read_into(std::byte *image_buf, size_t n_frames) override; | ||
size_t frame_number(size_t frame_index) override; | ||
size_t bytes_per_frame() override; | ||
size_t pixels() override; | ||
void seek(size_t frame_number) override; | ||
size_t tell() override; | ||
size_t total_frames() const override ; | ||
ssize_t rows() const override ; | ||
ssize_t cols() const override ; | ||
ssize_t bitdepth() const override ; | ||
File(File &&other); | ||
|
||
|
||
~File(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.