Open Lighting Architecture
0.9.6
Main Page
Modules
Related Pages
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
ola
io
IOQueue.h
1
/*
2
* This library is free software; you can redistribute it and/or
3
* modify it under the terms of the GNU Lesser General Public
4
* License as published by the Free Software Foundation; either
5
* version 2.1 of the License, or (at your option) any later version.
6
*
7
* This library is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
* Lesser General Public License for more details.
11
*
12
* You should have received a copy of the GNU Lesser General Public
13
* License along with this library; if not, write to the Free Software
14
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
*
16
* IOQueue.h
17
* A non-contigous memory buffer that operates as a queue (FIFO).
18
* Copyright (C) 2012 Simon Newton
19
*/
20
21
#ifndef INCLUDE_OLA_IO_IOQUEUE_H_
22
#define INCLUDE_OLA_IO_IOQUEUE_H_
23
24
#include <ola/io/IOVecInterface.h>
25
#include <ola/io/InputBuffer.h>
26
#include <ola/io/OutputBuffer.h>
27
#include <stdint.h>
28
#include <deque>
29
#include <iostream>
30
#include <queue>
31
#include <string>
32
33
namespace
ola {
34
namespace
io {
35
39
class
IOQueue
:
public
InputBufferInterface
,
40
public
OutputBufferInterface
,
41
public
IOVecInterface
{
42
public
:
43
IOQueue
();
44
explicit
IOQueue
(
class
MemoryBlockPool
*block_pool);
45
46
~IOQueue
();
47
48
unsigned
int
Size
()
const
;
49
50
bool
Empty()
const
{
51
return
m_blocks.empty();
52
}
53
54
// From OutputBuffer
55
void
Write
(
const
uint8_t *data,
unsigned
int
length);
56
57
// From InputBuffer, these reads consume data from the buffer.
58
unsigned
int
Read
(uint8_t *data,
unsigned
int
length);
59
unsigned
int
Read
(std::string *output,
unsigned
int
length);
60
61
unsigned
int
Peek
(uint8_t *data,
unsigned
int
length)
const
;
62
63
// From IOVecInterface
64
const
struct
IOVec
*
AsIOVec
(
int
*io_count)
const
;
65
void
Pop
(
unsigned
int
n);
66
67
// Append a MemoryBlock to this IOQueue. Ownership of the block is taken.
68
void
AppendBlock
(
class
MemoryBlock
*block);
69
74
void
AppendMove
(
IOQueue
*other);
75
76
void
Clear
();
77
78
// purge the underlying memory pool
79
void
Purge();
80
81
void
Dump
(std::ostream *output);
82
83
private
:
84
typedef
std::deque<class MemoryBlock*> BlockVector;
85
86
class
MemoryBlockPool
* m_pool;
87
bool
m_delete_pool;
88
89
BlockVector m_blocks;
90
91
void
AppendBlock();
92
93
// no copying / assignment for now
94
IOQueue
(
const
IOQueue
&);
95
IOQueue
& operator=(
const
IOQueue
&);
96
};
97
}
// namespace io
98
}
// namespace ola
99
#endif // INCLUDE_OLA_IO_IOQUEUE_H_
Generated on Fri Jul 3 2015 15:58:45 for Open Lighting Architecture by
1.8.1.2