Update copyright dates
[src/app-framework-binder.git] / include / afb / afb-binding.h
1 /*
2  * Copyright (C) 2015-2020 "IoT.bzh"
3  * Author: José Bollo <jose.bollo@iot.bzh>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #pragma once
19
20 /**
21  * @mainpage
22  *
23  * @section brief Brief introduction
24  *
25  * This is part of the AGL framework micro-service binder and is provided as the
26  * API for writing bindings.
27  *
28  * The normal usage is to include only one file as below:
29  *
30  * ```C
31  * #define AFB_BINDING_VERSION 3
32  * #include <afb/afb-binding.h>
33  * ```
34  *
35  * @example tuto-1.c
36  * @example tuto-2.c
37  */
38 /**
39  * @file afb/afb-binding.h
40  */
41
42 #include <stdarg.h>
43 #include <stdint.h>
44 #include <json-c/json.h>
45
46 /**
47  * @def AFB_BINDING_INTERFACE_VERSION
48
49  *  * Version of the binding interface.
50  *
51  * This is intended to be test for tuning condition code.
52  * It is of the form MAJOR * 1000 + REVISION.
53  *
54  * @see AFB_BINDING_UPPER_VERSION that should match MAJOR
55  */
56 #define AFB_BINDING_INTERFACE_VERSION 3000
57
58 /**
59  * @def AFB_BINDING_LOWER_VERSION
60  *
61  * Lowest binding API version supported.
62  *
63  * @see AFB_BINDING_VERSION
64  * @see AFB_BINDING_UPPER_VERSION
65  */
66 #define AFB_BINDING_LOWER_VERSION     1
67
68 /**
69  * @def AFB_BINDING_UPPER_VERSION
70  *
71  * Upper binding API version supported.
72  *
73  * @see AFB_BINDING_VERSION
74  * @see AFB_BINDING_LOWER_VERSION
75  */
76 #define AFB_BINDING_UPPER_VERSION     3
77
78 /**
79  * @def AFB_BINDING_VERSION
80  *
81  * This macro must be defined before including <afb/afb-binding.h> to set
82  * the required binding API.
83  */
84
85 #ifndef AFB_BINDING_VERSION
86 #error "\
87 \n\
88 \n\
89   AFB_BINDING_VERSION should be defined before including <afb/afb-binding.h>\n\
90   AFB_BINDING_VERSION defines the version of binding that you use.\n\
91   Currently the version to use is 3 (older versions: 1 is obsolete, 2 is legacy).\n\
92   Consider to add one of the following define before including <afb/afb-binding.h>:\n\
93 \n\
94     #define AFB_BINDING_VERSION 3\n\
95 \n\
96 "
97 #else
98 #  if AFB_BINDING_VERSION == 1
99 #    warning "Using binding version 1, consider to switch to version 3"
100 #  endif
101 #  if AFB_BINDING_VERSION == 2
102 #    warning "Using binding version 2, consider to switch to version 3"
103 #  endif
104 #endif
105
106 #if AFB_BINDING_VERSION != 0
107 # if AFB_BINDING_VERSION < AFB_BINDING_LOWER_VERSION || AFB_BINDING_VERSION > AFB_BINDING_UPPER_VERSION
108 #  error "Unsupported binding version AFB_BINDING_VERSION"
109 # endif
110 #endif
111
112 /***************************************************************************************************/
113 #include "afb-binding-predefs.h"
114 #include "afb-binding-v1.h"
115 #include "afb-binding-v2.h"
116 #include "afb-binding-v3.h"
117 #if defined(AFB_BINDING_WANT_DYNAPI)
118 #  include "afb-dynapi-legacy.h"
119 #endif
120 #include "afb-binding-postdefs.h"
121