IrregularityFile.h 2.14 KB
Newer Older
Matteo's avatar
update  
Matteo committed
1
2
#ifndef IRREGULARITY_FILE_H
#define IRREGULARITY_FILE_H
Matteo's avatar
Matteo committed
3
4

#include <vector>
Matteo's avatar
update  
Matteo committed
5
6
#include <nlohmann/json.hpp>
#include "Irregularity.h"
Matteo's avatar
Matteo committed
7
#include <optional>
Matteo's avatar
update  
Matteo committed
8
9
10

using json = nlohmann::json;

Matteo's avatar
Matteo committed
11
12
13
14
15
/**
 * @class IrregularityFile
 * @brief An IrregularityFile is a collection of Irregularities detected on a tape.
 * 
 */
Matteo's avatar
Matteo committed
16
class IrregularityFile {
Matteo's avatar
update  
Matteo committed
17
public:
Matteo's avatar
Matteo committed
18
19
20
21
22
23
    /**
     * @brief Create an IrregularityFile object from a JSON object
     * 
     * @param j 
     * @return IrregularityFile 
     */
Matteo's avatar
update  
Matteo committed
24
    static IrregularityFile fromJSON(const json j);
Matteo's avatar
Matteo committed
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
    /**
     * @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
52
    IrregularityFile& remove_by_id(const boost::uuids::uuid id);
Matteo's avatar
Matteo committed
53
54
55
56
57
    /**
     * @brief Sort the IrregularityFile by time_label
     * 
     * @return IrregularityFile& 
     */
Matteo's avatar
update    
Matteo committed
58
    IrregularityFile& sort();
Matteo's avatar
Matteo committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
    /**
     * @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
81
82
};

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