mayuresh bharmoria / Mbed OS mbed-os-example-wifi
Committer:
mayur098
Date:
Thu Jun 21 17:50:21 2018 +0000
Revision:
0:8f8e8f3cbd1c
first commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mayur098 0:8f8e8f3cbd1c 1
mayur098 0:8f8e8f3cbd1c 2 /**
mayur098 0:8f8e8f3cbd1c 3 * @file Buffer.cpp
mayur098 0:8f8e8f3cbd1c 4 * @brief Software Buffer - Templated Ring Buffer for most data types
mayur098 0:8f8e8f3cbd1c 5 * @author sam grove
mayur098 0:8f8e8f3cbd1c 6 * @version 1.0
mayur098 0:8f8e8f3cbd1c 7 * @see
mayur098 0:8f8e8f3cbd1c 8 *
mayur098 0:8f8e8f3cbd1c 9 * Copyright (c) 2013
mayur098 0:8f8e8f3cbd1c 10 *
mayur098 0:8f8e8f3cbd1c 11 * Licensed under the Apache License, Version 2.0 (the "License");
mayur098 0:8f8e8f3cbd1c 12 * you may not use this file except in compliance with the License.
mayur098 0:8f8e8f3cbd1c 13 * You may obtain a copy of the License at
mayur098 0:8f8e8f3cbd1c 14 *
mayur098 0:8f8e8f3cbd1c 15 * http://www.apache.org/licenses/LICENSE-2.0
mayur098 0:8f8e8f3cbd1c 16 *
mayur098 0:8f8e8f3cbd1c 17 * Unless required by applicable law or agreed to in writing, software
mayur098 0:8f8e8f3cbd1c 18 * distributed under the License is distributed on an "AS IS" BASIS,
mayur098 0:8f8e8f3cbd1c 19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mayur098 0:8f8e8f3cbd1c 20 * See the License for the specific language governing permissions and
mayur098 0:8f8e8f3cbd1c 21 * limitations under the License.
mayur098 0:8f8e8f3cbd1c 22 */
mayur098 0:8f8e8f3cbd1c 23
mayur098 0:8f8e8f3cbd1c 24 #include "MyBuffer.h"
mayur098 0:8f8e8f3cbd1c 25
mayur098 0:8f8e8f3cbd1c 26 template <class T>
mayur098 0:8f8e8f3cbd1c 27 MyBuffer<T>::MyBuffer(uint32_t size)
mayur098 0:8f8e8f3cbd1c 28 {
mayur098 0:8f8e8f3cbd1c 29 _buf = new T [size];
mayur098 0:8f8e8f3cbd1c 30 _size = size;
mayur098 0:8f8e8f3cbd1c 31 clear();
mayur098 0:8f8e8f3cbd1c 32
mayur098 0:8f8e8f3cbd1c 33 return;
mayur098 0:8f8e8f3cbd1c 34 }
mayur098 0:8f8e8f3cbd1c 35
mayur098 0:8f8e8f3cbd1c 36 template <class T>
mayur098 0:8f8e8f3cbd1c 37 MyBuffer<T>::~MyBuffer()
mayur098 0:8f8e8f3cbd1c 38 {
mayur098 0:8f8e8f3cbd1c 39 delete [] _buf;
mayur098 0:8f8e8f3cbd1c 40
mayur098 0:8f8e8f3cbd1c 41 return;
mayur098 0:8f8e8f3cbd1c 42 }
mayur098 0:8f8e8f3cbd1c 43
mayur098 0:8f8e8f3cbd1c 44 template <class T>
mayur098 0:8f8e8f3cbd1c 45 uint32_t MyBuffer<T>::getSize()
mayur098 0:8f8e8f3cbd1c 46 {
mayur098 0:8f8e8f3cbd1c 47 return this->_size;
mayur098 0:8f8e8f3cbd1c 48 }
mayur098 0:8f8e8f3cbd1c 49
mayur098 0:8f8e8f3cbd1c 50 template <class T>
mayur098 0:8f8e8f3cbd1c 51 void MyBuffer<T>::clear(void)
mayur098 0:8f8e8f3cbd1c 52 {
mayur098 0:8f8e8f3cbd1c 53 _wloc = 0;
mayur098 0:8f8e8f3cbd1c 54 _rloc = 0;
mayur098 0:8f8e8f3cbd1c 55 memset(_buf, 0, _size);
mayur098 0:8f8e8f3cbd1c 56
mayur098 0:8f8e8f3cbd1c 57 return;
mayur098 0:8f8e8f3cbd1c 58 }
mayur098 0:8f8e8f3cbd1c 59
mayur098 0:8f8e8f3cbd1c 60 template <class T>
mayur098 0:8f8e8f3cbd1c 61 uint32_t MyBuffer<T>::peek(char c)
mayur098 0:8f8e8f3cbd1c 62 {
mayur098 0:8f8e8f3cbd1c 63 return 1;
mayur098 0:8f8e8f3cbd1c 64 }
mayur098 0:8f8e8f3cbd1c 65
mayur098 0:8f8e8f3cbd1c 66 // make the linker aware of some possible types
mayur098 0:8f8e8f3cbd1c 67 template class MyBuffer<uint8_t>;
mayur098 0:8f8e8f3cbd1c 68 template class MyBuffer<int8_t>;
mayur098 0:8f8e8f3cbd1c 69 template class MyBuffer<uint16_t>;
mayur098 0:8f8e8f3cbd1c 70 template class MyBuffer<int16_t>;
mayur098 0:8f8e8f3cbd1c 71 template class MyBuffer<uint32_t>;
mayur098 0:8f8e8f3cbd1c 72 template class MyBuffer<int32_t>;
mayur098 0:8f8e8f3cbd1c 73 template class MyBuffer<uint64_t>;
mayur098 0:8f8e8f3cbd1c 74 template class MyBuffer<int64_t>;
mayur098 0:8f8e8f3cbd1c 75 template class MyBuffer<char>;
mayur098 0:8f8e8f3cbd1c 76 template class MyBuffer<wchar_t>;