UniMRCP  1.4.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mrcp_engine_plugin.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2015 Arsen Chaloyan
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MRCP_ENGINE_PLUGIN_H
18 #define MRCP_ENGINE_PLUGIN_H
19 
20 /**
21  * @file mrcp_engine_plugin.h
22  * @brief MRCP Engine Plugin
23  */
24 
25 #include "apr_version.h"
26 #include "apt_log.h"
27 #include "mrcp_engine_types.h"
28 
30 
31 /** Let the plugin symbols be always exported as C functions */
32 #ifdef __cplusplus
33 #define MRCP_PLUGIN_EXTERN_C extern "C"
34 #else
35 #define MRCP_PLUGIN_EXTERN_C extern
36 #endif
37 
38 /** Plugin export defines */
39 #ifdef WIN32
40 #define MRCP_PLUGIN_DECLARE(type) MRCP_PLUGIN_EXTERN_C __declspec(dllexport) type
41 #else
42 #define MRCP_PLUGIN_DECLARE(type) MRCP_PLUGIN_EXTERN_C type
43 #endif
44 
45 /** [REQUIRED] Symbol name of the main entry point in plugin DSO */
46 #define MRCP_PLUGIN_ENGINE_SYM_NAME "mrcp_plugin_create"
47 /** [REQUIRED] Symbol name of the vesrion number entry point in plugin DSO */
48 #define MRCP_PLUGIN_VERSION_SYM_NAME "mrcp_plugin_version"
49 /** [IMPLIED] Symbol name of the log accessor entry point in plugin DSO */
50 #define MRCP_PLUGIN_LOGGER_SYM_NAME "mrcp_plugin_logger_set"
51 
52 /** Prototype of engine creator (entry point of plugin DSO) */
53 typedef mrcp_engine_t* (*mrcp_plugin_creator_f)(apr_pool_t *pool);
54 
55 /** Prototype of log accessor (entry point of plugin DSO) */
57 
58 /** Declare this macro in plugins to use log routine of the server */
59 #define MRCP_PLUGIN_LOGGER_IMPLEMENT \
60  MRCP_PLUGIN_DECLARE(apt_bool_t) mrcp_plugin_logger_set(apt_logger_t *logger) \
61  { return apt_log_instance_set(logger); }
62 
63 /** Declare this macro in plugins to use log routine of the server */
64 #define MRCP_PLUGIN_LOG_SOURCE_IMPLEMENT(LOG_SOURCE, LOG_SOURCE_TAG) \
65  apt_log_source_t *LOG_SOURCE = &def_log_source; \
66  MRCP_PLUGIN_DECLARE(apt_bool_t) mrcp_plugin_logger_set(apt_logger_t *logger) \
67  { apt_log_instance_set(logger); \
68  apt_log_source_assign(LOG_SOURCE_TAG,&LOG_SOURCE); \
69  return TRUE; }
70 
71 /** Declare this macro in plugins to set plugin version */
72 #define MRCP_PLUGIN_VERSION_DECLARE \
73  MRCP_PLUGIN_DECLARE(mrcp_plugin_version_t) mrcp_plugin_version; \
74  mrcp_plugin_version_t mrcp_plugin_version = \
75  {PLUGIN_MAJOR_VERSION, PLUGIN_MINOR_VERSION, PLUGIN_PATCH_VERSION};
76 
77 
78 /** major version
79  * Major API changes that could cause compatibility problems for older
80  * plugins such as structure size changes. No binary compatibility is
81  * possible across a change in the major version.
82  */
83 #define PLUGIN_MAJOR_VERSION 1
84 
85 /** minor version
86  * Minor API changes that do not cause binary compatibility problems.
87  * Reset to 0 when upgrading PLUGIN_MAJOR_VERSION
88  */
89 #define PLUGIN_MINOR_VERSION 4
90 
91 /** patch level
92  * The Patch Level never includes API changes, simply bug fixes.
93  * Reset to 0 when upgrading PLUGIN_MINOR_VERSION
94  */
95 #define PLUGIN_PATCH_VERSION 0
96 
97 
98 /**
99  * Check at compile time if the plugin version is at least a certain
100  * level.
101  */
102 #define PLUGIN_VERSION_AT_LEAST(major,minor,patch) \
103 (((major) < PLUGIN_MAJOR_VERSION) \
104  || ((major) == PLUGIN_MAJOR_VERSION && (minor) < PLUGIN_MINOR_VERSION) \
105  || ((major) == PLUGIN_MAJOR_VERSION && (minor) == PLUGIN_MINOR_VERSION && (patch) <= PLUGIN_PATCH_VERSION))
106 
107 /** The formatted string of plugin's version */
108 #define PLUGIN_VERSION_STRING \
109  APR_STRINGIFY(PLUGIN_MAJOR_VERSION) "." \
110  APR_STRINGIFY(PLUGIN_MINOR_VERSION) "." \
111  APR_STRINGIFY(PLUGIN_PATCH_VERSION)
112 
113 /** Plugin version */
114 typedef apr_version_t mrcp_plugin_version_t;
115 
116 /** Get plugin version */
117 static APR_INLINE void mrcp_plugin_version_get(mrcp_plugin_version_t *version)
118 {
119  version->major = PLUGIN_MAJOR_VERSION;
120  version->minor = PLUGIN_MINOR_VERSION;
121  version->patch = PLUGIN_PATCH_VERSION;
122 }
123 
124 /** Check plugin version */
125 static APR_INLINE int mrcp_plugin_version_check(mrcp_plugin_version_t *version)
126 {
127  return PLUGIN_VERSION_AT_LEAST(version->major,version->minor,version->patch);
128 }
129 
131 
132 #endif /* MRCP_ENGINE_PLUGIN_H */
#define PLUGIN_PATCH_VERSION
Definition: mrcp_engine_plugin.h:95
#define APT_END_EXTERN_C
Definition: apt.h:38
int apt_bool_t
Definition: apt.h:57
apr_version_t mrcp_plugin_version_t
Definition: mrcp_engine_plugin.h:114
#define PLUGIN_VERSION_AT_LEAST(major, minor, patch)
Definition: mrcp_engine_plugin.h:102
#define PLUGIN_MAJOR_VERSION
Definition: mrcp_engine_plugin.h:83
#define APT_BEGIN_EXTERN_C
Definition: apt.h:36
Basic Logger.
apt_bool_t(* mrcp_plugin_log_accessor_f)(apt_logger_t *logger)
Definition: mrcp_engine_plugin.h:56
#define PLUGIN_MINOR_VERSION
Definition: mrcp_engine_plugin.h:89
MRCP Engine Types.
struct apt_logger_t apt_logger_t
Definition: apt_log.h:124
Definition: mrcp_engine_types.h:114