MySQL 9.1.0
Source Code Documentation
plugin.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2017, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef MYSQLROUTER_PLUGIN_INFO_PLUGIN_INCLUDED
27#define MYSQLROUTER_PLUGIN_INFO_PLUGIN_INCLUDED
28
29#include <list>
30#include <ostream> // ostream
31#include <string>
32
33// we duplicate the Plugin struct here to have the history of the potential
34// changes but we still include this one for VERSION_ macros
35#include "mysql/harness/plugin.h"
36
37/** @struct Plugin_abi
38 *
39 * @brief The assumed and expected beginning of each version of Plugin struct
40 *
41 **/
42struct Plugin_abi {
43 uint32_t abi_version;
44};
45
46/** @struct Plugin_v1
47 *
48 * @brief Data fields of the first version of the Plugin struct.
49 * Whenever this changes, add a new struct (callded vX) here,
50 * respective constructor to Plugin_info and its handling
51 *
52 **/
53struct Plugin_v1 {
54 uint32_t abi_version;
55
56 const char *arch_descriptor;
57 const char *brief;
59
61 const char **requires_plugins;
62
64 const char **conflicts;
65
66 /* some function pointers follow; we are not really interested in those and we
67 don't want to be dependent on their types/arguments so we skip them here */
68};
69
70/** @class Plugin_info
71 *
72 * @brief Version independent plugin data storage, defines conversion from
73 * existing versions and enables writing the data as a JSON text.
74 *
75 **/
77 public:
78 /** @brief Constructor
79 *
80 * @param plugin constructor from v1 of Plugin struct
81 **/
82 explicit Plugin_info(const Plugin_v1 &plugin);
83
84 /** @brief prints the JSON representation of the Plugin_info object to the
85 * selected output stream
86 *
87 **/
88 friend std::ostream &operator<<(std::ostream &stream,
90
91 /** @brief converts ABI version integer to string representation
92 *
93 * @param ver integer representation to convert
94 **/
95 static std::string get_abi_version_str(uint32_t ver);
96
97 /** @brief converts plugin version integer to string representation
98 *
99 * @param ver integer representation to convert
100 **/
101 static std::string get_plugin_version_str(uint32_t ver);
102
103 private:
104 static void copy_to_list(std::list<std::string> &out_list,
105 const char **in_list, size_t in_list_size);
106
107 void print_as_json(std::ostream &out_stream) const;
108
109 uint32_t abi_version;
110
111 std::string arch_descriptor;
112 std::string brief;
114
115 std::list<std::string> requires_plugins;
116 std::list<std::string> conflicts;
117};
118
119#endif
Version independent plugin data storage, defines conversion from existing versions and enables writin...
Definition: plugin.h:76
std::string arch_descriptor
Definition: plugin.h:111
Plugin_info(const Plugin_v1 &plugin)
Constructor.
Definition: plugin.cc:38
friend std::ostream & operator<<(std::ostream &stream, const Plugin_info &plugin_info)
prints the JSON representation of the Plugin_info object to the selected output stream
Definition: plugin.cc:98
uint32_t abi_version
Definition: plugin.h:109
std::list< std::string > requires_plugins
Definition: plugin.h:115
std::list< std::string > conflicts
Definition: plugin.h:116
void print_as_json(std::ostream &out_stream) const
Definition: plugin.cc:64
static std::string get_abi_version_str(uint32_t ver)
converts ABI version integer to string representation
Definition: plugin.cc:48
static void copy_to_list(std::list< std::string > &out_list, const char **in_list, size_t in_list_size)
Definition: plugin.cc:59
std::string brief
Definition: plugin.h:112
uint32_t plugin_version
Definition: plugin.h:113
static std::string get_plugin_version_str(uint32_t ver)
converts plugin version integer to string representation
Definition: plugin.cc:53
static MYSQL_PLUGIN plugin_info
Definition: rewriter_plugin.cc:89
The assumed and expected beginning of each version of Plugin struct.
Definition: plugin.h:42
uint32_t abi_version
Definition: plugin.h:43
Data fields of the first version of the Plugin struct.
Definition: plugin.h:53
const char * arch_descriptor
Definition: plugin.h:56
const char ** conflicts
Definition: plugin.h:64
size_t requires_length
Definition: plugin.h:60
const char * brief
Definition: plugin.h:57
uint32_t plugin_version
Definition: plugin.h:58
size_t conflicts_length
Definition: plugin.h:63
uint32_t abi_version
Definition: plugin.h:54
const char ** requires_plugins
Definition: plugin.h:61