Merge pull request #52 from slsdetectorgroup/feature/formatting-in-cmake

add formatting as target in cmake
This commit is contained in:
Bechir Braham 2024-04-04 17:25:45 +02:00 committed by GitHub
commit 818ad608d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 320 additions and 401 deletions

View File

@ -11,7 +11,11 @@ jobs:
# find all examples in build/examples and run them
run: |
pwd
find -name "*.cpp" -not -path "./build/*" | xargs -I {} -n 1 -P 10 clang-format {} -Werror --dry-run -style='file:.clang-format'
mkdir build
cd build
cmake ..
cmake --build . --target=check-format

View File

@ -164,3 +164,22 @@ add_subdirectory(examples)
if(AARE_PYTHON_BINDINGS)
add_subdirectory(python)
endif()
# custom target to run check formatting with clang-format
add_custom_target(
check-format
COMMAND find \( -name "*.cpp" -o -name "*.hpp" \) -not -path "./build/*" | xargs -I {} -n 1 -P 10 bash -c "clang-format -Werror -style=\"file:.clang-format\" {} | diff {} -"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Checking code formatting with clang-format"
VERBATIM
)
add_custom_target(
format-files
COMMAND find \( -name "*.cpp" -o -name "*.hpp" \) -not -path "./build/*" | xargs -I {} -n 1 -P 10 bash -c "clang-format -i -style=\"file:.clang-format\" {}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Formatting with clang-format"
VERBATIM
)

View File

