silence warnings

This commit is contained in:
Erik Frojdh 2024-03-08 16:13:17 +01:00
parent e8f81e618d
commit b8cd465a12
5 changed files with 24 additions and 21 deletions

View File

@ -17,6 +17,7 @@ class File {
private:
public:
virtual ~File() = default;
std::filesystem::path fname;
std::filesystem::path base_path;
std::string base_name, ext;

View File

@ -6,13 +6,14 @@ class FileFactory{
// Class that will be used to create File objects
// follows the factory pattern
protected:
std::filesystem::path fpath;
std::filesystem::path m_fpath;
public:
static FileFactory<detector,DataType>* get_factory(std::filesystem::path);
// virtual int deleteFile() = 0;
virtual File<detector,DataType>* load_file()=0;//TODO: add option to load all file to memory or keep it on disk
virtual void parse_metadata(File<detector,DataType>*)=0;
virtual void parse_fname(File<detector,DataType>*)=0;
virtual ~FileFactory() = default;

View File

@ -7,7 +7,12 @@
class SubFile {
protected:
FILE *fp = nullptr;
uint16_t bitdepth;
uint16_t m_bitdepth;
std::filesystem::path m_fname;
ssize_t m_rows{};
ssize_t m_cols{};
ssize_t n_frames{};
int m_sub_file_index_{};
public:
// pointer to a read_impl function. pointer will be set to the appropriate read_impl function in the constructor
@ -22,11 +27,7 @@ class SubFile {
size_t get_frame(std::byte *buffer, int frame_number);
// TODO: define the inlines as variables and assign them in constructor
inline size_t bytes_per_frame() { return (bitdepth / 8) * rows * cols; }
inline size_t pixels_per_frame() { return rows * cols; }
std::filesystem::path fname;
ssize_t rows{};
ssize_t cols{};
ssize_t n_frames{};
int sub_file_index_{};
inline size_t bytes_per_frame() { return (m_bitdepth / 8) * m_rows * m_cols; }
inline size_t pixels_per_frame() { return m_rows * m_cols; }
};

View File

@ -13,7 +13,7 @@ template <DetectorType detector,typename DataType>
JsonFileFactory<detector,DataType>::JsonFileFactory(std::filesystem::path fpath) {
if (not is_master_file(fpath))
throw std::runtime_error("Json file is not a master file");
this->fpath = fpath;
this->m_fpath = fpath;
}
template <DetectorType detector,typename DataType>
@ -63,7 +63,7 @@ void JsonFileFactory<detector,DataType>::open_subfiles(File<detector,DataType> *
template <DetectorType detector,typename DataType>
File<detector,DataType> *JsonFileFactory<detector,DataType>::load_file() {
JsonFile<detector,DataType> *file = new JsonFile<detector,DataType>();
file->fname = this->fpath;
file->fname = this->m_fpath;
this->parse_fname(file);
this->parse_metadata(file);
file->find_number_of_subfiles();
@ -113,9 +113,9 @@ void JsonFileFactory<detector, DataType>::find_geometry(File<detector, DataType>
template <DetectorType detector, typename DataType>
void JsonFileFactory<detector, DataType>::parse_fname(File<detector, DataType> *file) {
file->base_path = this->fpath.parent_path();
file->base_name = this->fpath.stem();
file->ext = this->fpath.extension();
file->base_path = this->m_fpath.parent_path();
file->base_name = this->m_fpath.stem();
file->ext = this->m_fpath.extension();
auto pos = file->base_name.rfind("_");
file->findex = std::stoi(file->base_name.substr(pos + 1));

View File

@ -9,10 +9,10 @@
*/
SubFile::SubFile(std::filesystem::path fname, DetectorType detector, ssize_t rows, ssize_t cols, uint16_t bitdepth) {
this->rows = rows;
this->cols = cols;
this->fname = fname;
this->bitdepth = bitdepth;
this->m_rows = rows;
this->m_cols = cols;
this->m_fname = fname;
this->m_bitdepth = bitdepth;
fp = fopen(fname.c_str(), "rb");
if (fp == nullptr) {
throw std::runtime_error("Could not open file " + fname.string());
@ -77,12 +77,12 @@ template <typename DataType> size_t SubFile::read_impl_flip(std::byte *buffer) {
size_t rc = fread(reinterpret_cast<char *>(&tmp[0]), this->bytes_per_frame(), 1, this->fp);
// copy to place
const size_t start = this->cols * (this->rows - 1) * sizeof(DataType);
const size_t row_size = this->cols * sizeof(DataType);
const size_t start = this->m_cols * (this->m_rows - 1) * sizeof(DataType);
const size_t row_size = this->m_cols * sizeof(DataType);
auto dst = buffer + start;
auto src = &tmp[0];
for (int i = 0; i != this->rows; ++i) {
for (int i = 0; i != this->m_rows; ++i) {
memcpy(dst, src, row_size);
dst -= row_size;
src += row_size;