Main Page
Namespaces
Classes
Files
File List
File Members
src
ros_lib
BufferedSerial
Buffer
Buffer.h
Go to the documentation of this file.
1
24
#ifndef BUFFER_H
25
#define BUFFER_H
26
27
#include <stdint.h>
28
#include <string.h>
29
60
template
<
typename
T>
61
class
Buffer
62
{
63
private
:
64
T *
_buf
;
65
volatile
uint32_t
_wloc
;
66
volatile
uint32_t
_rloc
;
67
uint32_t
_size
;
68
69
public
:
73
Buffer
(uint32_t size = 0x100);
74
78
uint32_t
getSize
();
79
82
~Buffer
();
83
87
void
put
(T data);
88
92
T
get
(void);
93
97
T *
head
(
void
);
98
101
void
clear
(
void
);
102
106
uint32_t
available
(
void
);
107
112
Buffer
&
operator=
(T data)
113
{
114
put
(data);
115
return
*
this
;
116
}
117
121
operator
int(
void
)
122
{
123
return
get
();
124
}
125
126
uint32_t
peek
(
char
c);
127
128
};
129
130
template
<
class
T>
131
inline
void
Buffer<T>::put
(T data)
132
{
133
_buf
[
_wloc
++] = data;
134
_wloc
%= (
_size
-1);
135
136
return
;
137
}
138
139
template
<
class
T>
140
inline
T
Buffer<T>::get
(
void
)
141
{
142
T data_pos =
_buf
[
_rloc
++];
143
_rloc
%= (
_size
-1);
144
145
return
data_pos;
146
}
147
148
template
<
class
T>
149
inline
T *
Buffer<T>::head
(
void
)
150
{
151
T *data_pos = &
_buf
[0];
152
153
return
data_pos;
154
}
155
156
template
<
class
T>
157
inline
uint32_t
Buffer<T>::available
(
void
)
158
{
159
return
(
_wloc
==
_rloc
) ? 0 : 1;
160
}
161
162
#endif
163
Buffer::Buffer
Buffer(uint32_t size=0x100)
Definition:
Buffer.cpp:27
Buffer::operator=
Buffer & operator=(T data)
Definition:
Buffer.h:112
Buffer::peek
uint32_t peek(char c)
Definition:
Buffer.cpp:61
Buffer::put
void put(T data)
Definition:
Buffer.h:131
Buffer::getSize
uint32_t getSize()
Definition:
Buffer.cpp:45
Buffer::available
uint32_t available(void)
Definition:
Buffer.h:157
Buffer
Definition:
Buffer.h:61
Buffer::head
T * head(void)
Definition:
Buffer.h:149
Buffer::~Buffer
~Buffer()
Definition:
Buffer.cpp:37
Buffer::_size
uint32_t _size
Definition:
Buffer.h:67
Buffer::clear
void clear(void)
Definition:
Buffer.cpp:51
Buffer::_buf
T * _buf
Definition:
Buffer.h:64
Buffer::_wloc
volatile uint32_t _wloc
Definition:
Buffer.h:65
Buffer::_rloc
volatile uint32_t _rloc
Definition:
Buffer.h:66
Buffer::get
T get(void)
Definition:
Buffer.h:140
rosserial_mbed
Author(s): Gary Servin
autogenerated on Mon Jun 10 2019 14:53:26