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