GNU Radio 3.6.4.1 C++ API
gr_vmcircbuf.h
Go to the documentation of this file.
1
/* -*- c++ -*- */
2
/*
3
* Copyright 2003 Free Software Foundation, Inc.
4
*
5
* This file is part of GNU Radio
6
*
7
* GNU Radio is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 3, or (at your option)
10
* any later version.
11
*
12
* GNU Radio is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with GNU Radio; see the file COPYING. If not, write to
19
* the Free Software Foundation, Inc., 51 Franklin Street,
20
* Boston, MA 02110-1301, USA.
21
*/
22
23
#ifndef _GR_VMCIRCBUF_H_
24
#define _GR_VMCIRCBUF_H_
25
26
#include <
gr_core_api.h
>
27
#include <vector>
28
29
/*!
30
* \brief abstract class to implement doubly mapped virtual memory circular buffers
31
* \ingroup internal
32
*/
33
class
GR_CORE_API
gr_vmcircbuf
{
34
protected
:
35
int
d_size
;
36
char
*
d_base
;
37
38
// CREATORS
39
gr_vmcircbuf
(
int
size) : d_size (size), d_base (0) {};
40
41
public
:
42
virtual
~
gr_vmcircbuf
();
43
44
// ACCESSORS
45
void
*
pointer_to_first_copy
()
const
{
return
d_base; }
46
void
*
pointer_to_second_copy
()
const
{
return
d_base + d_size; }
47
};
48
49
/*!
50
* \brief abstract factory for creating circular buffers
51
*/
52
class
GR_CORE_API
gr_vmcircbuf_factory
{
53
protected
:
54
gr_vmcircbuf_factory
() {};
55
virtual
~
gr_vmcircbuf_factory
();
56
57
public
:
58
59
/*!
60
* \brief return name of this factory
61
*/
62
virtual
const
char
*
name
()
const
= 0;
63
64
/*!
65
* \brief return granularity of mapping, typically equal to page size
66
*/
67
virtual
int
granularity () = 0;
68
69
/*!
70
* \brief return a gr_vmcircbuf, or 0 if unable.
71
*
72
* Call this to create a doubly mapped circular buffer.
73
*/
74
virtual
gr_vmcircbuf
*make (
int
size) = 0;
75
};
76
77
/*
78
* \brief pulls together all implementations of gr_vmcircbuf
79
*/
80
class
GR_CORE_API
gr_vmcircbuf_sysconfig
{
81
public
:
82
83
/*
84
* \brief return the single instance of the default factory.
85
*
86
* returns the default factory to use if it's already defined,
87
* else find the first working factory and use it.
88
*/
89
static
gr_vmcircbuf_factory
*get_default_factory ();
90
91
92
static
int
granularity
() {
return
get_default_factory()->
granularity
(); }
93
static
gr_vmcircbuf
*
make
(
int
size) {
return
get_default_factory()->
make
(size); }
94
95
96
// N.B. not all factories are guaranteed to work.
97
// It's too hard to check everything at config time, so we check at runtime
98
static
std::vector<gr_vmcircbuf_factory *> all_factories ();
99
100
// make this factory the default
101
static
void
set_default_factory (
gr_vmcircbuf_factory
*f);
102
103
/*!
104
* \brief Does this factory really work?
105
*
106
* verbose = 0: silent
107
* verbose = 1: names of factories tested and results
108
* verbose = 2: all intermediate results
109
*/
110
static
bool
test_factory (
gr_vmcircbuf_factory
*f,
int
verbose);
111
112
/*!
113
* \brief Test all factories, return true if at least one of them works
114
* verbose = 0: silent
115
* verbose = 1: names of factories tested and results
116
* verbose = 2: all intermediate results
117
*/
118
static
bool
test_all_factories (
int
verbose);
119
};
120
121
122
#endif
/* _GR_VMCIRCBUF_H_ */
gnuradio
gnuradio-core
src
lib
runtime
gr_vmcircbuf.h
Generated by
1.8.1.2