MySQL 8.0.40
Source Code Documentation
|
Specifies macros to define Components. More...
#include <mysql/components/services/dynamic_loader.h>
#include <mysql/components/services/registry.h>
#include <cstddef>
#include "service_implementation.h"
Go to the source code of this file.
Macros | |
#define | DECLARE_COMPONENT(source_name, name) |
Declares a component. More... | |
#define | END_DECLARE_COMPONENT() } |
A macro to end the last declaration of a Component. More... | |
#define | BEGIN_COMPONENT_PROVIDES(name) static struct mysql_service_ref_t __##name##_provides[] = { |
Creates a service implementation list that are provided by specified component. More... | |
#define | PROVIDES_SERVICE(component, service) |
Declare a Service Implementation provided by a Component. More... | |
#define | END_COMPONENT_PROVIDES() |
A macro to end the last declaration started with the BEGIN_COMPONENT_PROVIDES. More... | |
#define | BEGIN_COMPONENT_REQUIRES_WITHOUT_REGISTRY(name) static struct mysql_service_placeholder_ref_t __##name##_requires[] = { |
A macro to specify requirements of the component. More... | |
#define | BEGIN_COMPONENT_REQUIRES(name) |
A macro to specify requirements of the component. More... | |
#define | REQUIRES_SERVICE_PLACEHOLDER(service) SERVICE_TYPE(service) * mysql_service_##service |
Create a service placeholder, based on the service name. More... | |
#define | REQUIRES_SERVICE_PLACEHOLDER_AS(service, name) SERVICE_TYPE(service) * name |
Create a service placeholder, with an arbitrary name. More... | |
#define | REQUIRES_SERVICE(service) |
Adds a Service requirement with a pointer to placeholder to the list of components. More... | |
#define | REQUIRES_SERVICE_AS(service, name) |
Adds a Service requirement with a pointer to placeholder to the list of components. More... | |
#define | SERVICE_PLACEHOLDER(service) mysql_service_##service |
Use this macro to reference the service placeholder as defined by the REQUIRES_SERVICE_PLACEHOLDER macro. More... | |
#define | END_COMPONENT_REQUIRES() |
A macro to end the last declaration started with the BEGIN_COMPONENT_REQUIRES. More... | |
#define | BEGIN_COMPONENT_METADATA(name) static struct mysql_metadata_ref_t __##name##_metadata[] = { |
A macro to specify metadata of the component. More... | |
#define | METADATA(key, value) { key, value } |
Adds a Service requirement with a pointer to placeholder to the list of components. More... | |
#define | END_COMPONENT_METADATA() |
A macro to end the last declaration started with the BEGIN_COMPONENT_METADATA. More... | |
#define | DLL_EXPORT extern "C" __attribute__((visibility("default"))) |
#define | DLL_IMPORT |
#define | DECLARE_LIBRARY_COMPONENTS mysql_component_t *library_components_list = { |
Creates a list of component implementations included in this dynamic library. More... | |
#define | END_DECLARE_LIBRARY_COMPONENTS |
A macro to end the last declaration started with the DECLARE_LIBRARY_COMPONENTS. More... | |
#define | COMPONENT_REF(name) mysql_component_##name |
Defines a reference to the specified Component data info structure. More... | |
#define | COMPONENT_ENTRY_FUNC "list_components" |
This is the component module entry function, used to get the component's structure to register the required services. More... | |
Specifies macros to define Components.
#define BEGIN_COMPONENT_METADATA | ( | name | ) | static struct mysql_metadata_ref_t __##name##_metadata[] = { |
A macro to specify metadata of the component.
Creates a list of metadata. Only a series of METADATA macros are expected to be used after this macro and before the END_COMPONENT_METADATA counterpart.
name | Name of component. |
#define BEGIN_COMPONENT_PROVIDES | ( | name | ) | static struct mysql_service_ref_t __##name##_provides[] = { |
Creates a service implementation list that are provided by specified component.
Only a series of PROVIDES_SERVICE and PROVIDES_CUSTOM_SERVICE macros are expected to be used after this macro and before the END_COMPONENT_PROVIDES counterpart.
name | Component name. |
#define BEGIN_COMPONENT_REQUIRES | ( | name | ) |
A macro to specify requirements of the component.
Creates a placeholder for the Registry service and structure with a list for requirements and pointers to their placeholders, adding the Registry service as first element.
name | Name of component. |
#define BEGIN_COMPONENT_REQUIRES_WITHOUT_REGISTRY | ( | name | ) | static struct mysql_service_placeholder_ref_t __##name##_requires[] = { |
A macro to specify requirements of the component.
Creates a structure with a list for requirements and pointers to their placeholders.
name | Name of component. |
#define COMPONENT_ENTRY_FUNC "list_components" |
This is the component module entry function, used to get the component's structure to register the required services.
Defines a reference to the specified Component data info structure.
#define DECLARE_COMPONENT | ( | source_name, | |
name | |||
) |
Declares a component.
For specified name following macros must be executed earlier: BEGIN_COMPONENT_PROVIDES, BEGIN_COMPONENT_REQUIRES and BEGIN_COMPONENT_METADATA. It fills mysql_component_t structure with all of the component data. The info object will be named mysql_component_{source_name}. After this macro it is required to specify comma-separated pointers to initialize and deinitialize methods for components to be used during loading and unloading of component.
source_name | The source name used in other macros. |
name | Name string with human readable name. |
#define DECLARE_LIBRARY_COMPONENTS mysql_component_t *library_components_list = { |
Creates a list of component implementations included in this dynamic library.
It can be used only once in whole library. It defines an entry point method for library to be used with the Dynamic Loader. A list of pointers to Component structures is required after this macro up to the usage of the END_DECLARE_LIBRARY_COMPONENTS macro. Current implementation of the Dynamic Loader supports only one Component being specified in the library.
#define DLL_EXPORT extern "C" __attribute__((visibility("default"))) |
#define DLL_IMPORT |
#define END_COMPONENT_METADATA | ( | ) |
#define END_COMPONENT_PROVIDES | ( | ) |
#define END_COMPONENT_REQUIRES | ( | ) |
#define END_DECLARE_COMPONENT | ( | ) | } |
A macro to end the last declaration of a Component.
#define END_DECLARE_LIBRARY_COMPONENTS |
A macro to end the last declaration started with the DECLARE_LIBRARY_COMPONENTS.
Adds a Service requirement with a pointer to placeholder to the list of components.
key | A string name of the metadata to add. |
value | A string value of the metadata to add. |
#define PROVIDES_SERVICE | ( | component, | |
service | |||
) |
Declare a Service Implementation provided by a Component.
It assumes standard Service Implementation name to be referenced.
component | Component name. |
service | A Service name for which the Service Implementation will be added. |
#define REQUIRES_SERVICE | ( | service | ) |
Adds a Service requirement with a pointer to placeholder to the list of components.
service | A referenced Service name. |
#define REQUIRES_SERVICE_AS | ( | service, | |
name | |||
) |
Adds a Service requirement with a pointer to placeholder to the list of components.
Use with REQUIRES_SERVICE_PLACEHOLDER_AS().
service | A referenced Service name. |
name | Service handle name. |
#define REQUIRES_SERVICE_PLACEHOLDER | ( | service | ) | SERVICE_TYPE(service) * mysql_service_##service |
Create a service placeholder, based on the service name.
A service placeholder is a pointer to the service. It is named mysql_service_{service name}.
This pointer is initialized by the framework upon loading a component, based on the component dependencies declared by REQUIRES_SERVICE.
When defining a service 'foo', in the header file for the service, a service placeholder is declared as follows:
extern REQUIRES_SERVICE_PLACEHOLDER(foo);
When implementing a component 'bar', which requires the service 'foo', the definition of the component 'bar' should contain the following:
REQUIRES_SERVICE_PLACEHOLDER(foo); BEGIN_COMPONENT_REQUIRES(bar) REQUIRES_SERVICE(foo), ... END_COMPONENT_REQUIRES();
The code in the implementation of service 'bar' can use the service placeholder pointer to invoke apis in service foo:
mysql_service_foo->some_api();
Similarly to use a service in another service within the same component. Call the implementation of the service directly in the other service since both services belong to the same component. Suppose mysql_bar_imp and mysql_foo_imp services belongs to the same component. And if foo service is required in bar service then use below method.
mysql_bar_imp::bar_api() { ... mysql_foo_imp::foo_api(); ... }
service | A referenced Service name. |
#define REQUIRES_SERVICE_PLACEHOLDER_AS | ( | service, | |
name | |||
) | SERVICE_TYPE(service) * name |
Create a service placeholder, with an arbitrary name.
Identical to REQUIRES_SERVICE_PLACEHOLDER(), except that the service handle name is provided by the caller, instead of being derived from the service type.
Use with REQUIRES_SERVICE_AS().
service | A referenced Service name. |
name | Service handle name. |
#define SERVICE_PLACEHOLDER | ( | service | ) | mysql_service_##service |
Use this macro to reference the service placeholder as defined by the REQUIRES_SERVICE_PLACEHOLDER macro.
Example: REQUIRES_SERVICE_PLACEHOLDER(foo);
...
code() { .... SERVICE_PLACEHOLDER(foo)->bar(1); ... }
BEGIN_COMPONENT_REQUIRES(comp) REQUIRES_SERVICE(foo); END_COMPONENT_REQUIRES(comp)
service | A valid service name. |