sevencore fota solution development project
ext_fota/MsgQueue.cpp
- Committer:
- dudnwjs
- Date:
- 2015-08-20
- Revision:
- 8:9eec2c246a85
- Parent:
- 1:5cf3a6c969be
- Child:
- 9:fcf91f563147
File content as of revision 8:9eec2c246a85:
/** * @file MsgQueue.cpp * @brief Ble message queue * Copyright 2015 SEVENCORE Co., Ltd. * * @author HyeongJun Kim * @version 1.0.0 * @date 2015-08-19 */ #include "MsgQueue.h" #include "mbed.h" /** **************************************************************************************** * @addtogroup ext_fota module * @brief Ble message Queue Class Method Definition. * * @{ **************************************************************************************** */ namespace sevencore_fota{ MsgQueue::MsgQueue(int MaxSize):MaxNum(MaxSize) { Front = NULL; Rear = NULL; ElemCnt = 0; } MsgQueue::~MsgQueue(void) { } void MsgQueue::EnQueue(void *vData) { Element *tmp = new Element; tmp->Data = vData; tmp->Next = NULL; ElemCnt++; if( Front == NULL) { Front = tmp; Rear = tmp; }else { Rear->Next = tmp; Rear = tmp; } } void *MsgQueue::DeQueue(void) { void *tmp; Element *tmpElem; if(Front == NULL) return NULL; ElemCnt--; tmpElem = Front; Front = tmpElem->Next; tmp = tmpElem->Data; free(tmpElem); return tmp; } int MsgQueue::GetElementCount(void) { return ElemCnt; } bool MsgQueue::IsEmpty(void) { if( Front == NULL) return false; else return true; } }//namespace