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