Open Lighting Architecture
0.9.3
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
70
void
Clear
();
71
72
// purge the underlying memory pool
73
void
Purge();
74
75
void
Dump
(std::ostream *output);
76
77
private
:
78
typedef
std::deque<class MemoryBlock*> BlockVector;
79
80
class
MemoryBlockPool
* m_pool;
81
bool
m_delete_pool;
82
83
BlockVector m_blocks;
84
85
void
AppendBlock();
86
87
// no copying / assignment for now
88
IOQueue
(
const
IOQueue
&);
89
IOQueue
& operator=(
const
IOQueue
&);
90
};
91
}
// namespace io
92
}
// namespace ola
93
#endif // INCLUDE_OLA_IO_IOQUEUE_H_
Generated on Sun Nov 16 2014 15:43:10 for Open Lighting Architecture by
1.8.1.2