Skip to content

Commit 40cd34e

Browse files
c++: move ReportGuard main.cpp -> report.cpp
1 parent 5c19270 commit 40cd34e

3 files changed

Lines changed: 55 additions & 26 deletions

File tree

src/main.cpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ namespace libsemigroups {
6868
init_detail_cong_common(m);
6969
init_detail_todd_coxeter_impl(m);
7070
init_detail_knuth_bendix_impl(m);
71+
init_detail_report(m);
7172

7273
init_action(m);
7374
init_aho_corasick(m);
@@ -109,30 +110,5 @@ namespace libsemigroups {
109110
init_ukkonen(m);
110111
init_word_graph(m);
111112
init_words(m);
112-
113-
////////////////////////////////////////////////////////////////////////
114-
// Miscellaneous
115-
////////////////////////////////////////////////////////////////////////
116-
117-
py::class_<ReportGuard>(m,
118-
"ReportGuard",
119-
R"pbdoc(
120-
Objects of this type can be used to enable printing of some information
121-
during various of the computation in ``libsemigroups_pybind11``. Reporting
122-
is enable (or not) at construction time, and disable when the
123-
:py:class:`ReportGuard` goes out of scope.
124-
)pbdoc")
125-
.def(py::init<bool>(),
126-
py::arg("val") = true,
127-
R"pbdoc(
128-
Constructs a :py:class:`ReportGuard` with reporting enabled by
129-
default.
130-
131-
:param val:
132-
whether to report or not (default: ``True``).
133-
134-
:type val:
135-
bool
136-
)pbdoc");
137113
}
138114
} // namespace libsemigroups

src/main.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#ifndef SRC_MAIN_HPP_
2020
#define SRC_MAIN_HPP_
2121

22-
#include <variant>
22+
#include <variant> // for variant
2323

2424
#include <pybind11/pybind11.h>
2525

@@ -32,6 +32,7 @@ namespace libsemigroups {
3232
void init_detail_cong_common(py::module&);
3333
void init_detail_knuth_bendix_impl(py::module&);
3434
void init_detail_todd_coxeter_impl(py::module&);
35+
void init_detail_report(py::module&);
3536

3637
void init_action(py::module&);
3738
void init_aho_corasick(py::module&);

src/report.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// libsemigroups_pybind11
3+
// Copyright (C) 2025 James D. Mitchell
4+
//
5+
// This program is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// This program is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
//
18+
19+
// libsemigroups headers
20+
#include <libsemigroups/detail/report.hpp>
21+
22+
// pybind11....
23+
#include <pybind11/pybind11.h>
24+
25+
// libsemigroups_pybind11....
26+
#include "main.hpp" // for init_error
27+
28+
namespace libsemigroups {
29+
30+
void init_detail_report(py::module& m) {
31+
py::class_<ReportGuard>(m,
32+
"ReportGuard",
33+
R"pbdoc(
34+
Objects of this type can be used to enable printing of some information
35+
during various of the computation in ``libsemigroups_pybind11``. Reporting
36+
is enable (or not) at construction time, and disable when the
37+
:py:class:`ReportGuard` goes out of scope.
38+
)pbdoc")
39+
.def(py::init<bool>(),
40+
py::arg("val") = true,
41+
R"pbdoc(
42+
Constructs a :py:class:`ReportGuard` with reporting enabled by
43+
default.
44+
45+
:param val:
46+
whether to report or not (default: ``True``).
47+
48+
:type val:
49+
bool
50+
)pbdoc");
51+
}
52+
} // namespace libsemigroups

0 commit comments

Comments
 (0)