SHORE API
Main Page
Namespaces
Classes
Files
File List
File Members
SHORE API
Namespaces
Classes
Files
File List
shore
algo
base
container
datatype
fmtio
parallel
processing
buffer_chain.hpp
extractor.hpp
feed.hpp
filter.hpp
merge.hpp
method_check.hpp
monolithic_source.hpp
pipe_box.hpp
pipeline.hpp
plugin.hpp
signalslot.hpp
program
statistics
stream
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
extractor.hpp
Go to the documentation of this file.
1
2
/*
3
* Copyright 2008,2009,2010,2011,2012 Stephan Ossowski, Korbinian Schneeberger,
4
* Felix Ott, Joerg Hagmann, Alf Scotland, Sebastian Bender
5
*
6
* This file is part of SHORE.
7
*
8
* SHORE is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
12
*
13
* SHORE is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with SHORE. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
25
26
#ifndef SHORE_PROCESSING_EXTRACTOR_HPP__
27
#define SHORE_PROCESSING_EXTRACTOR_HPP__
28
29
30
#include "
signalslot.hpp
"
31
#include "
pipeline.hpp
"
32
33
namespace
shore {
34
36
template
<
typename
T>
37
class
extractor
38
{
39
private
:
40
41
class
rawsink
42
{
43
private
:
44
45
friend
class
extractor
;
46
47
sink<rawsink,T>
* m_sink;
48
const
T* m_data;
49
50
public
:
51
52
typedef
T append_type;
53
54
rawsink()
55
:m_data(0)
56
{}
57
58
void
append(
const
T& v)
59
{
60
if
(m_data!=0)
61
throw
std::logic_error(
"extractor: suffocated"
);
62
m_data=&v;
63
m_sink->sigfreeze().emit();
64
}
65
66
void
flush()
67
{}
68
};
69
70
sink<rawsink,T>
m_sink;
71
72
public
:
73
74
typedef
T append_type;
75
typedef
T current_type;
76
77
extractor
()
78
{
79
m_sink->m_sink=&m_sink;
80
}
81
82
const
T& current()
const
83
{
84
return
*(m_sink->m_data);
85
}
86
87
bool
has_data()
88
{
89
if
((m_sink->m_data)==0)
90
m_sink.sigthaw().
emit
();
91
return
(m_sink->m_data)!=0;
92
}
93
94
void
next()
95
{
96
(m_sink->m_data)=0;
97
m_sink.sigthaw().
emit
();
98
}
99
100
slot<const append_type&>
& slotdata()
101
{
102
return
m_sink.slotdata();
103
}
104
105
slot<void>
& slotflush()
106
{
107
return
m_sink.slotflush();
108
}
109
110
signal<void>
& sigfreeze()
111
{
112
return
m_sink.sigfreeze();
113
}
114
115
signal<void>
& sigthaw()
116
{
117
return
m_sink.sigthaw();
118
}
119
};
120
121
}
//namespace shore
122
123
#endif // SHORE_PROCESSING_EXTRACTOR_HPP__
124
shore
processing
extractor.hpp
Generated on Thu Jun 20 2013 15:49:39 for SHORE API by
1.8.4