1 /* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
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 also distributed 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 included with MySQL.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License, version 2.0, for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
22 
23 #ifndef SERVICE_IMPLEMENTATION_H
24 #define SERVICE_IMPLEMENTATION_H
25 
26 #include "service.h"
27 
28 /**
29   @file include/mysql/components/service_implementation.h
30   Specifies macros to define Service Implementations.
31 */
32 
33 /**
34   Reference to the name of the service implementation variable
35 
36   @ref BEGIN_SERVICE_IMPLEMENTATION defines a local variable of
37   the structure type for the service (see @ref SERVICE_TYPE).
38   The variable is then used by the @ref PROVIDES_SERVICE macro to
39   construct the list of service provided by the component.
40   This macro allows one to use @ref BEGIN_SERVICE_IMPLEMENTATION ,
41   @ref DEFINE_METHOD and @ref END_SERVICE_IMPLEMENTATION macros to build
42   a service defintion structure and variable to be used outside of the
43   component definition context.
44 
45   @param component Name of the implementation of the service.
46     Usually a component name.
47   @param service  Name of the service to create the implementation for.
48 
49 */
50 #define SERVICE_IMPLEMENTATION(component, service) imp_##component##_##service
51 
52 /**
53   Declares a Service Implementation. It builds standard implementation
54   info structure. Only a series of pointers to methods the Service
55   Implementation implements as respective Service methods are expected to be
56   used after this macro and before the END_SERVICE_IMPLEMENTATION counterpart.
57 
58   @param component Name of the Component to create implementation in.
59   @param service Name of the Service to create implementation for.
60 */
61 #define BEGIN_SERVICE_IMPLEMENTATION(component, service) \
62   SERVICE_TYPE(service) SERVICE_IMPLEMENTATION(component, service) = {
63 /**
64   A macro to end the last declaration of a Service Implementation.
65 */
66 #define END_SERVICE_IMPLEMENTATION() }
67 
68 /**
69   A macro to ensure method implementation has required properties, that is it
70   does not throw exceptions and is static. This macro should be used with
71   exactly the same arguments as DECLARE_METHOD.
72 
73   @param retval Type of return value. It cannot contain comma characters, but
74     as only simple structures are possible, this shouldn't be a problem.
75   @param name Method name.
76   @param args a list of arguments in parenthesis.
77 */
78 #define DEFINE_METHOD(retval, name, args) retval name args noexcept
79 
80 /**
81   A short macro to define method that returns bool, which is the most common
82   case.
83 
84   @param name Method name.
85   @param args a list of arguments in parenthesis.
86 */
87 #define DEFINE_BOOL_METHOD(name, args) \
88   DEFINE_METHOD(mysql_service_status_t, name, args)
89 
90 #endif /* SERVICE_IMPLEMENTATION_H */
91