MySQL 8.0.39
Source Code Documentation
component_implementation.h File Reference

Specifies macros to define Components. More...

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...
 

Detailed Description

Specifies macros to define Components.

Macro Definition Documentation

◆ BEGIN_COMPONENT_METADATA

#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.

Parameters
nameName of component.

◆ BEGIN_COMPONENT_PROVIDES

#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.

Parameters
nameComponent name.

◆ BEGIN_COMPONENT_REQUIRES

#define BEGIN_COMPONENT_REQUIRES (   name)
Value:
static struct mysql_service_placeholder_ref_t __##name##_requires[] = { \
REQUIRES_SERVICE(registry),
#define REQUIRES_SERVICE_PLACEHOLDER(service)
Create a service placeholder, based on the service name.
Definition: component_implementation.h:280
case opt name
Definition: sslopt-case.h:33
Carries information on the specific Service requirement for some Component and a pointer to member wh...
Definition: dynamic_loader.h:243

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.

Parameters
nameName of component.

◆ BEGIN_COMPONENT_REQUIRES_WITHOUT_REGISTRY

#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.

Parameters
nameName of component.

◆ COMPONENT_ENTRY_FUNC

#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.

◆ COMPONENT_REF

#define COMPONENT_REF (   name)    mysql_component_##name

Defines a reference to the specified Component data info structure.

◆ DECLARE_COMPONENT

#define DECLARE_COMPONENT (   source_name,
  name 
)
Value:
mysql_component_t mysql_component_##source_name = { \
name, __##source_name##_provides, __##source_name##_requires, \
__##source_name##_metadata,
Carries information on the specific Component, all Service Implementations it provides,...
Definition: dynamic_loader.h:263

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.

Parameters
source_nameThe source name used in other macros.
nameName string with human readable name.

◆ DECLARE_LIBRARY_COMPONENTS

#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.

◆ DLL_EXPORT

#define DLL_EXPORT   extern "C" __attribute__((visibility("default")))

◆ DLL_IMPORT

#define DLL_IMPORT

◆ END_COMPONENT_METADATA

#define END_COMPONENT_METADATA ( )
Value:
{ NULL, NULL } \
}
#define NULL
Definition: types.h:55

A macro to end the last declaration started with the BEGIN_COMPONENT_METADATA.

◆ END_COMPONENT_PROVIDES

#define END_COMPONENT_PROVIDES ( )
Value:
{ NULL, NULL } \
}

A macro to end the last declaration started with the BEGIN_COMPONENT_PROVIDES.

◆ END_COMPONENT_REQUIRES

#define END_COMPONENT_REQUIRES ( )
Value:
{ NULL, NULL } \
}

A macro to end the last declaration started with the BEGIN_COMPONENT_REQUIRES.

◆ END_DECLARE_COMPONENT

#define END_DECLARE_COMPONENT ( )    }

A macro to end the last declaration of a Component.

◆ END_DECLARE_LIBRARY_COMPONENTS

#define END_DECLARE_LIBRARY_COMPONENTS
Value:
} \
; \
DLL_EXPORT mysql_component_t *list_components() { \
return library_components_list; \
}

A macro to end the last declaration started with the DECLARE_LIBRARY_COMPONENTS.

◆ METADATA

#define METADATA (   key,
  value 
)     { key, value }

Adds a Service requirement with a pointer to placeholder to the list of components.

Parameters
keyA string name of the metadata to add.
valueA string value of the metadata to add.

◆ PROVIDES_SERVICE

#define PROVIDES_SERVICE (   component,
  service 
)
Value:
{ \
#service "." #component, \
const_cast < void *> \
((const void *)&SERVICE_IMPLEMENTATION(component, service)) \
}

Declare a Service Implementation provided by a Component.

It assumes standard Service Implementation name to be referenced.

See also
SERVICE_IMPLEMENTATION
Parameters
componentComponent name.
serviceA Service name for which the Service Implementation will be added.

◆ REQUIRES_SERVICE

#define REQUIRES_SERVICE (   service)
Value:
{ \
#service, \
static_cast < void **> \
(static_cast <void *>(const_cast <mysql_service_##service##_t **>( \
&mysql_service_##service))) \
}

Adds a Service requirement with a pointer to placeholder to the list of components.

Parameters
serviceA referenced Service name.

◆ REQUIRES_SERVICE_AS

#define REQUIRES_SERVICE_AS (   service,
  name 
)
Value:
{ \
#service, \
static_cast < void **>(static_cast <void *>( \
const_cast <mysql_service_##service##_t **>(&name))) \
}

Adds a Service requirement with a pointer to placeholder to the list of components.

Use with REQUIRES_SERVICE_PLACEHOLDER_AS().

Parameters
serviceA referenced Service name.
nameService handle name.

◆ REQUIRES_SERVICE_PLACEHOLDER

#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();
  ...
}
Parameters
serviceA referenced Service name.

◆ REQUIRES_SERVICE_PLACEHOLDER_AS

#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().

Parameters
serviceA referenced Service name.
nameService handle name.

◆ SERVICE_PLACEHOLDER

#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)

Parameters
serviceA valid service name.