mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-06 21:00:41 +02:00
prefixed members rows and cols with m_ to avoid -Wshadow
This commit is contained in:
parent
dec072c090
commit
e8f81e618d
@ -1,35 +1,37 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstddef>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <bits/unique_ptr.h>
|
|
||||||
#include <vector>
|
|
||||||
#include "aare/defs.hpp"
|
#include "aare/defs.hpp"
|
||||||
|
#include <bits/unique_ptr.h>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Frame class to represent a single frame of data
|
* @brief Frame class to represent a single frame of data
|
||||||
* model class
|
* model class
|
||||||
* should be able to work with streams coming from files or network
|
* should be able to work with streams coming from files or network
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
template <class DataType> class Frame {
|
||||||
|
ssize_t m_rows;
|
||||||
|
ssize_t m_cols;
|
||||||
|
DataType *m_data;
|
||||||
|
ssize_t m_bitdepth = sizeof(DataType) * 8;
|
||||||
|
|
||||||
template <class DataType> class Frame{
|
public:
|
||||||
|
Frame(std::byte *fp, ssize_t rows, ssize_t cols);
|
||||||
public:
|
|
||||||
ssize_t rows;
|
|
||||||
ssize_t cols;
|
|
||||||
DataType* data;
|
|
||||||
ssize_t bitdepth = sizeof(DataType)*8;
|
|
||||||
|
|
||||||
Frame(std::byte* fp, ssize_t rows, ssize_t cols);
|
|
||||||
DataType get(int row, int col);
|
DataType get(int row, int col);
|
||||||
|
ssize_t rows() const{
|
||||||
~Frame(){
|
return m_rows;
|
||||||
delete[] data;
|
}
|
||||||
|
ssize_t cols() const{
|
||||||
|
return m_cols;
|
||||||
|
}
|
||||||
|
ssize_t bitdepth() const{
|
||||||
|
return m_bitdepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Frame() { delete[] m_data; }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Frame<uint16_t> Frame16;
|
typedef Frame<uint16_t> Frame16;
|
||||||
|
@ -3,20 +3,19 @@
|
|||||||
|
|
||||||
template <typename DataType>
|
template <typename DataType>
|
||||||
Frame<DataType>::Frame(std::byte* bytes, ssize_t rows, ssize_t cols):
|
Frame<DataType>::Frame(std::byte* bytes, ssize_t rows, ssize_t cols):
|
||||||
rows(rows), cols(cols) {
|
m_rows(rows), m_cols(cols) {
|
||||||
data = new DataType[rows*cols];
|
m_data = new DataType[rows*cols];
|
||||||
std::memcpy(data, bytes, rows*cols*sizeof(DataType));
|
std::memcpy(m_data, bytes, m_rows*m_cols*sizeof(DataType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <typename DataType>
|
template <typename DataType>
|
||||||
DataType Frame<DataType>::get(int row, int col) {
|
DataType Frame<DataType>::get(int row, int col) {
|
||||||
if (row < 0 || row >= rows || col < 0 || col >= cols) {
|
if (row < 0 || row >= m_rows || col < 0 || col >= m_cols) {
|
||||||
std::cerr << "Invalid row or column index" << std::endl;
|
std::cerr << "Invalid row or column index" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return data[row*cols + col];
|
return m_data[row*m_cols + col];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,9 +27,9 @@ PYBIND11_MODULE(_aare, m) {
|
|||||||
py::class_<Frame<uint16_t>>(m, "_Frame16")
|
py::class_<Frame<uint16_t>>(m, "_Frame16")
|
||||||
.def(py::init<std::byte*, ssize_t, ssize_t>())
|
.def(py::init<std::byte*, ssize_t, ssize_t>())
|
||||||
.def("get", &Frame<uint16_t>::get)
|
.def("get", &Frame<uint16_t>::get)
|
||||||
.def_readonly("rows", &Frame<uint16_t>::rows)
|
.def_property_readonly("rows", &Frame<uint16_t>::rows)
|
||||||
.def_readonly("cols", &Frame<uint16_t>::cols)
|
.def_property_readonly("cols", &Frame<uint16_t>::cols)
|
||||||
.def_readonly("bitdepth", &Frame<uint16_t>::bitdepth);
|
.def_property_readonly("bitdepth", &Frame<uint16_t>::bitdepth);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user