MySQL 8.0.37
Source Code Documentation
group_service_message.h
Go to the documentation of this file.
1/* Copyright (c) 2019, 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 GROUP_SERVICE_MESSAGE_H
25#define GROUP_SERVICE_MESSAGE_H
26
27#include <string>
28#include <vector>
29
33
35 public:
37 // This type should not be used anywhere.
39
40 // Length of the payload item: variable
42
43 // Length of the payload item: variable
45
46 // No valid type codes can appear after this one.
47 PIT_MAX = 3
48 };
49
50 /**
51 Group service message constructor.
52 */
54
55 /**
56 Group service message constructor for raw data.
57
58 @param[in] buf raw data
59 @param[in] len raw length
60 */
61 Group_service_message(const uchar *buf, size_t len);
62
63 /**
64 Group service message destructor
65 */
67
68 /**
69 Set data to message that will be transmitted to group members.
70 Memory ownership belongs to the message creator.
71
72 @param[in] data where the data will be read
73 @param[in] data_length the length of the data to write
74
75 @return returns false if succeeds, otherwise true is returned.
76 */
77 bool set_data(const uchar *data, const size_t data_length);
78
79 /**
80 Return data on message
81
82 @return content of the message
83 */
84 const uchar *get_data();
85
86 /**
87 Return the length of the data on message
88
89 @return length of the content of the message
90 */
91 size_t get_data_length();
92
93 /**
94 Set the tag that identifies the message
95
96 @param[in] tag tag name identify message
97
98 @return returns false if succeeds, otherwise tag is invalid and true
99 shall returned
100 */
101 bool set_tag(const char *tag);
102
103 /**
104 Return the tag that identifies the message
105
106 @return const string that identifies content of message
107 */
108 const std::string &get_tag() { return m_tag; }
109
110 /**
111 Return the length of the tag that identifies the message
112
113 @return length of the string that identifies content of message
114 */
115 size_t get_tag_length() { return m_tag.length(); }
116
117 protected:
118 /**
119 Encodes the group service message contents for transmission.
120
121 @param[out] buffer the message buffer to be written
122 */
123 void encode_payload(std::vector<unsigned char> *buffer) const override;
124
125 /**
126 Group service message decoding method
127
128 @param[in] buffer the received data
129 */
130 void decode_payload(const unsigned char *buffer,
131 const unsigned char *) override;
132
133 private:
134 /**The message identifier*/
135 std::string m_tag;
136 /**The message data*/
137 std::vector<uchar, Malloc_allocator<uchar>> m_data;
138 /**
139 A pointer to the message data, memory ownership belongs to the
140 message creator.
141 */
142 const unsigned char *m_data_pointer;
144};
145
146#endif /* GROUP_SERVICE_MESSAGE_H */
Definition: group_service_message.h:34
const std::string & get_tag()
Return the tag that identifies the message.
Definition: group_service_message.h:108
bool set_tag(const char *tag)
Set the tag that identifies the message.
Definition: group_service_message.cc:111
const unsigned char * m_data_pointer
A pointer to the message data, memory ownership belongs to the message creator.
Definition: group_service_message.h:142
size_t m_data_pointer_length
Definition: group_service_message.h:143
std::string m_tag
The message identifier.
Definition: group_service_message.h:135
enum_payload_item_type
Definition: group_service_message.h:36
@ PIT_MAX
Definition: group_service_message.h:47
@ PIT_DATA
Definition: group_service_message.h:44
@ PIT_UNKNOWN
Definition: group_service_message.h:38
@ PIT_TAG
Definition: group_service_message.h:41
void encode_payload(std::vector< unsigned char > *buffer) const override
Encodes the group service message contents for transmission.
Definition: group_service_message.cc:76
~Group_service_message() override
Group service message destructor.
std::vector< uchar, Malloc_allocator< uchar > > m_data
The message data.
Definition: group_service_message.h:137
size_t get_tag_length()
Return the length of the tag that identifies the message.
Definition: group_service_message.h:115
bool set_data(const uchar *data, const size_t data_length)
Set data to message that will be transmitted to group members.
Definition: group_service_message.cc:46
Group_service_message()
Group service message constructor.
Definition: group_service_message.cc:28
size_t get_data_length()
Return the length of the data on message.
Definition: group_service_message.cc:66
void decode_payload(const unsigned char *buffer, const unsigned char *) override
Group service message decoding method.
Definition: group_service_message.cc:94
const uchar * get_data()
Return data on message.
Definition: group_service_message.cc:56
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:64
unsigned char uchar
Definition: my_inttypes.h:52
Definition: buf0block_hint.cc:30
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:420