MySQL 8.3.0
Source Code Documentation
gcs_view_identifier.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef GCS_VIEW_IDENTIFIER_INCLUDED
24#define GCS_VIEW_IDENTIFIER_INCLUDED
25
26#include <string>
27#include <typeinfo>
28
29/**
30 @class Gcs_view_identifier
31
32 This represents the identification of a certain view of a certain group in a
33 moment in time.
34
35 This identifier must increase monotonically and be unique,
36 in order to provide the notion of "happened before".
37
38 The get_representation() method is virtual, since each binding
39 implementation might provide its notion of view identifier. The only
40 mandatory property is that they should be comparable.
41*/
42
44 public:
50
51 /**
52 Returns a normalized representation of the DTO.
53
54 @return a const char * containing the normalized representation of the DTO
55 */
56
57 virtual const std::string &get_representation() const = 0;
58
59 /**
60 Returns a copy of this object. Since this object is an interface, this is
61 necessary to generate copies of it.
62
63 @return a copy of the current object
64 */
65
66 virtual Gcs_view_identifier *clone() const = 0;
67
68 /**
69 Redefinition of the operator less, to allow usage as key in maps.
70
71 @param[in] other the Gcs_view_identifier to compare to
72
73 @return true if the objects is less than @c other, according to the
74 internal representation of the object.
75 false otherwise.
76 */
77
78 bool operator<(const Gcs_view_identifier &other) const {
79 return typeid(*this) == typeid(other) && this->lessThan(other);
80 }
81
82 /**
83 Redefinition of the operator equals, to allow usage in sets.
84
85 @param[in] other the Gcs_view_identifier to compare to
86
87 @return true if the objects have the same internal representation.
88 false otherwise.
89 */
90
91 bool operator==(const Gcs_view_identifier &other) const {
92 return typeid(*this) == typeid(other) && this->equals(other);
93 }
94
95 bool operator!=(const Gcs_view_identifier &other) const {
96 return !(*this == other);
97 }
98
99 virtual ~Gcs_view_identifier() = default;
100
101 private:
102 virtual bool equals(const Gcs_view_identifier &other) const = 0;
103 virtual bool lessThan(const Gcs_view_identifier &other) const = 0;
104};
105
106#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:43
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:78
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:91
virtual ~Gcs_view_identifier()=default
bool operator!=(const Gcs_view_identifier &other) const
Definition: gcs_view_identifier.h:95