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