Forked from LibPN532

Dependents:   NFC_Secure_Access NFC_Secure_Access

Fork of LibPN532 by dotnfc Tang

Committer:
udareaniket
Date:
Sun Apr 22 23:29:20 2018 +0000
Revision:
2:9a2ab3fa7862
Parent:
0:db8030e71f55
Initial commit;

Who changed what in which revision?

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