MySQL 9.0.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 <iostream>
30#include <list>
31
32// we duplicate the Plugin struct here to have the history of the potential
33// changes but we still include this one for VERSION_ macros
34#include "mysql/harness/plugin.h"
35
36/** @struct Plugin_abi
37 *
38 * @brief The assumed and expected beginning of each version of Plugin struct
39 *
40 **/
41struct Plugin_abi {
42 uint32_t abi_version;
43};
44
45/** @struct Plugin_v1
46 *
47 * @brief Data fields of the first version of the Plugin struct.
48 * Whenever this changes, add a new struct (callded vX) here,
49 * respective constructor to Plugin_info and its handling
50 *
51 **/
52struct Plugin_v1 {
53 uint32_t abi_version;
54
55 const char *arch_descriptor;
56 const char *brief;
58
60 const char **requires_plugins;
61
63 const char **conflicts;
64
65 /* some function pointers follow; we are not really interested in those and we
66 don't want to be dependent on their types/arguments so we skip them here */
67};
68
69/** @class Plugin_info
70 *
71 * @brief Version independent plugin data storage, defines conversion from
72 * existing versions and enables writing the data as a JSON text.
73 *
74 **/
76 public:
77 /** @brief Constructor
78 *
79 * @param plugin constructor from v1 of Plugin struct
80 **/
81 explicit Plugin_info(const Plugin_v1 &plugin);
82
83 /** @brief prints the JSON representation of the Plugin_info object to the
84 * selected output stream
85 *
86 **/
87 friend std::ostream &operator<<(std::ostream &stream,
89
90 /** @brief converts ABI version integer to string representation
91 *
92 * @param ver integer representation to convert
93 **/
94 static std::string get_abi_version_str(uint32_t ver);
95
96 /** @brief converts plugin version integer to string representation
97 *
98 * @param ver integer representation to convert
99 **/
100 static std::string get_plugin_version_str(uint32_t ver);
101
102 private:
103 static void copy_to_list(std::list<std::string> &out_list,
104 const char **in_list, size_t in_list_size);
105
106 void print_as_json(std::ostream &out_stream) const;
107
108 uint32_t abi_version;
109
110 std::string arch_descriptor;
111 std::string brief;
113
114 std::list<std::string> requires_plugins;
115 std::list<std::string> conflicts;
116};
117
118#endif
Version independent plugin data storage, defines conversion from existing versions and enables writin...
Definition: plugin.h:75
std::string arch_descriptor
Definition: plugin.h:110
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:108
std::list< std::string > requires_plugins
Definition: plugin.h:114
std::list< std::string > conflicts
Definition: plugin.h:115
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:111
uint32_t plugin_version
Definition: plugin.h:112
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:41
uint32_t abi_version
Definition: plugin.h:42
Data fields of the first version of the Plugin struct.
Definition: plugin.h:52
const char * arch_descriptor
Definition: plugin.h:55
const char ** conflicts
Definition: plugin.h:63
size_t requires_length
Definition: plugin.h:59
const char * brief
Definition: plugin.h:56
uint32_t plugin_version
Definition: plugin.h:57
size_t conflicts_length
Definition: plugin.h:62
uint32_t abi_version
Definition: plugin.h:53
const char ** requires_plugins
Definition: plugin.h:60