IrregularityFile.h 2.35 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
/**
 * @file IrregularityFile.h
 * @author Matteo Spanio (dev2@audioinnova.com)
 * @brief Header file containing the IrregularityFile class
 * @version 1.0
 * @date 2023-05-14
 * 
 * @copyright Copyright (c) 2023
 * 
 */
Matteo's avatar
update  
Matteo committed
11
12
#ifndef IRREGULARITY_FILE_H
#define IRREGULARITY_FILE_H
Matteo's avatar
Matteo committed
13
14

#include <vector>
Matteo's avatar
update  
Matteo committed
15
16
#include <nlohmann/json.hpp>
#include "Irregularity.h"
Matteo's avatar
Matteo committed
17
#include <optional>
Matteo's avatar
update  
Matteo committed
18
19
20

using json = nlohmann::json;

Matteo's avatar
Matteo committed
21
22
23
24
25
/**
 * @class IrregularityFile
 * @brief An IrregularityFile is a collection of Irregularities detected on a tape.
 * 
 */
Matteo's avatar
Matteo committed
26
class IrregularityFile {
Matteo's avatar
update  
Matteo committed
27
public:
Matteo's avatar
Matteo committed
28
29
30
31
32
33
    /**
     * @brief Create an IrregularityFile object from a JSON object
     * 
     * @param j 
     * @return IrregularityFile 
     */
Matteo's avatar
update  
Matteo committed
34
    static IrregularityFile fromJSON(const json j);
Matteo's avatar
Matteo committed
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
    /**
     * @brief Convert the IrregularityFile to a JSON object
     * 
     * @return json 
     */
    json toJSON() const;
    IrregularityFile(std::optional<uint16_t> offset = std::nullopt);
    /**
     * @brief Copy constructor
     * 
     * @param rhs 
     */
    IrregularityFile(const IrregularityFile &rhs);
    ~IrregularityFile() {};
    /**
     * @brief Add an Irregularity to the IrregularityFile
     * 
     * @param irregularity 
     * @return IrregularityFile& 
     */
    IrregularityFile& add(std::unique_ptr<Irregularity> irregularity);
    /**
     * @brief Remove an Irregularity from the IrregularityFile
     * 
     * @param id 
     * @return IrregularityFile& 
     */
Matteo's avatar
update    
Matteo committed
62
    IrregularityFile& remove_by_id(const boost::uuids::uuid id);
Matteo's avatar
Matteo committed
63
64
65
66
67
    /**
     * @brief Sort the IrregularityFile by time_label
     * 
     * @return IrregularityFile& 
     */
Matteo's avatar
update    
Matteo committed
68
    IrregularityFile& sort();
Matteo's avatar
Matteo committed
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
    /**
     * @brief Get the offset object
     * 
     * @return std::optional<uint16_t> 
     */
    std::optional<uint16_t> get_offset() const;
    /**
     * @brief Get an iterator to the beginning of the IrregularityFile
     * 
     * @return std::vector<std::unique_ptr<Irregularity>>::iterator 
     */
    std::vector<std::unique_ptr<Irregularity>>::iterator begin();
    /**
     * @brief Get an iterator to the end of the IrregularityFile
     * 
     * @return std::vector<std::unique_ptr<Irregularity>>::iterator 
     */
    std::vector<std::unique_ptr<Irregularity>>::iterator end();

private:
    std::optional<uint16_t> offset_;
    std::vector<std::unique_ptr<Irregularity>> irregularities_;
Matteo's avatar
update  
Matteo committed
91
92
};

Matteo's avatar
Matteo committed
93
#endif // IRREGULARITY_FILE_HPP