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 |
|
---|
4 | #ifndef COMMAND_DECODER_H
|
---|
5 | #define COMMAND_DECODER_H
|
---|
6 |
|
---|
7 | #include "multitree.h"
|
---|
8 | #include "schema.h"
|
---|
9 | #include "agenttypesystem.h"
|
---|
10 | #include "azure_macro_utils/macro_utils.h"
|
---|
11 | #include "methodreturn.h"
|
---|
12 |
|
---|
13 | #ifdef __cplusplus
|
---|
14 | extern "C" {
|
---|
15 | #else
|
---|
16 | #include <stdbool.h>
|
---|
17 | #endif
|
---|
18 |
|
---|
19 | #define COMMANDDECODER_RESULT_VALUES \
|
---|
20 | COMMANDDECODER_OK, \
|
---|
21 | COMMANDDECODER_ERROR, \
|
---|
22 | COMMANDDECODER_INVALID_ARG
|
---|
23 |
|
---|
24 | MU_DEFINE_ENUM_WITHOUT_INVALID(COMMANDDECODER_RESULT, COMMANDDECODER_RESULT_VALUES)
|
---|
25 |
|
---|
26 | #define EXECUTE_COMMAND_RESULT_VALUES \
|
---|
27 | EXECUTE_COMMAND_SUCCESS, /*when the final recipient of the command indicates a successful execution*/ \
|
---|
28 | EXECUTE_COMMAND_FAILED, /*when the final recipient of the command indicates a failure*/ \
|
---|
29 | EXECUTE_COMMAND_ERROR /*when a transient error either in the final recipient or until the final recipient*/
|
---|
30 |
|
---|
31 | MU_DEFINE_ENUM_WITHOUT_INVALID(EXECUTE_COMMAND_RESULT, EXECUTE_COMMAND_RESULT_VALUES)
|
---|
32 |
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 | /* Codes_SRS_COMMAND_DECODER_99_001:[ The CommandDecoder module shall expose the following API:] */
|
---|
37 |
|
---|
38 | typedef struct COMMAND_DECODER_HANDLE_DATA_TAG* COMMAND_DECODER_HANDLE;
|
---|
39 | typedef EXECUTE_COMMAND_RESULT(*ACTION_CALLBACK_FUNC)(void* actionCallbackContext, const char* relativeActionPath, const char* actionName, size_t argCount, const AGENT_DATA_TYPE* args);
|
---|
40 | typedef METHODRETURN_HANDLE(*METHOD_CALLBACK_FUNC)(void* methodCallbackContext, const char* relativeMethodPath, const char* methodName, size_t argCount, const AGENT_DATA_TYPE* args);
|
---|
41 |
|
---|
42 | #include "umock_c/umock_c_prod.h"
|
---|
43 |
|
---|
44 | MOCKABLE_FUNCTION(,COMMAND_DECODER_HANDLE, CommandDecoder_Create, SCHEMA_MODEL_TYPE_HANDLE, modelHandle, ACTION_CALLBACK_FUNC, actionCallback, void*, actionCallbackContext, METHOD_CALLBACK_FUNC, methodCallback, void*, methodCallbackContext);
|
---|
45 | MOCKABLE_FUNCTION(,EXECUTE_COMMAND_RESULT, CommandDecoder_ExecuteCommand, COMMAND_DECODER_HANDLE, handle, const char*, command);
|
---|
46 | MOCKABLE_FUNCTION(,METHODRETURN_HANDLE, CommandDecoder_ExecuteMethod, COMMAND_DECODER_HANDLE, handle, const char*, fullMethodName, const char*, methodPayload);
|
---|
47 | MOCKABLE_FUNCTION(,void, CommandDecoder_Destroy, COMMAND_DECODER_HANDLE, commandDecoderHandle);
|
---|
48 |
|
---|
49 | MOCKABLE_FUNCTION(, EXECUTE_COMMAND_RESULT, CommandDecoder_IngestDesiredProperties, void*, startAddress, COMMAND_DECODER_HANDLE, handle, const char*, jsonPayload, bool, parseDesiredNode);
|
---|
50 |
|
---|
51 | #ifdef __cplusplus
|
---|
52 | }
|
---|
53 | #endif
|
---|
54 |
|
---|
55 | #endif /* COMMAND_DECODER_H */
|
---|