Library for Bluetooth Low Energy Module ble 4.0 HM-11

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Buffer.cpp Source File

Buffer.cpp

Go to the documentation of this file.
00001 
00002 /**
00003  * @file    Buffer.cpp
00004  * @brief   Software Buffer - Templated Ring Buffer for most data types
00005  * @author  sam grove
00006  * @version 1.0
00007  * @see     
00008  *
00009  * Copyright (c) 2013
00010  *
00011  * Licensed under the Apache License, Version 2.0 (the "License");
00012  * you may not use this file except in compliance with the License.
00013  * You may obtain a copy of the License at
00014  *
00015  *     http://www.apache.org/licenses/LICENSE-2.0
00016  *
00017  * Unless required by applicable law or agreed to in writing, software
00018  * distributed under the License is distributed on an "AS IS" BASIS,
00019  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020  * See the License for the specific language governing permissions and
00021  * limitations under the License.
00022  */
00023  
00024 #include "Buffer.h"
00025 
00026 template <class T>
00027 Buffer<T>::Buffer(uint32_t size)
00028 {
00029     _buf = new T [size];
00030     _size = size;
00031     clear();
00032     
00033     return;
00034 }
00035 
00036 template <class T>
00037 Buffer<T>::~Buffer()
00038 {
00039     delete [] _buf;
00040     
00041     return;
00042 }
00043 
00044 template <class T>
00045 uint32_t Buffer<T>::getSize() 
00046 { 
00047     return this->_size; 
00048 }
00049 
00050 template <class T>
00051 void Buffer<T>::clear(void)
00052 {
00053     _wloc = 0;
00054     _rloc = 0;
00055     memset(_buf, 0, _size);
00056     
00057     return;
00058 }
00059 
00060 template <class T>
00061 uint32_t Buffer<T>::peek(char c)
00062 {
00063     return 1;
00064 }
00065 
00066 // make the linker aware of some possible types
00067 template class Buffer<uint8_t>;
00068 template class Buffer<int8_t>;
00069 template class Buffer<uint16_t>;
00070 template class Buffer<int16_t>;
00071 template class Buffer<uint32_t>;
00072 template class Buffer<int32_t>;
00073 template class Buffer<uint64_t>;
00074 template class Buffer<int64_t>;
00075 template class Buffer<char> ;
00076 template class Buffer<wchar_t>;