mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-02-03 12:38:38 +01:00
moving code into aare:: namespace
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
#include "aare/FileFactory.hpp"
|
||||
#include "aare/utils/logger.hpp"
|
||||
|
||||
namespace aare {
|
||||
|
||||
File::File(std::filesystem::path fname, std::string mode, FileConfig cfg) {
|
||||
file_impl = FileFactory::load_file(fname, mode, cfg);
|
||||
}
|
||||
@@ -30,3 +32,5 @@ File::File(File &&other) {
|
||||
}
|
||||
|
||||
// write move assignment operator
|
||||
|
||||
}
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "aare/utils/logger.hpp"
|
||||
#include <iostream>
|
||||
|
||||
namespace aare {
|
||||
|
||||
FileFactory *FileFactory::get_factory(std::filesystem::path fpath) {
|
||||
if (fpath.extension() == ".raw" || fpath.extension() == ".json"){
|
||||
aare::logger::debug("Loading",fpath.extension(),"file");
|
||||
@@ -18,11 +20,12 @@ FileFactory *FileFactory::get_factory(std::filesystem::path fpath) {
|
||||
// check if extension is numpy
|
||||
else if (fpath.extension() == ".npy") {
|
||||
aare::logger::debug("Loading numpy file");
|
||||
return new NumpyFileFactory(fpath);
|
||||
return new aare::NumpyFileFactory(fpath);
|
||||
}
|
||||
|
||||
throw std::runtime_error("Unsupported file type");
|
||||
}
|
||||
|
||||
} // namespace aare
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
#include "aare/NumpyFile.hpp"
|
||||
|
||||
namespace aare{
|
||||
|
||||
void NumpyFile::write(Frame &frame) {
|
||||
if (fp == nullptr) {
|
||||
throw std::runtime_error("File not open");
|
||||
@@ -96,4 +98,6 @@ NumpyFile::~NumpyFile() {
|
||||
fclose(fp);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace aare
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "aare/NumpyFileFactory.hpp"
|
||||
#include "aare/NumpyHelpers.hpp"
|
||||
|
||||
using namespace aare;
|
||||
namespace aare {
|
||||
|
||||
NumpyFileFactory::NumpyFileFactory(std::filesystem::path fpath) { this->m_fpath = fpath; }
|
||||
void NumpyFileFactory::parse_metadata(FileInterface *_file) {
|
||||
@@ -86,3 +86,5 @@ NumpyFile *NumpyFileFactory::load_file_write(FileConfig config) {
|
||||
|
||||
return file;
|
||||
};
|
||||
|
||||
} // namespace aare
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "aare/RawFile.hpp"
|
||||
#include "aare/utils/logger.hpp"
|
||||
|
||||
namespace aare{
|
||||
|
||||
Frame RawFile::get_frame(size_t frame_number) {
|
||||
auto f = Frame(this->m_rows, this->m_cols, this->m_bitdepth);
|
||||
std::byte *frame_buffer = f._get_data();
|
||||
@@ -77,3 +79,5 @@ RawFile::~RawFile() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace aare
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
namespace aare {
|
||||
|
||||
RawFileFactory::RawFileFactory(std::filesystem::path fpath) {
|
||||
if (not is_master_file(fpath))
|
||||
throw std::runtime_error("Json file is not a master file");
|
||||
@@ -180,3 +182,5 @@ void RawFileFactory::parse_fname(FileInterface *file) {
|
||||
pos = file->m_base_name.find("_master_");
|
||||
file->m_base_name.erase(pos);
|
||||
}
|
||||
|
||||
} // namespace aare
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <iostream>
|
||||
// #include <filesystem>
|
||||
|
||||
namespace aare {
|
||||
|
||||
SubFile::SubFile(std::filesystem::path fname, DetectorType detector, ssize_t rows, ssize_t cols, uint16_t bitdepth) {
|
||||
this->m_rows = rows;
|
||||
this->m_cols = cols;
|
||||
@@ -97,3 +99,5 @@ size_t SubFile::frame_number(int frame_index) {
|
||||
|
||||
return h.frameNumber;
|
||||
}
|
||||
|
||||
} // namespace aare
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "aare/helpers.hpp"
|
||||
|
||||
namespace aare {
|
||||
|
||||
bool is_master_file(std::filesystem::path fpath) {
|
||||
std::string stem = fpath.stem();
|
||||
@@ -9,3 +10,4 @@ bool is_master_file(std::filesystem::path fpath) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}// namespace aare
|
||||
Reference in New Issue
Block a user