Use latest version of conf.d/templates submodule.
[apps/agl-service-unicens.git] / ucs2-lib / inc / ucs_amspool.h
1 /*------------------------------------------------------------------------------------------------*/
2 /* UNICENS V2.1.0-3491                                                                            */
3 /* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG.                              */
4 /*                                                                                                */
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.                                                            */
9 /*                                                                                                */
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.                                                   */
14 /*                                                                                                */
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/>.                          */
17 /*                                                                                                */
18 /* You may also obtain this software under a propriety license from Microchip.                    */
19 /* Please contact Microchip for further information.                                              */
20 /*------------------------------------------------------------------------------------------------*/
21
22 /*!
23  * \file
24  * \brief Internal header file of Application Message Pools
25  *
26  * \cond UCS_INTERNAL_DOC
27  * \addtogroup G_AMSPOOL
28  * @{
29  */
30
31 #ifndef UCS_AMSPOOL_H
32 #define UCS_AMSPOOL_H
33
34 /*------------------------------------------------------------------------------------------------*/
35 /* Includes                                                                                       */
36 /*------------------------------------------------------------------------------------------------*/
37 #include "ucs_ams_pb.h"
38 #include "ucs_obs.h"
39 #include "ucs_amsallocator.h"
40
41 #ifdef __cplusplus
42 extern "C"
43 {
44 #endif
45
46 /*------------------------------------------------------------------------------------------------*/
47 /* Classes                                                                                        */
48 /*------------------------------------------------------------------------------------------------*/
49 /*! \brief Class members of AMS Pool */
50 typedef struct CAmsMsgPool_
51 {
52     Ams_MemAllocator_t *allocator_ptr;              /*!< \brief  Interface to memory allocator */
53     Ucs_AmsRx_Msg_t    *rx_rsvd_msg_ptr;            /*!< \brief  Pre-allocated Rx message or NULL if no 
54                                                      *           reserved message is available */
55     Ucs_AmsRx_Msg_t    *rx_rsvd_msg_ref;            /*!< \brief  Stores the reference of the reserved message
56                                                      *           to identify it and restore the 
57                                                      *           \c rx_rsvd_msg_ptr. */
58     CSubject            tx_freed_subject;           /*!< \brief  Allows to observe freed Tx message event */
59     CSubject            rx_freed_subject;           /*!< \brief  Allows to observe freed Rx message event */
60     bool                tx_notify_freed;            /*!< \brief  Is \c true when to notify the next Tx freed object */
61     bool                rx_notify_freed;            /*!< \brief  Is \c true when to notify the next Rx freed object */
62     bool                terminated;                 /*!< \brief  Is \c true if a cleanup was done. Helps to release the 
63                                                      *           pre-allocated message after the first cleanup attempt. */
64     void               *ucs_user_ptr;               /*!< \brief User reference that needs to be passed in every callback function */
65
66 } CAmsMsgPool;
67
68 /*------------------------------------------------------------------------------------------------*/
69 /* Class methods                                                                                  */
70 /*------------------------------------------------------------------------------------------------*/
71 extern void Amsp_Ctor(CAmsMsgPool *self, Ams_MemAllocator_t *mem_allocator_ptr, void *ucs_user_ptr);
72 extern void Amsp_Cleanup(CAmsMsgPool *self);
73 /* Tx */
74 extern void Amsp_AssignTxFreedObs(CAmsMsgPool *self, CObserver *observer_ptr);
75 extern Ucs_AmsTx_Msg_t* Amsp_AllocTxObj(CAmsMsgPool *self, uint16_t payload_sz);
76 /* Rx */
77 extern void Amsp_AssignRxFreedObs(CAmsMsgPool *self, CObserver *observer_ptr);
78 extern Ucs_AmsRx_Msg_t* Amsp_AllocRxObj(CAmsMsgPool *self, uint16_t payload_sz);
79 extern Ucs_AmsRx_Msg_t* Amsp_AllocRxRsvd(CAmsMsgPool *self);
80 extern bool Amsp_AllocRxPayload(CAmsMsgPool *self, uint16_t payload_sz, Ucs_AmsRx_Msg_t* msg_ptr);
81 extern void Amsp_FreeRxObj(CAmsMsgPool *self, Ucs_AmsRx_Msg_t* msg_ptr);
82 extern void Amsp_FreeRxPayload(CAmsMsgPool *self, Ucs_AmsRx_Msg_t* msg_ptr);
83
84 #ifdef __cplusplus
85 }               /* extern "C" */
86 #endif
87
88 #endif          /* UCS_AMSPOOL_H */
89
90 /*!
91  * @}
92  * \endcond
93  */
94
95 /*------------------------------------------------------------------------------------------------*/
96 /* End of file                                                                                    */
97 /*------------------------------------------------------------------------------------------------*/
98