Microsoft Azure IoT Gateway SDK  1.0.8
The Microsoft Azure IoT Gateway SDK contains the infrastructure and modules to create IoT gateway solutions.
module.h
Go to the documentation of this file.
1 // Copyright (c) Microsoft. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 
17 #ifndef MODULE_H
18 #define MODULE_H
19 
22 typedef struct MODULE_TAG MODULE;
23 
25 typedef void* MODULE_HANDLE;
26 
28 typedef struct MODULE_API_TAG MODULE_API;
29 
30 #include "azure_c_shared_utility/macro_utils.h"
31 #include "broker.h"
32 #include "message.h"
33 
34 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39 
44  struct MODULE_TAG
45  {
50  };
51 
64  typedef void*(*pfModule_ParseConfigurationFromJson)(const char* configuration);
65 
75  typedef void(*pfModule_FreeConfiguration)(void* configuration);
76 
88  typedef MODULE_HANDLE(*pfModule_Create)(BROKER_HANDLE broker, const void* configuration);
89 
97  typedef void(*pfModule_Destroy)(MODULE_HANDLE moduleHandle);
98 
108  typedef void(*pfModule_Receive)(MODULE_HANDLE moduleHandle, MESSAGE_HANDLE messageHandle);
109 
119  typedef void(*pfModule_Start)(MODULE_HANDLE moduleHandle);
120 
123  {
124  MODULE_API_VERSION_1
126 
128  static const MODULE_API_VERSION Module_ApiGatewayVersion = MODULE_API_VERSION_1;
129 
136  {
140  MODULE_API_VERSION version;
141  };
142 
147  typedef struct MODULE_API_1_TAG
148  {
151 
155 
159 
162 
165 
168 
172  } MODULE_API_1;
173 
181  typedef const MODULE_API* (*pfModule_GetApi)(MODULE_API_VERSION gateway_api_version);
182 
184 #define MODULE_GETAPI_NAME ("Module_GetApi")
185 
186 #ifdef _WIN32
187 #define MODULE_EXPORT __declspec(dllexport)
188 #else
189 #define MODULE_EXPORT
190 #endif // _WIN32
191 
195 #define MODULE_STATIC_GETAPI(MODULE_NAME) C2(Module_GetApi_, MODULE_NAME)
196 
201 MODULE_EXPORT const MODULE_API* Module_GetApi(MODULE_API_VERSION gateway_api_version);
202 
203 #ifdef __cplusplus
204 }
205 #endif
206 
207 #endif // MODULE_H
pfModule_Receive Module_Receive
Function pointer to the Module_Receive function.
Definition: module.h:167
pfModule_FreeConfiguration Module_FreeConfiguration
Function pointer to the Module_FreeConfiguration function.
Definition: module.h:158
void * MODULE_HANDLE
Represents a module instance.
Definition: module.h:25
enum MODULE_API_VERSION_TAG MODULE_API_VERSION
Module API version.
pfModule_Create Module_Create
Function pointer to the Module_Create function.
Definition: module.h:161
struct MODULE_API_1_TAG MODULE_API_1
The module interface, version 1. An instance of this struct contains function pointers to module-spec...
MODULE_API base
Always the first element on a Module's API.
Definition: module.h:150
struct BROKER_HANDLE_DATA_TAG * BROKER_HANDLE
Struct representing a message broker.
Definition: broker.h:18
pfModule_ParseConfigurationFromJson Module_ParseConfigurationFromJson
Function pointer to the Module_ParseConfigurationFromJson function.
Definition: module.h:154
Defines structures and function prototypes for creating, inspecting and disposing of messages publish...
MODULE_API_VERSION_TAG
Module API version.
Definition: module.h:122
pfModule_Start Module_Start
Function pointer to the Module_Start function (optional).
Definition: module.h:171
Structure used to represent/abstract the idea of a module. May contain Handle/FxnPtrs or an interface...
Definition: module.h:44
void(* pfModule_Start)(MODULE_HANDLE moduleHandle)
Signals to the module that the broker is ready to send and receive messages.
Definition: module.h:119
void *(* pfModule_ParseConfigurationFromJson)(const char *configuration)
Translates module configuration from a JSON string to a module specific data structure.
Definition: module.h:64
const MODULE_API * module_apis
Struct containing function pointers.
Definition: module.h:47
MODULE_EXPORT const MODULE_API * Module_GetApi(MODULE_API_VERSION gateway_api_version)
This is the only function exported by a module under a "by convention" name...
void(* pfModule_Receive)(MODULE_HANDLE moduleHandle, MESSAGE_HANDLE messageHandle)
Receives a message from the broker.
Definition: module.h:108
MODULE_HANDLE module_handle
HANDLE for module.
Definition: module.h:49
MODULE_API_VERSION version
The version of the MODULES_API, shall always be the first element of this structure.
Definition: module.h:140
Structure returned by Module_GetApi containing the API version. By convention, the module returns a c...
Definition: module.h:135
void(* pfModule_Destroy)(MODULE_HANDLE moduleHandle)
Disposes of the resources managed by this module.
Definition: module.h:97
void(* pfModule_FreeConfiguration)(void *configuration)
Frees the configuration object returned by the ParseConfigurationFromJson function.
Definition: module.h:75
Library for configuring and using the gateway's message broker.
pfModule_Destroy Module_Destroy
Function pointer to the Module_Destroy function.
Definition: module.h:164
struct MESSAGE_HANDLE_DATA_TAG * MESSAGE_HANDLE
Struct representing a particular message.
Definition: message.h:48
MODULE_HANDLE(* pfModule_Create)(BROKER_HANDLE broker, const void *configuration)
Creates an instance of a module.
Definition: module.h:88
The module interface, version 1. An instance of this struct contains function pointers to module-spec...
Definition: module.h:147