1 /******************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
23 * @brief This file contains the APIs for queue to be implemented
33 #endif /* __cplusplus */
36 * @struct u_queue_message
37 * @brief Queue message format
39 typedef struct u_queue_message_t
41 /* Pointer to message*/
47 typedef struct u_queue_element_t u_queue_element;
50 * @struct u_queue_element
51 * @brief Queue element format
53 struct u_queue_element_t
55 /* pointer to queue message */
56 u_queue_message_t *message;
57 /* Pointer to next queue element*/
58 u_queue_element *next;
63 * @brief Queue structure
65 typedef struct u_queue_t
67 /* Head of the queue */
68 u_queue_element *element;
69 /* Number of messages in Queue*/
74 * @brief API to creates queue and initializes the elements.
75 * @return u_queue_t pointer if Success, NULL otherwise
77 u_queue_t *u_queue_create();
81 * @brief Resets and deletes the queue
82 * @param queue- queue pointer
83 * @return CAResult_t - CA_STATUS_OK, if Success
84 * @return CA_STATUS_FAILED - otherwise
86 CAResult_t u_queue_delete(u_queue_t *queue);
89 * @fn u_queue_add_element
90 * @brief Adds message at the end of the queue
91 * @param queue - pointer to queue
92 * @param message - Pointer to message
93 * @return CAResult_t - CA_STATUS_OK, if Success
94 * @return CA_STATUS_FAILED - otherwise
96 CAResult_t u_queue_add_element(u_queue_t *queue, u_queue_message_t *message);
99 * @fn u_queue_get_element
100 * @brief Returns the first message in the queue and removes queue element.
101 * Head is moved to next element.
102 * @param queue - pointer to queue
103 * @return pointer to Message, if Success
104 * @return NULL - otherwise
106 u_queue_message_t *u_queue_get_element(u_queue_t *queue);
109 * @fn u_queueRemoveElement
110 * @brief Removes head element of the queue
111 * @param queue - pointer to queue
112 * @return CAResult_t - CA_STATUS_OK, if Success
113 * @return CA_STATUS_FAILED - otherwise
115 CAResult_t u_queue_remove_element(u_queue_t *queue);
118 * @fn u_queue_get_size
119 * @param queue - pointer to queue
120 * @return number of elements in queue
122 uint32_t u_queue_get_size(u_queue_t *queue);
126 * @brief Removes all the messages from Queue and reset message count
127 * @param queue - pointer to queue
128 * @return CAResult_t - CA_STATUS_OK, if Success
129 * @return CA_STATUS_FAILED - otherwise
131 CAResult_t u_queue_reset(u_queue_t *queue);
134 * @fn u_queue_get_head
135 * @brief Returns the first message in queue, but not remove the element
136 * @param queue - pointer to queue
137 * @return pointer to Message, if Success
138 * @return NULL - otherwise
140 u_queue_message_t *u_queue_get_head(u_queue_t *queue);
144 #endif /* __cplusplus */
146 #endif /* _U_QUEUE_H_ */