MySQL
8.0.40
Source Code Documentation
service.h
Go to the documentation of this file.
1
/* Copyright (c) 2016, 2024, Oracle and/or its affiliates.
2
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License, version 2.0,
5
as published by the Free Software Foundation.
6
7
This program is designed to work with certain software (including
8
but not limited to OpenSSL) that is licensed under separate terms,
9
as designated in a particular file or component or in included license
10
documentation. The authors of MySQL hereby grant you an additional
11
permission to link the program and your derivative works with the
12
separately licensed software that they have either included with
13
the program or referenced in the documentation.
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, version 2.0, 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
#ifndef SERVICE_H
25
#define SERVICE_H
26
27
/**
28
Specific type for the service status return values.
29
30
0 is false, non-zero is true. Corresponds to C++ bool.
31
32
@sa DEFINE_BOOL_METHOD, DECLARE_BOOL_METHOD
33
*/
34
typedef
int
mysql_service_status_t
;
35
36
/**
37
@page PAGE_COMPONENTS_SERVICE A Service and a Service Implementation
38
39
The Service is basic concept of the Components subsystem. A Service is a
40
named, well-defined stateless interface to one functionality, expressed as a
41
list of pointers to a specific methods. The service name will consist of ASCII
42
symbols excluding the dot ('.') symbol. Each Service will be accompanied with
43
a (part of a) header file that defines the Service allowing other Components
44
to consume it. Each Service should work only on basic C types and structures
45
of these types to prevent problems with not fully-defined C++ objects ABI. The
46
Service is a default way to operate inside the Components subsystem as a mean
47
to show that one is interested only on functionality interface, not its exact
48
implementation. The Services are not versioned - any change to interface must
49
require Service being copied to one with different name before applying
50
changes. The Services by itself do not carry any state, all methods are
51
stateless. This does not prevent one from having some state-carrying objects
52
created and returned as handles to them. Such concept is shown for example in
53
create(), get() and release() methods of the registry_query Service. This
54
concept relies on implementation of generator of the Opaque pointers with
55
d-pointer described here: https://en.wikipedia.org/wiki/Opaque_pointer .
56
57
For any specific Service a Service Implementation is defined as a structure
58
of the Service type filled with pointers to methods of specified
59
implementation. The name of the Service Implementation is a name of the
60
Service and the implementation related name separated with a dot. In most
61
cases the implementation related name should be the Component name in which it
62
is being defined. Each Service can have several Service Implementations.
63
64
@file include/mysql/components/service.h
65
*/
66
67
/**
68
Generates the standard Service type name. It does not have const specifier,
69
it should be used only when really necessary.
70
*/
71
#define SERVICE_TYPE_NO_CONST(name) mysql_service_##name##_t
72
73
/**
74
Generates the standard Service type name.
75
*/
76
#define SERVICE_TYPE(name) const SERVICE_TYPE_NO_CONST(name)
77
78
/**
79
Declares a new Service. It creates a structure for pointers to Service
80
methods. A list of methods defined using DECLARE_METHOD and
81
DECLARE_BOOL_METHOD macros must follow this macro, with a closing
82
END_SERVICE_DEFINITION macro usage.
83
84
@param name Service name, must be a valid C name.
85
*/
86
#define BEGIN_SERVICE_DEFINITION(name) typedef struct s_mysql_##name {
87
/**
88
A macro to end the last Service definition started with the
89
BEGIN_SERVICE_DEFINITION macro.
90
*/
91
#define END_SERVICE_DEFINITION(name) \
92
} \
93
SERVICE_TYPE_NO_CONST(name);
94
/**
95
Declares a method as a part of the Service definition. To be used within the
96
SERVICE_DEFINITION macro.
97
98
@param retval Type of the return value for the method declaration. Should be a
99
simple type or structure, not a C++ object with undefined ABI.
100
@param name Name of the method, must be a valid C name.
101
@param args The list of arguments of the method taken in parentheses.
102
*/
103
#define DECLARE_METHOD(retval, name, args) retval(*name) args
104
105
/**
106
Declares a method that returns bool as a part of the Service definition. To be
107
used within the SERVICE_DEFINITION macro.
108
109
@param name Name of the method, must be a valid C name.
110
@param args The list of arguments of the method taken in parentheses.
111
*/
112
#define DECLARE_BOOL_METHOD(name, args) \
113
DECLARE_METHOD(mysql_service_status_t, name, args)
114
115
/**
116
Defines an object type that is meant for carrying handles to the
117
implementation-specific objects used in the Service interface, but without
118
their structure exposed, keeping it as an abstraction. This follows a Opaque
119
Pointer design pattern, see more: https://en.wikipedia.org/wiki/Opaque_pointer
120
If you would like to have a C++ RAII class to manage the resource with
121
additional methods to call raw service calls, please create your class
122
{handle_name} instead of following macro. Please make sure it does not use any
123
virtual methods to keep binary compatibility, and try use only one member, the
124
d-pointer to hide all implementation details and keep headers unmodified from
125
the point of publishing it.
126
127
@param name Handle name, must be a valid C name.
128
*/
129
#define DEFINE_SERVICE_HANDLE(name) typedef struct name##_imp *name
130
131
#endif
/* SERVICE_H */
mysql_service_status_t
int mysql_service_status_t
Specific type for the service status return values.
Definition:
service.h:34
include
mysql
components
service.h
Generated by
1.9.2