source: azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/inc/azure_c_shared_utility/singlylinkedlist.h@ 457

Last change on this file since 457 was 457, checked in by coas-nagasima, 4 years ago

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 3.5 KB
Line 
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 SINGLYLINKEDLIST_H
5#define SINGLYLINKEDLIST_H
6
7#ifdef __cplusplus
8#else
9#include "stdbool.h"
10#endif /* __cplusplus */
11
12#include "umock_c/umock_c_prod.h"
13
14#ifdef __cplusplus
15extern "C" {
16#endif /* __cplusplus */
17
18typedef struct SINGLYLINKEDLIST_INSTANCE_TAG* SINGLYLINKEDLIST_HANDLE;
19typedef struct LIST_ITEM_INSTANCE_TAG* LIST_ITEM_HANDLE;
20
21/**
22* @brief Function passed to singlylinkedlist_find, which returns whichever first list item that matches it.
23* @param list_item Current list node being evaluated.
24* @param match_context Context passed to singlylinkedlist_find.
25* @returns True to indicate that the current list node is the one to be returned, or false to continue traversing the list.
26*/
27typedef bool (*LIST_MATCH_FUNCTION)(LIST_ITEM_HANDLE list_item, const void* match_context);
28/**
29* @brief Function passed to singlylinkedlist_remove_if, which is used to define if an item of the list should be removed or not.
30* @param item Value of the current list node being evaluated for removal.
31* @param match_context Context passed to singlylinkedlist_remove_if.
32* @param continue_processing Indicates if singlylinkedlist_remove_if shall continue iterating through the next nodes of the list or stop.
33* @returns True to indicate that the current list node shall be removed, or false to not to.
34*/
35typedef bool (*LIST_CONDITION_FUNCTION)(const void* item, const void* match_context, bool* continue_processing);
36/**
37* @brief Function passed to singlylinkedlist_foreach, which is called for the value of each node of the list.
38* @param item Value of the current list node being processed.
39* @param action_context Context passed to singlylinkedlist_foreach.
40* @param continue_processing Indicates if singlylinkedlist_foreach shall continue iterating through the next nodes of the list or stop.
41*/
42typedef void (*LIST_ACTION_FUNCTION)(const void* item, const void* action_context, bool* continue_processing);
43
44MOCKABLE_FUNCTION(, SINGLYLINKEDLIST_HANDLE, singlylinkedlist_create);
45MOCKABLE_FUNCTION(, void, singlylinkedlist_destroy, SINGLYLINKEDLIST_HANDLE, list);
46MOCKABLE_FUNCTION(, LIST_ITEM_HANDLE, singlylinkedlist_add, SINGLYLINKEDLIST_HANDLE, list, const void*, item);
47MOCKABLE_FUNCTION(, LIST_ITEM_HANDLE, singlylinkedlist_add_head, SINGLYLINKEDLIST_HANDLE, list, const void*, item);
48MOCKABLE_FUNCTION(, int, singlylinkedlist_remove, SINGLYLINKEDLIST_HANDLE, list, LIST_ITEM_HANDLE, item_handle);
49MOCKABLE_FUNCTION(, LIST_ITEM_HANDLE, singlylinkedlist_get_head_item, SINGLYLINKEDLIST_HANDLE, list);
50MOCKABLE_FUNCTION(, LIST_ITEM_HANDLE, singlylinkedlist_get_next_item, LIST_ITEM_HANDLE, item_handle);
51MOCKABLE_FUNCTION(, LIST_ITEM_HANDLE, singlylinkedlist_find, SINGLYLINKEDLIST_HANDLE, list, LIST_MATCH_FUNCTION, match_function, const void*, match_context);
52MOCKABLE_FUNCTION(, const void*, singlylinkedlist_item_get_value, LIST_ITEM_HANDLE, item_handle);
53MOCKABLE_FUNCTION(, int, singlylinkedlist_remove_if, SINGLYLINKEDLIST_HANDLE, list, LIST_CONDITION_FUNCTION, condition_function, const void*, match_context);
54MOCKABLE_FUNCTION(, int, singlylinkedlist_foreach, SINGLYLINKEDLIST_HANDLE, list, LIST_ACTION_FUNCTION, action_function, const void*, action_context);
55
56#ifdef __cplusplus
57}
58#endif /* __cplusplus */
59
60#endif /* SINGLYLINKEDLIST_H */
Note: See TracBrowser for help on using the repository browser.