1 /*------------------------------------------------------------------------------------------------*/
2 /* UNICENS V2.1.0-3491 */
3 /* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
5 /* This program is free software: you can redistribute it and/or modify */
6 /* it under the terms of the GNU General Public License as published by */
7 /* the Free Software Foundation, either version 2 of the License, or */
8 /* (at your option) any later version. */
10 /* This program is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* GNU General Public License for more details. */
15 /* You should have received a copy of the GNU General Public License */
16 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 /* You may also obtain this software under a propriety license from Microchip. */
19 /* Please contact Microchip for further information. */
20 /*------------------------------------------------------------------------------------------------*/
24 * \brief Implementation of class CTelQueue
26 * \cond UCS_INTERNAL_DOC
27 * \addtogroup G_MSG_QUEUE
31 /*------------------------------------------------------------------------------------------------*/
33 /*------------------------------------------------------------------------------------------------*/
34 #include "ucs_telqueue.h"
37 /*------------------------------------------------------------------------------------------------*/
38 /* Internal constants */
39 /*------------------------------------------------------------------------------------------------*/
41 /*------------------------------------------------------------------------------------------------*/
43 /*------------------------------------------------------------------------------------------------*/
44 /*! \brief Constructor of class CTelQueue
45 * \param self The instance
46 * \param ucs_user_ptr User reference that needs to be passed in every callback function
48 void Telq_Ctor(CTelQueue *self, void *ucs_user_ptr)
50 self->ucs_user_ptr = ucs_user_ptr;
51 Dl_Ctor(&self->list, self->ucs_user_ptr);
54 /*! \brief Retrieves the head object of the telegram queue
55 * \param self The instance
56 * \return Reference to the telegram if a telegram object is available.
59 Msg_MostTel_t* Telq_Dequeue(CTelQueue *self)
61 Msg_MostTel_t *tel_ptr = NULL;
62 CDlNode *node_ptr = Dl_PopHead(&self->list);
66 tel_ptr = (Msg_MostTel_t*)Dln_GetData(node_ptr);
72 /*! \brief Retrieves a reference to the head object
73 * without removing it from the telegram queue
74 * \param self The instance
75 * \return Reference to the telegram if a telegram object is available.
78 Msg_MostTel_t* Telq_Peek(CTelQueue *self)
80 Msg_MostTel_t *tel_ptr = NULL;
81 CDlNode *node_ptr = Dl_PeekHead(&self->list);
85 tel_ptr = (Msg_MostTel_t*)Dln_GetData(node_ptr);
91 /*! \brief Adds a telegram to the tail of the queue
92 * \param self The instance
93 * \param tel_ptr Reference to the telegram
95 void Telq_Enqueue(CTelQueue *self, Msg_MostTel_t *tel_ptr)
97 Dl_InsertTail(&self->list, Msg_GetNode((CMessage*)(void*)tel_ptr));
100 /*! \brief Retrieves the current number of objects in the telegram queue
101 * \param self The instance
102 * \return The current number of available telegram objects in the pool
104 uint8_t Telq_GetSize(CTelQueue *self)
106 return (uint8_t)Dl_GetSize(&self->list);
114 /*------------------------------------------------------------------------------------------------*/
116 /*------------------------------------------------------------------------------------------------*/