LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
treebank_file_report.hpp
1/*********************************************************************
2 *
3 * Linear Arrangement Library - A library that implements a collection
4 * algorithms for linear arrangments of graphs.
5 *
6 * Copyright (C) 2019 - 2024
7 *
8 * This file is part of Linear Arrangement Library. The full code is available
9 * at:
10 * https://github.com/LAL-project/linear-arrangement-library.git
11 *
12 * Linear Arrangement Library is free software: you can redistribute it
13 * and/or modify it under the terms of the GNU Affero General Public License
14 * as published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * Linear Arrangement Library is distributed in the hope that it will be
18 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Affero General Public License for more details.
21 *
22 * You should have received a copy of the GNU Affero General Public License
23 * along with Linear Arrangement Library. If not, see <http://www.gnu.org/licenses/>.
24 *
25 * Contact:
26 *
27 * LluĂ­s Alemany Puig (lluis.alemany.puig@upc.edu)
28 * LQMC (Quantitative, Mathematical, and Computational Linguisitcs)
29 * CQL (Complexity and Quantitative Linguistics Lab)
30 * Jordi Girona St 1-3, Campus Nord UPC, 08034 Barcelona. CATALONIA, SPAIN
31 * Webpage: https://cqllab.upc.edu/people/lalemany/
32 *
33 * Ramon Ferrer i Cancho (rferrericancho@cs.upc.edu)
34 * LQMC (Quantitative, Mathematical, and Computational Linguisitcs)
35 * CQL (Complexity and Quantitative Linguistics Lab)
36 * Office 220, Omega building
37 * Jordi Girona St 1-3, Campus Nord UPC, 08034 Barcelona. CATALONIA, SPAIN
38 * Webpage: https://cqllab.upc.edu/people/rferrericancho/
39 *
40 ********************************************************************/
41
42#pragma once
43
44// C++ includes
45#if defined DEBUG
46#include <cassert>
47#endif
48#include <cstdint>
49#include <vector>
50
51// lal includes
52#include <lal/io/head_vector_error.hpp>
53#include <lal/io/treebank_file_error.hpp>
54
55namespace lal {
56namespace io {
57
70public:
71
79 typedef std::vector<std::pair<uint64_t, head_vector_error>> error_list;
80
81public:
83 treebank_file_report() noexcept = default;
85 treebank_file_report(const treebank_file_report&) noexcept = default;
86
89
92 m_treebank_error = err;
93 }
96 m_treebank_error = std::move(err);
97 }
98
100 treebank_file_report(const uint64_t line_number, const head_vector_error& err) noexcept {
101 m_hv_errors.emplace_back(line_number, err);
102 }
104 treebank_file_report(const uint64_t line_number, head_vector_error&& err) noexcept {
105 m_hv_errors.emplace_back(line_number, std::move(err));
106 }
107
109 ~treebank_file_report() noexcept = default;
110
111 /* ASSIGNMENT OPERATORS */
112
114 treebank_file_report& operator= (const treebank_file_report&) noexcept = default;
116 treebank_file_report& operator= (treebank_file_report&&) noexcept = default;
117
118 /* MODIFIERS */
119
125 void add_error(const uint64_t line_number, const head_vector_error& err) noexcept {
126 m_hv_errors.emplace_back(line_number, err);
127 }
133 void add_error(const uint64_t line_number, head_vector_error&& err) noexcept {
134 m_hv_errors.emplace_back(line_number, std::move(err));
135 }
136
138 void set_treebank_error(const treebank_file_error& err) noexcept {
139 m_treebank_error = err;
140 }
143 m_treebank_error = std::move(err);
144 }
145
146 /* GETTERS */
147
149 [[nodiscard]] std::size_t get_num_errors() const noexcept {
150 return m_treebank_error.is_error() + m_hv_errors.size();
151 }
152
158 [[nodiscard]] const error_list& get_head_vector_errors() const noexcept
159 { return m_hv_errors; }
160
166 [[nodiscard]] const treebank_file_error& get_treebank_error() const noexcept
167 { return m_treebank_error; }
168
169private:
172
175};
176
177} // -- namespace io
178} // -- namespace lal
Head vector error report class.
Definition head_vector_error.hpp:64
Treebank file error report class.
Definition treebank_file_error.hpp:64
bool is_error() const noexcept
Returns whether or not this is an actual error.
Definition treebank_file_error.hpp:131
Report on a treebank file.
Definition treebank_file_report.hpp:69
void add_error(const uint64_t line_number, const head_vector_error &err) noexcept
Adds an error to the list of errors.
Definition treebank_file_report.hpp:125
treebank_file_error m_treebank_error
A treebank error. Set if the file could not be opened or it does not exist.
Definition treebank_file_report.hpp:174
std::size_t get_num_errors() const noexcept
Returns the number of errors in this report.
Definition treebank_file_report.hpp:149
const error_list & get_head_vector_errors() const noexcept
Returns the list of errors in the head vectors.
Definition treebank_file_report.hpp:158
treebank_file_report() noexcept=default
Default constructor.
treebank_file_report(const uint64_t line_number, head_vector_error &&err) noexcept
Constructor with a single head vector error.
Definition treebank_file_report.hpp:104
treebank_file_report(const uint64_t line_number, const head_vector_error &err) noexcept
Constructor with a single head vector error.
Definition treebank_file_report.hpp:100
~treebank_file_report() noexcept=default
Default destructor.
void add_error(const uint64_t line_number, head_vector_error &&err) noexcept
Adds an error to the list of errors.
Definition treebank_file_report.hpp:133
void set_treebank_error(treebank_file_error &&err) noexcept
Sets the treebank error m_treebank_error.
Definition treebank_file_report.hpp:142
std::vector< std::pair< uint64_t, head_vector_error > > error_list
The error list for a trebank file.
Definition treebank_file_report.hpp:79
void set_treebank_error(const treebank_file_error &err) noexcept
Sets the treebank error m_treebank_error.
Definition treebank_file_report.hpp:138
const treebank_file_error & get_treebank_error() const noexcept
Returns the only treebank error concerning the file (if any).
Definition treebank_file_report.hpp:166
treebank_file_report(treebank_file_error &&err) noexcept
Constructor with a single head vector error.
Definition treebank_file_report.hpp:95
error_list m_hv_errors
The error in the head vector and the line number where it happened.
Definition treebank_file_report.hpp:171
Main namespace of the library.
Definition basic_types.hpp:48