mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-02-01 11:04:55 +01:00
use clang-tidy (#59)
* use clang-tidy for Frame.cpp * fixes for defs.cpp * clang-tidy 6/45 * clang-tidy for core * clang-tidy fixes: for hpp File,FileInterface,SubFile.cpp * ci fixes * fix build errors * fix clang-tidy command ci * fix clang-tidy ci * clang-tidy for rawfile.cpp * clang-tidy numpy helpers * fix ci * clang-tidy file_io * clang-tidy file_io and core working * zmqheader * clagn-tidy: network_io,file_io,core * clang-tidy working * format --------- Co-authored-by: Bechir <bechir.brahem420@gmail.com>
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
|
||||
#include "aare/core/DType.hpp"
|
||||
#include "aare/utils/logger.hpp"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/core.h>
|
||||
|
||||
namespace aare {
|
||||
|
||||
@@ -26,9 +25,7 @@ DType::DType(const std::type_info &t) {
|
||||
m_type = TypeIndex::INT32;
|
||||
else if (t == typeid(uint32_t))
|
||||
m_type = TypeIndex::UINT32;
|
||||
else if (t == typeid(int64_t))
|
||||
m_type = TypeIndex::INT64;
|
||||
else if (t == typeid(long))
|
||||
else if (t == typeid(int64_t) || t == typeid(long)) // NOLINT
|
||||
m_type = TypeIndex::INT64;
|
||||
else if (t == typeid(uint64_t))
|
||||
m_type = TypeIndex::UINT64;
|
||||
@@ -130,7 +127,7 @@ DType::DType(std::string_view sv) {
|
||||
*/
|
||||
std::string DType::str() const {
|
||||
|
||||
char ec;
|
||||
char ec{};
|
||||
if (endian::native == endian::little)
|
||||
ec = '<';
|
||||
else
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "aare/core/Frame.hpp"
|
||||
#include "aare/utils/logger.hpp"
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sys/types.h>
|
||||
|
||||
namespace aare {
|
||||
|
||||
@@ -12,9 +13,9 @@ namespace aare {
|
||||
* @param cols number of columns
|
||||
* @param bitdepth bitdepth of the pixels
|
||||
*/
|
||||
Frame::Frame(std::byte *bytes, ssize_t rows, ssize_t cols, ssize_t bitdepth)
|
||||
: m_rows(rows), m_cols(cols), m_bitdepth(bitdepth) {
|
||||
m_data = new std::byte[rows * cols * bitdepth / 8];
|
||||
Frame::Frame(std::byte *bytes, size_t rows, size_t cols, size_t bitdepth)
|
||||
: m_rows(rows), m_cols(cols), m_bitdepth(bitdepth), m_data(new std::byte[rows * cols * bitdepth / 8]) {
|
||||
|
||||
std::memcpy(m_data, bytes, rows * cols * bitdepth / 8);
|
||||
}
|
||||
|
||||
@@ -25,8 +26,9 @@ Frame::Frame(std::byte *bytes, ssize_t rows, ssize_t cols, ssize_t bitdepth)
|
||||
* @param bitdepth bitdepth of the pixels
|
||||
* @note the data is initialized to zero
|
||||
*/
|
||||
Frame::Frame(ssize_t rows, ssize_t cols, ssize_t bitdepth) : m_rows(rows), m_cols(cols), m_bitdepth(bitdepth) {
|
||||
m_data = new std::byte[rows * cols * bitdepth / 8];
|
||||
Frame::Frame(size_t rows, size_t cols, size_t bitdepth)
|
||||
: m_rows(rows), m_cols(cols), m_bitdepth(bitdepth), m_data(new std::byte[rows * cols * bitdepth / 8]) {
|
||||
|
||||
std::memset(m_data, 0, rows * cols * bitdepth / 8);
|
||||
}
|
||||
|
||||
@@ -37,10 +39,10 @@ Frame::Frame(ssize_t rows, ssize_t cols, ssize_t bitdepth) : m_rows(rows), m_col
|
||||
* @return pointer to the pixel
|
||||
* @note the user should cast the pointer to the appropriate type
|
||||
*/
|
||||
std::byte *Frame::get(int row, int col) {
|
||||
if (row < 0 || row >= m_rows || col < 0 || col >= m_cols) {
|
||||
std::cerr << "Invalid row or column index" << std::endl;
|
||||
return 0;
|
||||
std::byte *Frame::get(size_t row, size_t col) {
|
||||
if (row >= m_rows or col >= m_cols) {
|
||||
std::cerr << "Invalid row or column index" << '\n';
|
||||
return nullptr;
|
||||
}
|
||||
return m_data + (row * m_cols + col) * (m_bitdepth / 8);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "aare/core/defs.hpp"
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace aare {
|
||||
|
||||
@@ -7,8 +9,8 @@ namespace aare {
|
||||
* @param type DetectorType
|
||||
* @return string representation of the DetectorType
|
||||
*/
|
||||
template <> std::string toString(DetectorType type) {
|
||||
switch (type) {
|
||||
template <> std::string toString(DetectorType arg) {
|
||||
switch (arg) {
|
||||
case DetectorType::Jungfrau:
|
||||
return "Jungfrau";
|
||||
case DetectorType::Eiger:
|
||||
@@ -30,20 +32,18 @@ template <> std::string toString(DetectorType type) {
|
||||
* @return DetectorType
|
||||
* @throw runtime_error if the string does not match any DetectorType
|
||||
*/
|
||||
template <> DetectorType StringTo(std::string name) {
|
||||
if (name == "Jungfrau")
|
||||
template <> DetectorType StringTo(const std::string &arg) {
|
||||
if (arg == "Jungfrau")
|
||||
return DetectorType::Jungfrau;
|
||||
else if (name == "Eiger")
|
||||
if (arg == "Eiger")
|
||||
return DetectorType::Eiger;
|
||||
else if (name == "Mythen3")
|
||||
if (arg == "Mythen3")
|
||||
return DetectorType::Mythen3;
|
||||
else if (name == "Moench")
|
||||
if (arg == "Moench")
|
||||
return DetectorType::Moench;
|
||||
else if (name == "ChipTestBoard")
|
||||
if (arg == "ChipTestBoard")
|
||||
return DetectorType::ChipTestBoard;
|
||||
else {
|
||||
throw std::runtime_error("Could not decode dector from: \"" + name + "\"");
|
||||
}
|
||||
throw std::runtime_error("Could not decode dector from: \"" + arg + "\"");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,14 +52,12 @@ template <> DetectorType StringTo(std::string name) {
|
||||
* @return TimingMode
|
||||
* @throw runtime_error if the string does not match any TimingMode
|
||||
*/
|
||||
template <> TimingMode StringTo(std::string mode) {
|
||||
if (mode == "auto")
|
||||
template <> TimingMode StringTo(const std::string &arg) {
|
||||
if (arg == "auto")
|
||||
return TimingMode::Auto;
|
||||
else if (mode == "trigger")
|
||||
if (arg == "trigger")
|
||||
return TimingMode::Trigger;
|
||||
else {
|
||||
throw std::runtime_error("Could not decode timing mode from: \"" + mode + "\"");
|
||||
}
|
||||
throw std::runtime_error("Could not decode timing mode from: \"" + arg + "\"");
|
||||
}
|
||||
|
||||
// template <> TimingMode StringTo<TimingMode>(std::string mode);
|
||||
|
||||
Reference in New Issue
Block a user