MySQL 8.0.40
Source Code Documentation
transaction_message.h
Go to the documentation of this file.
1/* Copyright (c) 2013, 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 TRANSACTION_MESSAGE_INCLUDED
25#define TRANSACTION_MESSAGE_INCLUDED
26
28
29/*
30 @class Transaction_message
31 Class to convey the serialized contents of the TCLE
32 */
34 public:
36 // This type should not be used anywhere.
38
39 // Length of the payload item: variable
41
42 // No valid type codes can appear after this one.
43 PIT_MAX = 2
44 };
45
46 /**
47 Constructor
48
49 @param[in] payload_capacity The transaction data size
50 */
51 Transaction_message(uint64_t payload_capacity);
52 ~Transaction_message() override;
53
54 /**
55 Overrides Basic_ostream::write().
56 Transaction_message is a Basic_ostream, which appends
57 data into the a Gcs_message_data.
58
59 @param[in] buffer where the data will be read
60 @param[in] length the length of the data to write
61
62 @return returns false if succeeds, otherwise true is returned.
63 */
64 bool write(const unsigned char *buffer, my_off_t length) override;
65
66 /**
67 Length of the message.
68
69 @return message length
70 */
71 uint64_t length() override;
72
73 /**
74 Get the Gcs_message_data object, which contains the serialized
75 transaction data.
76 The internal Gcs_message_data is nullified, to avoid further usage
77 of this Transaction object and the caller receives a pointer to the
78 previously internal Gcs_message_data, which whom it is now responsible.
79
80 @return the serialized transaction data in a Gcs_message_data object
81 */
83
84 protected:
85 /*
86 Implementation of the template methods
87 */
88 void encode_payload(std::vector<unsigned char> *buffer) const override;
89 void decode_payload(const unsigned char *buffer,
90 const unsigned char *) override;
91
92 private:
94};
95
96#endif /* TRANSACTION_MESSAGE_INCLUDED */
This class serves as data container for information flowing in the GCS ecosystem.
Definition: gcs_message.h:48
Definition: transaction_message_interface.h:41
Definition: transaction_message.h:33
Gcs_message_data * m_gcs_message_data
Definition: transaction_message.h:93
uint64_t length() override
Length of the message.
Definition: transaction_message.cc:63
void encode_payload(std::vector< unsigned char > *buffer) const override
Encodes the contents of this instance payload into the buffer.
Definition: transaction_message.cc:79
bool write(const unsigned char *buffer, my_off_t length) override
Overrides Basic_ostream::write().
Definition: transaction_message.cc:54
Gcs_message_data * get_message_data_and_reset() override
Get the Gcs_message_data object, which contains the serialized transaction data.
Definition: transaction_message.cc:72
enum_payload_item_type
Definition: transaction_message.h:35
@ PIT_MAX
Definition: transaction_message.h:43
@ PIT_UNKNOWN
Definition: transaction_message.h:37
@ PIT_TRANSACTION_DATA
Definition: transaction_message.h:40
void decode_payload(const unsigned char *buffer, const unsigned char *) override
Decodes the contents of the buffer and sets the payload field values according to the values decoded.
Definition: transaction_message.cc:84
Transaction_message(uint64_t payload_capacity)
Constructor.
Definition: transaction_message.cc:28
~Transaction_message() override
Definition: transaction_message.cc:49
ulonglong my_off_t
Definition: my_inttypes.h:72
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:420