summaryrefslogtreecommitdiff
path: root/src/pixels.h
blob: 3c64b39e006b47de47830eca617776f63f8f4131 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once

#include <array>
#include <mutex>

#include "fuck_intel.h"

#include <QString>

#include "constants.h"
#include "typedefs.h"

struct Pixels
{
    // TODO: try to avoid setting default values to speedup
    // could be even made a ref/ptr to image counters
    Counters counters{};
    std::array<float, img_width> pixels{0.f};

    Pixels& operator+=(const Pixels& other);
    Pixels& operator/=(const float divider);

    // TODO: tests for everything everywhere
    /*!
     * \brief load - load binary pixels from file
     * \param filename - file path
     * \return Pixels on success, empty std::optional otherwise
     */
    [[nodiscard]] static std::optional<Pixels> load(const QString& filename);
    /*!
     * \brief save - save binary profile to file
     * \param filename - file path
     * \return - true on success, false otherwise
     */
    [[nodiscard]] bool save(const QString& filename);

    operator bool() const;

    // TODO: forbid copying
    // Pixels() = default;
    // Pixels(Pixels &&) = default;
    // Pixels &operator=(Pixels &&) = default;

    // Pixels(Pixels &) = delete;
    // Pixels(const Pixels &) = delete;
    // Pixels &operator=(Pixels &) = delete;
    // Pixels &operator=(const Pixels &) = delete;

    /*!
     * \brief lock - lock any write operations on this `Pixels`
     * \return lock guard
     */
    // std::lock_guard<std::mutex> lock();

    // private:
    // std::mutex m_mtx;
};