Irregularity.hpp 2.5 KB
Newer Older
Matteo Spanio's avatar
update  
Matteo Spanio committed
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
 * @file Irregularity.hpp
 * @author Matteo Spanio (dev2@audioinnova.com)
 * @brief Header file containing the Irregularity class
 * @version 1.0
 * @date 2023-05-14
 *
 * @copyright Copyright (c) 2023
 *
 */
#ifndef IRREGULARITY_H
#define IRREGULARITY_H
#include <boost/lexical_cast.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <nlohmann/json.hpp>

#include "enums.hpp"

using std::string;
using json = nlohmann::json;

/**
 * @class Irregularity
 * @brief an irregularity of the tape detected by the system
 *
 */
class Irregularity {
   private:
    boost::uuids::uuid id;
    Source source;
    string time_label;
    std::optional<IrregularityType> type;
    std::optional<string> image_URI;
    std::optional<string> audio_URI;

   public:
    Irregularity(const Irregularity& other);
    Irregularity(Irregularity&& other) noexcept;
    Irregularity(Source source, string time_label);
    Irregularity(Source source, string time_label, IrregularityType type);
    ~Irregularity() = default;
    /**
     * @brief Convert the Irregularity to a JSON object
     *
     * @return json
     */
    json to_JSON() const;
    /**
     * @brief Create an Irregularity object from a JSON object
     *
     * @param j the JSON object
     * @return Irregularity
     */
    static Irregularity from_JSON(const json& j);
    /**
     * @brief Get the source object
     *
     * @return Source
     */
    Source get_source() const;
    /**
     * @brief Get the time label object
     *
     * @return string
     */
    string get_time_label() const;
    /**
     * @brief Get the type object
     *
     * @return IrregularityType
     */
    std::optional<IrregularityType> get_type() const;
    /**
     * @brief Get the id object
     *
     * @return boost::uuids::uuid
     */
    boost::uuids::uuid get_id() const;
    /**
     * @brief Get the audio URI object
     *
     * @return std::optional<string>
     */
    std::optional<string> get_audio_URI() const;
    /**
     * @brief Get the image URI object
     *
     * @return std::optional<string>
     */
    std::optional<string> get_image_URI() const;
    /**
     * @brief Set the audio URI object
     *
     * @param audio_URI
     * @return Irregularity&
     */
    Irregularity& set_audio_URI(string audio_URI);
    /**
     * @brief Set the image URI object
     *
     * @param image_URI
     * @return Irregularity&
     */
    Irregularity& set_image_URI(string image_URI);
};

#endif  // IRREGULARITY_H