sevencore fota solution development project
ext_fota/MsgQueue.cpp@8:9eec2c246a85, 2015-08-20 (annotated)
- Committer:
- dudnwjs
- Date:
- Thu Aug 20 05:16:55 2015 +0000
- Revision:
- 8:9eec2c246a85
- Parent:
- 1:5cf3a6c969be
- Child:
- 9:fcf91f563147
add msg handler doxygen
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dudnwjs | 8:9eec2c246a85 | 1 | /** |
dudnwjs | 8:9eec2c246a85 | 2 | * @file MsgQueue.cpp |
dudnwjs | 8:9eec2c246a85 | 3 | * @brief Ble message queue |
dudnwjs | 8:9eec2c246a85 | 4 | * Copyright 2015 SEVENCORE Co., Ltd. |
dudnwjs | 8:9eec2c246a85 | 5 | * |
dudnwjs | 8:9eec2c246a85 | 6 | * @author HyeongJun Kim |
dudnwjs | 8:9eec2c246a85 | 7 | * @version 1.0.0 |
dudnwjs | 8:9eec2c246a85 | 8 | * @date 2015-08-19 |
dudnwjs | 8:9eec2c246a85 | 9 | */ |
dudnwjs | 1:5cf3a6c969be | 10 | #include "MsgQueue.h" |
dudnwjs | 0:a1f6b1ba8a1e | 11 | #include "mbed.h" |
dudnwjs | 8:9eec2c246a85 | 12 | /** |
dudnwjs | 8:9eec2c246a85 | 13 | **************************************************************************************** |
dudnwjs | 8:9eec2c246a85 | 14 | * @addtogroup ext_fota module |
dudnwjs | 8:9eec2c246a85 | 15 | * @brief Ble message Queue Class Method Definition. |
dudnwjs | 8:9eec2c246a85 | 16 | * |
dudnwjs | 8:9eec2c246a85 | 17 | * @{ |
dudnwjs | 8:9eec2c246a85 | 18 | **************************************************************************************** |
dudnwjs | 8:9eec2c246a85 | 19 | */ |
dudnwjs | 0:a1f6b1ba8a1e | 20 | namespace sevencore_fota{ |
dudnwjs | 0:a1f6b1ba8a1e | 21 | |
dudnwjs | 1:5cf3a6c969be | 22 | MsgQueue::MsgQueue(int MaxSize):MaxNum(MaxSize) |
dudnwjs | 0:a1f6b1ba8a1e | 23 | { |
dudnwjs | 0:a1f6b1ba8a1e | 24 | Front = NULL; |
dudnwjs | 0:a1f6b1ba8a1e | 25 | Rear = NULL; |
dudnwjs | 0:a1f6b1ba8a1e | 26 | ElemCnt = 0; |
dudnwjs | 0:a1f6b1ba8a1e | 27 | } |
dudnwjs | 0:a1f6b1ba8a1e | 28 | |
dudnwjs | 1:5cf3a6c969be | 29 | MsgQueue::~MsgQueue(void) |
dudnwjs | 0:a1f6b1ba8a1e | 30 | { |
dudnwjs | 0:a1f6b1ba8a1e | 31 | } |
dudnwjs | 0:a1f6b1ba8a1e | 32 | |
dudnwjs | 1:5cf3a6c969be | 33 | void MsgQueue::EnQueue(void *vData) |
dudnwjs | 0:a1f6b1ba8a1e | 34 | { |
dudnwjs | 0:a1f6b1ba8a1e | 35 | Element *tmp = new Element; |
dudnwjs | 0:a1f6b1ba8a1e | 36 | tmp->Data = vData; |
dudnwjs | 0:a1f6b1ba8a1e | 37 | tmp->Next = NULL; |
dudnwjs | 0:a1f6b1ba8a1e | 38 | ElemCnt++; |
dudnwjs | 0:a1f6b1ba8a1e | 39 | if( Front == NULL) |
dudnwjs | 0:a1f6b1ba8a1e | 40 | { |
dudnwjs | 0:a1f6b1ba8a1e | 41 | Front = tmp; |
dudnwjs | 0:a1f6b1ba8a1e | 42 | Rear = tmp; |
dudnwjs | 0:a1f6b1ba8a1e | 43 | }else |
dudnwjs | 0:a1f6b1ba8a1e | 44 | { |
dudnwjs | 0:a1f6b1ba8a1e | 45 | Rear->Next = tmp; |
dudnwjs | 0:a1f6b1ba8a1e | 46 | Rear = tmp; |
dudnwjs | 0:a1f6b1ba8a1e | 47 | } |
dudnwjs | 0:a1f6b1ba8a1e | 48 | } |
dudnwjs | 0:a1f6b1ba8a1e | 49 | |
dudnwjs | 1:5cf3a6c969be | 50 | void *MsgQueue::DeQueue(void) |
dudnwjs | 0:a1f6b1ba8a1e | 51 | { |
dudnwjs | 0:a1f6b1ba8a1e | 52 | void *tmp; |
dudnwjs | 0:a1f6b1ba8a1e | 53 | Element *tmpElem; |
dudnwjs | 0:a1f6b1ba8a1e | 54 | |
dudnwjs | 0:a1f6b1ba8a1e | 55 | if(Front == NULL) |
dudnwjs | 0:a1f6b1ba8a1e | 56 | return NULL; |
dudnwjs | 0:a1f6b1ba8a1e | 57 | |
dudnwjs | 0:a1f6b1ba8a1e | 58 | ElemCnt--; |
dudnwjs | 0:a1f6b1ba8a1e | 59 | tmpElem = Front; |
dudnwjs | 0:a1f6b1ba8a1e | 60 | Front = tmpElem->Next; |
dudnwjs | 0:a1f6b1ba8a1e | 61 | tmp = tmpElem->Data; |
dudnwjs | 0:a1f6b1ba8a1e | 62 | free(tmpElem); |
dudnwjs | 0:a1f6b1ba8a1e | 63 | |
dudnwjs | 0:a1f6b1ba8a1e | 64 | return tmp; |
dudnwjs | 0:a1f6b1ba8a1e | 65 | } |
dudnwjs | 0:a1f6b1ba8a1e | 66 | |
dudnwjs | 1:5cf3a6c969be | 67 | int MsgQueue::GetElementCount(void) |
dudnwjs | 0:a1f6b1ba8a1e | 68 | { |
dudnwjs | 0:a1f6b1ba8a1e | 69 | return ElemCnt; |
dudnwjs | 0:a1f6b1ba8a1e | 70 | } |
dudnwjs | 0:a1f6b1ba8a1e | 71 | |
dudnwjs | 1:5cf3a6c969be | 72 | bool MsgQueue::IsEmpty(void) |
dudnwjs | 0:a1f6b1ba8a1e | 73 | { |
dudnwjs | 0:a1f6b1ba8a1e | 74 | if( Front == NULL) |
dudnwjs | 0:a1f6b1ba8a1e | 75 | return false; |
dudnwjs | 0:a1f6b1ba8a1e | 76 | else |
dudnwjs | 0:a1f6b1ba8a1e | 77 | return true; |
dudnwjs | 0:a1f6b1ba8a1e | 78 | } |
dudnwjs | 0:a1f6b1ba8a1e | 79 | |
dudnwjs | 0:a1f6b1ba8a1e | 80 | }//namespace |