@ -17,8 +17,7 @@ template <class ItemType> class CircularFifo {
public:
CircularFifo() : CircularFifo(100){};
CircularFifo(uint32_t size)
: fifo_size(size), free_slots(size+1), filled_slots(size+1) {
CircularFifo(uint32_t size) : fifo_size(size), free_slots(size + 1), filled_slots(size + 1) {
// TODO! how do we deal with alignment for writing? alignas???
// Do we give the user a chance to provide memory locations?
@ -36,7 +35,6 @@ template <class ItemType> class CircularFifo {
if (!free_slots.write(std::move(it)))
return false;
return true;
}
~CircularFifo() {}
@ -55,12 +53,9 @@ ItemType pop_free() {
// return v;
}
bool try_pop_free(ItemType& v){
return free_slots.read(v);
}
bool try_pop_free(ItemType &v) { return free_slots.read(v); }
ItemType pop_value(std::chrono::nanoseconds wait,
std::atomic<bool> &stopped) {
ItemType pop_value(std::chrono::nanoseconds wait, std::atomic<bool> &stopped) {
ItemType v;
while (!filled_slots.read(v) && !stopped) {
std::this_thread::sleep_for(wait);
@ -75,38 +70,28 @@ ItemType pop_value() {
return std::move(v);
}
ItemType* frontPtr(){
return filled_slots.frontPtr();
}
ItemType *frontPtr() { return filled_slots.frontPtr(); }
// TODO! Add function to move item from filled to free to be used
// with the frontPtr function
template <class... Args>
void push_value(Args&&... recordArgs) {
template <class... Args> void push_value(Args &&...recordArgs) {
while (!filled_slots.write(std::forward<Args>(recordArgs)...))
;
}
template <class... Args>
bool try_push_value(Args&&... recordArgs) {
template <class... Args> bool try_push_value(Args &&...recordArgs) {
return filled_slots.write(std::forward<Args>(recordArgs)...);
}
template <class... Args>
void push_free(Args&&... recordArgs) {
template <class... Args> void push_free(Args &&...recordArgs) {
while (!free_slots.write(std::forward<Args>(recordArgs)...))
;
}
template <class... Args>
bool try_push_free(Args&&... recordArgs) {
template <class... Args> bool try_push_free(Args &&...recordArgs) {
return free_slots.write(std::forward<Args>(recordArgs)...);
}
};
} // namespace aare

View File

@ -4,7 +4,6 @@
#include <cstddef>
#include <cstdint>
#include <memory>
#include <vector>
#include <sys/types.h>
#include <vector>
@ -27,10 +26,8 @@ class Frame {
Frame(std::byte *fp, ssize_t rows, ssize_t cols, ssize_t m_bitdepth);
std::byte *get(int row, int col);
// TODO! can we, or even want to remove the template?
template <typename T>
void set(int row, int col, T data) {
template <typename T> void set(int row, int col, T data) {
assert(sizeof(T) == m_bitdepth / 8);
if (row < 0 || row >= m_rows || col < 0 || col >= m_cols) {
throw std::out_of_range("Invalid row or column index");
@ -62,20 +59,15 @@ class Frame {
other.m_rows = other.m_cols = other.m_bitdepth = 0;
}
template <typename T>
NDView<T> view() {
template <typename T> NDView<T> view() {
std::vector<ssize_t> shape = {m_rows, m_cols};
T *data = reinterpret_cast<T *>(m_data);
return NDView<T>(data, shape);
}
template <typename T>
NDArray<T> image() {
return NDArray<T>(this->view<T>());
}
template <typename T> NDArray<T> image() { return NDArray<T>(this->view<T>()); }
~Frame() { delete[] m_data; }
};
} // namespace aare

View File

@ -22,19 +22,13 @@ namespace aare {
template <typename T, ssize_t Ndim = 2> class NDArray {
public:
NDArray()
: shape_(), strides_(c_strides<Ndim>(shape_)), size_(0),
data_(nullptr){};
NDArray() : shape_(), strides_(c_strides<Ndim>(shape_)), size_(0), data_(nullptr){};
explicit NDArray(std::array<ssize_t, Ndim> shape)
: shape_(shape), strides_(c_strides<Ndim>(shape_)),
size_(std::accumulate(shape_.begin(), shape_.end(), 1,
std::multiplies<ssize_t>())),
data_(new T[size_]){};
size_(std::accumulate(shape_.begin(), shape_.end(), 1, std::multiplies<ssize_t>())), data_(new T[size_]){};
NDArray(std::array<ssize_t, Ndim> shape, T value) : NDArray(shape) {
this->operator=(value);
}
NDArray(std::array<ssize_t, Ndim> shape, T value) : NDArray(shape) { this->operator=(value); }
/* When constructing from a NDView we need to copy the data since
NDArray expect to own its data, and span is just a view*/
@ -45,8 +39,7 @@ template <typename T, ssize_t Ndim = 2> class NDArray {
// Move constructor
NDArray(NDArray &&other)
: shape_(other.shape_), strides_(c_strides<Ndim>(shape_)),
size_(other.size_), data_(nullptr) {
: shape_(other.shape_), strides_(c_strides<Ndim>(shape_)), size_(other.size_), data_(nullptr) {
data_ = other.data_;
other.reset();
// fmt::print("NDArray(NDArray &&other)\n");
@ -54,15 +47,12 @@ template <typename T, ssize_t Ndim = 2> class NDArray {
// Copy constructor
NDArray(const NDArray &other)
: shape_(other.shape_), strides_(c_strides<Ndim>(shape_)),
size_(other.size_), data_(new T[size_]) {
: shape_(other.shape_), strides_(c_strides<Ndim>(shape_)), size_(other.size_), data_(new T[size_]) {
std::copy(other.data_, other.data_ + size_, data_);
// fmt::print("NDArray(const NDArray &other)\n");
}
~NDArray() {
delete[] data_;
}
~NDArray() { delete[] data_; }
auto begin() { return data_; }
auto end() { return data_ + size_; }
@ -80,8 +70,7 @@ template <typename T, ssize_t Ndim = 2> class NDArray {
NDArray &operator*=(const NDArray &other);
NDArray operator/(const NDArray &other);
// NDArray& operator/=(const NDArray& other);
template <typename V>
NDArray &operator/=(const NDArray<V, Ndim> &other) {
template <typename V> NDArray &operator/=(const NDArray<V, Ndim> &other) {
// check shape
if (shape_ == other.shape()) {
for (int i = 0; i < size_; ++i) {
@ -118,21 +107,15 @@ template <typename T, ssize_t Ndim = 2> class NDArray {
NDArray &operator++(); // pre inc
template <typename... Ix>
typename std::enable_if<sizeof...(Ix) == Ndim, T &>::type
operator()(Ix... index) {
template <typename... Ix> typename std::enable_if<sizeof...(Ix) == Ndim, T &>::type operator()(Ix... index) {
return data_[element_offset(strides_, index...)];
}
template <typename... Ix>
typename std::enable_if<sizeof...(Ix) == Ndim, T &>::type
operator()(Ix... index) const{
template <typename... Ix> typename std::enable_if<sizeof...(Ix) == Ndim, T &>::type operator()(Ix... index) const {
return data_[element_offset(strides_, index...)];
}
template <typename... Ix>
typename std::enable_if<sizeof...(Ix) == Ndim, T>::type value(Ix... index) {
template <typename... Ix> typename std::enable_if<sizeof...(Ix) == Ndim, T>::type value(Ix... index) {
return data_[element_offset(strides_, index...)];
}
@ -175,8 +158,7 @@ template <typename T, ssize_t Ndim = 2> class NDArray {
};
// Move assign
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> &NDArray<T, Ndim>::operator=(NDArray<T, Ndim> &&other) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator=(NDArray<T, Ndim> &&other) {
if (this != &other) {
delete[] data_;
data_ = other.data_;
@ -188,15 +170,12 @@ NDArray<T, Ndim> &NDArray<T, Ndim>::operator=(NDArray<T, Ndim> &&other) {
return *this;
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> NDArray<T, Ndim>::operator+(const NDArray &other) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> NDArray<T, Ndim>::operator+(const NDArray &other) {
NDArray result(*this);
result += other;
return result;
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> &
NDArray<T, Ndim>::operator+=(const NDArray<T, Ndim> &other) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator+=(const NDArray<T, Ndim> &other) {
// check shape
if (shape_ == other.shape_) {
for (int i = 0; i < size_; ++i) {
@ -208,16 +187,13 @@ NDArray<T, Ndim>::operator+=(const NDArray<T, Ndim> &other) {
}
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> NDArray<T, Ndim>::operator-(const NDArray &other) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> NDArray<T, Ndim>::operator-(const NDArray &other) {
NDArray result{*this};
result -= other;
return result;
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> &
NDArray<T, Ndim>::operator-=(const NDArray<T, Ndim> &other) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator-=(const NDArray<T, Ndim> &other) {
// check shape
if (shape_ == other.shape_) {
for (int i = 0; i < size_; ++i) {
@ -228,16 +204,13 @@ NDArray<T, Ndim>::operator-=(const NDArray<T, Ndim> &other) {
throw(std::runtime_error("Shape of ImageDatas must match"));
}
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> NDArray<T, Ndim>::operator*(const NDArray &other) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> NDArray<T, Ndim>::operator*(const NDArray &other) {
NDArray result = *this;
result *= other;
return result;
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> &
NDArray<T, Ndim>::operator*=(const NDArray<T, Ndim> &other) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator*=(const NDArray<T, Ndim> &other) {
// check shape
if (shape_ == other.shape_) {
for (int i = 0; i < size_; ++i) {
@ -249,15 +222,13 @@ NDArray<T, Ndim>::operator*=(const NDArray<T, Ndim> &other) {
}
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> NDArray<T, Ndim>::operator/(const NDArray &other) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> NDArray<T, Ndim>::operator/(const NDArray &other) {
NDArray result = *this;
result /= other;
return result;
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> &NDArray<T, Ndim>::operator&=(const T &mask) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator&=(const T &mask) {
for (auto it = begin(); it != end(); ++it)
*it &= mask;
return *this;
@ -278,8 +249,7 @@ NDArray<T, Ndim> &NDArray<T, Ndim>::operator&=(const T &mask) {
// }
// }
template <typename T, ssize_t Ndim>
NDArray<bool, Ndim> NDArray<T, Ndim>::operator>(const NDArray &other) {
template <typename T, ssize_t Ndim> NDArray<bool, Ndim> NDArray<T, Ndim>::operator>(const NDArray &other) {
if (shape_ == other.shape_) {
NDArray<bool> result{shape_};
for (int i = 0; i < size_; ++i) {
@ -291,9 +261,7 @@ NDArray<bool, Ndim> NDArray<T, Ndim>::operator>(const NDArray &other) {
}
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> &
NDArray<T, Ndim>::operator=(const NDArray<T, Ndim> &other) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator=(const NDArray<T, Ndim> &other) {
if (this != &other) {
delete[] data_;
shape_ = other.shape_;
@ -305,8 +273,7 @@ NDArray<T, Ndim>::operator=(const NDArray<T, Ndim> &other) {
return *this;
}
template <typename T, ssize_t Ndim>
bool NDArray<T, Ndim>::operator==(const NDArray<T, Ndim> &other) const {
template <typename T, ssize_t Ndim> bool NDArray<T, Ndim>::operator==(const NDArray<T, Ndim> &other) const {
if (shape_ != other.shape_)
return false;
@ -317,68 +284,57 @@ bool NDArray<T, Ndim>::operator==(const NDArray<T, Ndim> &other) const {
return true;
}
template <typename T, ssize_t Ndim>
bool NDArray<T, Ndim>::operator!=(const NDArray<T, Ndim> &other) const {
template <typename T, ssize_t Ndim> bool NDArray<T, Ndim>::operator!=(const NDArray<T, Ndim> &other) const {
return !((*this) == other);
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> &NDArray<T, Ndim>::operator++() {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator++() {
for (int i = 0; i < size_; ++i)
data_[i] += 1;
return *this;
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> &NDArray<T, Ndim>::operator=(const T &value) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator=(const T &value) {
std::fill_n(data_, size_, value);
return *this;
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> &NDArray<T, Ndim>::operator+=(const T &value) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator+=(const T &value) {
for (int i = 0; i < size_; ++i)
data_[i] += value;
return *this;
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> NDArray<T, Ndim>::operator+(const T &value) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> NDArray<T, Ndim>::operator+(const T &value) {
NDArray result = *this;
result += value;
return result;
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> &NDArray<T, Ndim>::operator-=(const T &value) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator-=(const T &value) {
for (int i = 0; i < size_; ++i)
data_[i] -= value;
return *this;
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> NDArray<T, Ndim>::operator-(const T &value) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> NDArray<T, Ndim>::operator-(const T &value) {
NDArray result = *this;
result -= value;
return result;
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> &NDArray<T, Ndim>::operator/=(const T &value) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator/=(const T &value) {
for (int i = 0; i < size_; ++i)
data_[i] /= value;
return *this;
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> NDArray<T, Ndim>::operator/(const T &value) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> NDArray<T, Ndim>::operator/(const T &value) {
NDArray result = *this;
result /= value;
return result;
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> &NDArray<T, Ndim>::operator*=(const T &value) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> &NDArray<T, Ndim>::operator*=(const T &value) {
for (int i = 0; i < size_; ++i)
data_[i] *= value;
return *this;
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> NDArray<T, Ndim>::operator*(const T &value) {
template <typename T, ssize_t Ndim> NDArray<T, Ndim> NDArray<T, Ndim>::operator*(const T &value) {
NDArray result = *this;
result *= value;
return result;
@ -408,8 +364,7 @@ template <typename T, ssize_t Ndim> void NDArray<T, Ndim>::Print_some() {
}
}
template <typename T, ssize_t Ndim>
void save(NDArray<T, Ndim> &img, std::string pathname) {
template <typename T, ssize_t Ndim> void save(NDArray<T, Ndim> &img, std::string pathname) {
std::ofstream f;
f.open(pathname, std::ios::binary);
f.write(img.buffer(), img.size() * sizeof(T));
@ -417,8 +372,7 @@ void save(NDArray<T, Ndim> &img, std::string pathname) {
}
template <typename T, ssize_t Ndim>
NDArray<T, Ndim> load(const std::string &pathname,
std::array<ssize_t, Ndim> shape) {
NDArray<T, Ndim> load(const std::string &pathname, std::array<ssize_t, Ndim> shape) {
NDArray<T, Ndim> img{shape};
std::ifstream f;
f.open(pathname, std::ios::binary);
@ -427,5 +381,4 @@ NDArray<T, Ndim> load(const std::string &pathname,
return img;
}
} // namespace aare

View File

@ -4,16 +4,15 @@
#include <cassert>
#include <cstdint>
#include <numeric>
#include <vector>
#include <stdexcept>
#include <vector>
namespace aare {
template <ssize_t Ndim> using Shape = std::array<ssize_t, Ndim>;
// TODO! fix mismatch between signed and unsigned
template <ssize_t Ndim>
Shape<Ndim> make_shape(const std::vector<size_t>& shape){
template <ssize_t Ndim> Shape<Ndim> make_shape(const std::vector<size_t> &shape) {
if (shape.size() != Ndim)
throw std::runtime_error("Shape size mismatch");
Shape<Ndim> arr;
@ -60,7 +59,6 @@ template <typename T, ssize_t Ndim=2> class NDView {
strides_ = c_strides<Ndim>(make_array<Ndim>(shape));
shape_ = make_array<Ndim>(shape);
size_ = std::accumulate(std::begin(shape), std::end(shape), 1, std::multiplies<ssize_t>());
}
template <typename... Ix> typename std::enable_if<sizeof...(Ix) == Ndim, T &>::type operator()(Ix... index) {

View File

@ -38,8 +38,7 @@ namespace folly {
* ProducerConsumerQueue is a one producer and one consumer queue
* without locks.
*/
template <class T>
struct ProducerConsumerQueue {
template <class T> struct ProducerConsumerQueue {
typedef T value_type;
ProducerConsumerQueue(const ProducerConsumerQueue &) = delete;
@ -51,10 +50,7 @@ struct ProducerConsumerQueue {
// given time is actually (size-1), so if you start with an empty queue,
// isFull() will return true after size-1 insertions.
explicit ProducerConsumerQueue(uint32_t size)
: size_(size),
records_(static_cast<T*>(std::malloc(sizeof(T) * size))),
readIndex_(0),
writeIndex_(0) {
: size_(size), records_(static_cast<T *>(std::malloc(sizeof(T) * size))), readIndex_(0), writeIndex_(0) {
assert(size >= 2);
if (!records_) {
throw std::bad_alloc();
@ -79,8 +75,7 @@ struct ProducerConsumerQueue {
std::free(records_);
}
template <class... Args>
bool write(Args&&... recordArgs) {
template <class... Args> bool write(Args &&...recordArgs) {
auto const currentWrite = writeIndex_.load(std::memory_order_relaxed);
auto nextRecord = currentWrite + 1;
if (nextRecord == size_) {
@ -139,8 +134,7 @@ struct ProducerConsumerQueue {
}
bool isEmpty() const {
return readIndex_.load(std::memory_order_acquire) ==
writeIndex_.load(std::memory_order_acquire);
return readIndex_.load(std::memory_order_acquire) == writeIndex_.load(std::memory_order_acquire);
}
bool isFull() const {
@ -161,8 +155,7 @@ struct ProducerConsumerQueue {
// be removing items concurrently).
// * It is undefined to call this from any other thread.
size_t sizeGuess() const {
int ret = writeIndex_.load(std::memory_order_acquire) -
readIndex_.load(std::memory_order_acquire);
int ret = writeIndex_.load(std::memory_order_acquire) - readIndex_.load(std::memory_order_acquire);
if (ret < 0) {
ret += size_;
}

View File

@ -5,7 +5,6 @@
#include <unordered_map>
#include <vector>
#include "aare/NDArray.hpp"
const int MAX_CLUSTER_SIZE = 200;
@ -51,14 +50,16 @@ template <typename T> class ClusterFinder {
public:
ClusterFinder(image_shape shape, T threshold)
: shape_(shape), labeled_(shape, 0), peripheral_labeled_(shape, 0), binary_(shape),
threshold_(threshold) {
: shape_(shape), labeled_(shape, 0), peripheral_labeled_(shape, 0), binary_(shape), threshold_(threshold) {
hits.reserve(2000);
}
NDArray<int, 2> labeled() { return labeled_; }
void set_noiseMap(NDView<T, 2> noise_map) { noiseMap = noise_map; use_noise_map = true; }
void set_noiseMap(NDView<T, 2> noise_map) {
noiseMap = noise_map;
use_noise_map = true;
}
void set_peripheralThresholdFactor(int factor) { peripheralThresholdFactor_ = factor; }
void find_clusters(NDView<T, 2> img);
void find_clusters_X(NDView<T, 2> img);
@ -140,7 +141,6 @@ template <typename T> int ClusterFinder<T>::check_neighbours(int i, int j) {
add_link(*current, *next);
}
return neighbour_labels.back(); // already sorted
}
}
@ -200,8 +200,7 @@ template <typename T> void ClusterFinder<T>::rec_FillHit(int clusterIndex, int i
threshold_ = peripheralThresholdFactor_ * noiseMap(row, col);
if (original_(row, col) > threshold_) {
rec_FillHit(clusterIndex, row, col);
}
else{
} else {
// if (h_size[clusterIndex].size < MAX_CLUSTER_SIZE){
// h_size[clusterIndex].size += 1;
// h_size[clusterIndex].rows[h_size[clusterIndex].size] = row;
@ -286,8 +285,7 @@ template <typename T> void ClusterFinder<T>::store_clusters() {
record.rows[record.size] = i;
record.cols[record.size] = j;
record.enes[record.size] = original_(i, j);
}
else{
} else {
continue;
}
record.size += 1;
@ -304,7 +302,6 @@ template <typename T> void ClusterFinder<T>::store_clusters() {
for (const auto &h : h_size)
hits.push_back(h.second);
}
} // namespace aare

View File

@ -1,10 +1,9 @@
#pragma once
#include <array>
#include <cstdint>
#include <map>
#include <string>
#include <cstdint>
// Socket to receive data from a ZMQ publisher
// needs to be in sync with the main library (or maybe better use the versioning in the header)
@ -65,7 +64,6 @@ struct zmqHeader {
std::array<int, 4> rx_roi{};
};
class ZmqSocket {
void *m_context{nullptr};
void *m_socket{nullptr};
@ -90,8 +88,6 @@ public:
void set_timeout_ms(int n);
int receive(zmqHeader &header, std::byte *data);
};
} // namespace aare

View File

@ -1,13 +1,13 @@
#pragma once
#include <array>
#include <vector>
#include <sys/types.h>
#include <string_view>
#include <string>
#include <stdexcept>
#include <fmt/format.h>
#include <stdexcept>
#include <string>
#include <string_view>
#include <sys/types.h>
#include <variant>
#include <vector>
namespace aare {
@ -40,25 +40,17 @@ enum class DetectorType { Jungfrau, Eiger, Mythen3, Moench,ChipTestBoard };
enum class TimingMode { Auto, Trigger };
template<class T>
T StringTo(std::string sv){
return T(sv);
}
template <class T> T StringTo(std::string sv) { return T(sv); }
template<class T>
std::string toString(T sv){
return T(sv);
}
template <class T> std::string toString(T sv) { return T(sv); }
template <> DetectorType StringTo(std::string);
template <> std::string toString(DetectorType type);
template <> TimingMode StringTo(std::string);
using DataTypeVariants = std::variant<uint16_t, uint32_t>;
struct RawFileConfig {
int module_gap_row{};
int module_gap_col{};
@ -72,6 +64,4 @@ struct RawFileConfig {
}
};
} // namespace aare

View File

@ -30,7 +30,6 @@ class File {
ssize_t bitdepth() const;
File(File &&other);
~File();
};

View File

@ -1,7 +1,7 @@
#pragma once
#include "aare/DType.hpp"
#include "aare/Frame.hpp"
#include "aare/defs.hpp"
#include "aare/DType.hpp"
#include "aare/utils/logger.hpp"
#include <filesystem>
#include <vector>
@ -96,4 +96,4 @@ class FileInterface {
ssize_t m_bitdepth{};
};
}
} // namespace aare

View File

@ -1,11 +1,11 @@
#pragma once
#include "aare/DType.hpp"
#include "aare/FileInterface.hpp"
#include "aare/NumpyHelpers.hpp"
#include "aare/DType.hpp"
#include "aare/defs.hpp"
#include <filesystem>
#include <iostream>
#include <numeric>
#include <filesystem>
namespace aare {
@ -26,8 +26,6 @@ class NumpyFile : public FileInterface {
Frame get_frame(size_t frame_number);
public:
NumpyFile(const std::filesystem::path &fname);
NumpyFile(FileConfig, NumpyHeader);
void write(Frame &frame) override;
@ -50,8 +48,7 @@ class NumpyFile : public FileInterface {
std::vector<size_t> shape() const { return m_header.shape; }
// load the full numpy file into a NDArray
template<typename T, size_t NDim>
NDArray<T,NDim> load(){
template <typename T, size_t NDim> NDArray<T, NDim> load() {
NDArray<T, NDim> arr(make_shape<NDim>(m_header.shape));
fseek(fp, header_size, SEEK_SET);
fread(arr.data(), sizeof(T), arr.size(), fp);

View File

@ -17,7 +17,6 @@ class NumpyFileFactory : public FileFactory {
NumpyFile *load_file_read() override;
NumpyFile *load_file_write(FileConfig) override;
void parse_fname(FileInterface *) override{};
};
} // namespace aare

View File

@ -54,6 +54,5 @@ aare::DType parse_descr(std::string typestring);
size_t write_header(std::filesystem::path fname, const NumpyHeader &header);
size_t write_header(std::ostream &out, const NumpyHeader &header);
} // namespace NumpyHelpers
} // namespace aare

View File

@ -10,7 +10,6 @@ class RawFile : public FileInterface {
using config = RawFileConfig;
public:
std::filesystem::path m_fname; // TO be made private!
void write(Frame &frame) override{};
@ -75,4 +74,4 @@ class RawFile : public FileInterface {
Frame get_frame(size_t frame_number);
};
}
} // namespace aare

View File

@ -10,7 +10,6 @@ class RawFileFactory : public FileFactory {
void parse_raw_metadata(RawFile *file);
public:
RawFileFactory(std::filesystem::path fpath);
RawFile *load_file_read() override;
RawFile *load_file_write(FileConfig) override { return new RawFile(); };
@ -21,4 +20,4 @@ class RawFileFactory : public FileFactory {
void find_geometry(FileInterface *);
};
}
} // namespace aare