MySQL 8.0.39
Source Code Documentation
gcs_view_identifier.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 2024, 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 GCS_VIEW_IDENTIFIER_INCLUDED
25#define GCS_VIEW_IDENTIFIER_INCLUDED
26
27#include <string>
28#include <typeinfo>
29
30/**
31 @class Gcs_view_identifier
32
33 This represents the identification of a certain view of a certain group in a
34 moment in time.
35
36 This identifier must increase monotonically and be unique,
37 in order to provide the notion of "happened before".
38
39 The get_representation() method is virtual, since each binding
40 implementation might provide its notion of view identifier. The only
41 mandatory property is that they should be comparable.
42*/
43
45 public:
51
52 /**
53 Returns a normalized representation of the DTO.
54
55 @return a const char * containing the normalized representation of the DTO
56 */
57
58 virtual const std::string &get_representation() const = 0;
59
60 /**
61 Returns a copy of this object. Since this object is an interface, this is
62 necessary to generate copies of it.
63
64 @return a copy of the current object
65 */
66
67 virtual Gcs_view_identifier *clone() const = 0;
68
69 /**
70 Redefinition of the operator less, to allow usage as key in maps.
71
72 @param[in] other the Gcs_view_identifier to compare to
73
74 @return true if the objects is less than @c other, according to the
75 internal representation of the object.
76 false otherwise.
77 */
78
79 bool operator<(const Gcs_view_identifier &other) const {
80 return typeid(*this) == typeid(other) && this->lessThan(other);
81 }
82
83 /**
84 Redefinition of the operator equals, to allow usage in sets.
85
86 @param[in] other the Gcs_view_identifier to compare to
87
88 @return true if the objects have the same internal representation.
89 false otherwise.
90 */
91
92 bool operator==(const Gcs_view_identifier &other) const {
93 return typeid(*this) == typeid(other) && this->equals(other);
94 }
95
96 bool operator!=(const Gcs_view_identifier &other) const {
97 return !(*this == other);
98 }
99
100 virtual ~Gcs_view_identifier() = default;
101
102 private:
103 virtual bool equals(const Gcs_view_identifier &other) const = 0;
104 virtual bool lessThan(const Gcs_view_identifier &other) const = 0;
105};
106
107#endif // GCS_VIEW_IDENTIFIER_INCLUDED
This represents the identification of a certain view of a certain group in a moment in time.
Definition: gcs_view_identifier.h:44
Gcs_view_identifier & operator=(const Gcs_view_identifier &)=default
virtual Gcs_view_identifier * clone() const =0
Returns a copy of this object.
Gcs_view_identifier(const Gcs_view_identifier &)=default
virtual bool equals(const Gcs_view_identifier &other) const =0
virtual const std::string & get_representation() const =0
Returns a normalized representation of the DTO.
Gcs_view_identifier(Gcs_view_identifier &&)=default
bool operator<(const Gcs_view_identifier &other) const
Redefinition of the operator less, to allow usage as key in maps.
Definition: gcs_view_identifier.h:79
Gcs_view_identifier()=default
Gcs_view_identifier & operator=(Gcs_view_identifier &&)=default
virtual bool lessThan(const Gcs_view_identifier &other) const =0
bool operator==(const Gcs_view_identifier &other) const
Redefinition of the operator equals, to allow usage in sets.
Definition: gcs_view_identifier.h:92
virtual ~Gcs_view_identifier()=default
bool operator!=(const Gcs_view_identifier &other) const
Definition: gcs_view_identifier.h:96