MySQL 9.6.0
Source Code Documentation
interval_set_interface.h
Go to the documentation of this file.
1// Copyright (c) 2024, 2025, Oracle and/or its affiliates.
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License, version 2.0,
5// as published by the Free Software Foundation.
6//
7// This program is designed to work with certain software (including
8// but not limited to OpenSSL) that is licensed under separate terms,
9// as designated in a particular file or component or in included license
10// documentation. The authors of MySQL hereby grant you an additional
11// permission to link the program and your derivative works with the
12// separately licensed software that they have either included with
13// the program or referenced in the documentation.
14//
15// This program is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License, version 2.0, for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with this program; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23
24#ifndef MYSQL_SETS_INTERVAL_SET_INTERFACE_H
25#define MYSQL_SETS_INTERVAL_SET_INTERFACE_H
26
27/// @file
28/// Experimental API header
29
30#include "mysql/ranges/disjoint_pairs.h" // Disjoint_pairs_interface
31#include "mysql/sets/boundary_set_meta.h" // Is_boundary_set
32#include "mysql/sets/interval_set_category.h" // Interval_set_category_tag
33#include "mysql/utils/return_status.h" // Return_status
34
35/// @addtogroup GroupLibsMysqlSets
36/// @{
37
38namespace mysql::sets::detail {
39
40/// Helper function object to construct intervals.
41///
42/// This is used as template argument for
43/// mysql::ranges::Disjoint_pairs_interface.
44template <Is_bounded_set_traits Set_traits_tp>
46 [[nodiscard]] static constexpr auto make_pair(
47 const typename Set_traits_tp::Element_t &start,
48 const typename Set_traits_tp::Element_t &exclusive_end) {
50 [[maybe_unused]] auto ret = interval.assign(start, exclusive_end);
52 return interval;
53 }
54};
55
56} // namespace mysql::sets::detail
57
58namespace mysql::sets {
59
60/// Helper concept to identify if a class can be the implementation for
61/// Interval_set_interface.
62template <class Test>
63concept Is_interval_set_implementation = requires(Test t, const Test ct) {
64 {
65 t.boundaries()
67 {
68 ct.boundaries()
70 };
71
72/// CRTP base class used to define an Interval set based on an implementation
73/// having the member function `boundaries()`.
74///
75/// This is for objects that own the underlying boundary set. If you need
76/// objects that do not own the underlying range - a *view* - use
77/// Interval_set_view.
78///
79/// @tparam Self_tp Class that implements a boundaries() function that returns a
80/// Boundary_set_tp.
81///
82/// @tparam Boundary_set_tp Type of boundary set.
83template <class Self_tp, class Boundary_set_tp>
86 Self_tp,
87 detail::Make_interval<typename Boundary_set_tp::Set_traits_t>> {
88 using Self_t = Self_tp;
89
90 public:
91 using Boundary_set_t = Boundary_set_tp;
93
95 using Set_traits_t = Boundary_set_t::Set_traits_t;
96 using Element_t = typename Set_traits_t::Element_t;
97
108
109 // Required by Disjoint_pairs_interface
110 [[nodiscard]] const auto &disjoint_pairs_source() const {
111 return self().boundaries();
112 }
113 [[nodiscard]] auto &disjoint_pairs_source() { return self().boundaries(); }
114
115 private:
116 [[nodiscard]] const auto &self() const {
117 return static_cast<const Self_t &>(*this);
118 }
119 [[nodiscard]] auto &self() { return static_cast<Self_t &>(*this); }
120}; // class Interval_set_interface
121
122/// View that provides and Interval set from an underlying Boundary set.
123///
124/// This a view, which does not own the underlying Boundary set. If you need to
125/// define a class that owns the underlying range, use Interval_set_interface.
126///
127/// @tparam Boundary_set_tp Underlying Boundary set.
128template <Is_boundary_set Boundary_set_tp>
130 : public Interval_set_interface<Interval_set_view<Boundary_set_tp>,
131 Boundary_set_tp>,
132 public std::ranges::view_base {
134
135 public:
136 using Boundary_set_t = Boundary_set_tp;
137
140
141 [[nodiscard]] const auto &boundaries() const {
142 return m_boundaries.reference();
143 }
144
145 private:
147}; // class Interval_set_view
148
149template <Is_boundary_set Boundary_set_t>
150[[nodiscard]] auto make_interval_set_view(const Boundary_set_t &boundary_set) {
151 return Interval_set_view<Boundary_set_t>(boundary_set);
152}
153
154} // namespace mysql::sets
155
156// addtogroup GroupLibsMysqlSets
157/// @}
158
159#endif // ifndef MYSQL_SETS_INTERVAL_SET_INTERFACE_H
Experimental API header.
Self_tp Self_t
Definition: collection_interface.h:91
CRTP base used to define classes that yield disjoint, adjacent pairs of elements from an even-length ...
Definition: disjoint_pairs.h:207
Iterator used by Disjoint_pairs_interface and Disjoint_pairs_view: this yields the disjoint,...
Definition: disjoint_pairs.h:78
Wrapper around an object that is the source for a view: the wrapped object is owned by this object if...
Definition: view_sources.h:101
const Source_t & reference() const
Return a reference to the stored object.
Definition: view_sources.h:130
CRTP base class used to define an Interval set based on an implementation having the member function ...
Definition: interval_set_interface.h:87
Boundary_set_tp Boundary_set_t
Definition: interval_set_interface.h:91
mysql::ranges::Range_const_iterator_type< Boundary_set_tp > Boundary_const_iterator_t
Definition: interval_set_interface.h:102
Boundary_set_t::Set_traits_t Set_traits_t
Definition: interval_set_interface.h:95
const auto & disjoint_pairs_source() const
Definition: interval_set_interface.h:110
auto & disjoint_pairs_source()
Definition: interval_set_interface.h:113
mysql::ranges::Range_iterator_type< Boundary_set_tp > Boundary_iterator_t
Definition: interval_set_interface.h:100
typename Set_traits_t::Element_t Element_t
Definition: interval_set_interface.h:96
View that provides and Interval set from an underlying Boundary set.
Definition: interval_set_interface.h:132
Interval_set_view(const Boundary_set_t &boundaries)
Definition: interval_set_interface.h:138
Boundary_set_tp Boundary_set_t
Definition: interval_set_interface.h:136
const Boundary_set_ref_t m_boundaries
Definition: interval_set_interface.h:146
const auto & boundaries() const
Definition: interval_set_interface.h:141
Holds the start boundary and endpoint boundary of an interval.
Definition: interval.h:178
True if Test is a reference to a boundary set.
Definition: boundary_set_meta.h:225
Helper concept to identify if a class can be the implementation for Interval_set_interface.
Definition: interval_set_interface.h:63
Experimental API header.
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:180
Experimental API header.
static int interval
Definition: mysqladmin.cc:72
std::remove_cvref_t< decltype(std::declval< const Range_t >().begin())> Range_const_iterator_type
Gives the const_iterator type, deduced from the begin() const member.
Definition: meta.h:47
std::remove_cvref_t< decltype(std::declval< Range_t >().begin())> Range_iterator_type
Gives the iterator type, deduced from the begin() member.
Definition: meta.h:42
Definition: aliases.h:97
Definition: gtid_set.h:183
auto make_interval_set_view(const Boundary_set_t &boundary_set)
Definition: interval_set_interface.h:150
@ ok
operation succeeded
Experimental API header.
Tag to identify a class as an Interval set.
Definition: interval_set_category.h:41
Helper function object to construct intervals.
Definition: interval_set_interface.h:45
static constexpr auto make_pair(const typename Set_traits_tp::Element_t &start, const typename Set_traits_tp::Element_t &exclusive_end)
Definition: interval_set_interface.h:46