32 #include <bpipe/bpipe.h>
33 #include <bpipe/datatypes.h>
35 #include <Exception/Exception.h>
54 template<
typename T >
70 HdrF(
const char* cname, T idatum );
76 T*
data() {
return &datum; }
93 template<
typename T >
106 DpktF(
const char* cname );
118 Simple(
const string& input,
const string& output );
135 if ( bpipe_hdrf_add( _bpipe, field.name.c_str(),
136 field.BPT, field.matrix,
137 field.
data(), field.copy ) )
138 throw Exception( bpipe_strerror( bpipe_errno ) );
156 int res = bpipe_dpktf_add( _bpipe, field.name.c_str(),
157 field.BPT, field.matrix );
159 throw Exception( bpipe_strerror( bpipe_errno ) );
163 DpktField *dpktf = bpipe_dpktf( _bpipe, field.name.c_str() );
166 throw Exception(
string(
"internal error: " ) + field.name +
"should exist but doesn't" );
168 if ( bpipe_dpktf_type( dpktf) != field.BPT ) {
169 ostringstream errstr;
170 errstr <<
"requested type of " << field.name <<
"(" << field.BPT <<
")"
171 <<
"not equal to type of existing field" <<
"(" << bpipe_dpktf_type( dpktf ) <<
")";
173 throw Exception( errstr.str() );
181 void delete_hdrf(
const char* name,
size_t index=BPHdrfIdx_ALL );
182 void delete_dpktf(
const char* name,
183 BPDataSite site = BPDSite_OUTPUT,
184 BPipeOutput *channel = BPOutputChannel_ALL );
187 bool has_hdrf(
const char* name,
size_t index=BPHdrfIdx_LAST );
188 bool has_dpktf(
const char* name );
204 DpktField *dpktf = bpipe_dpktf( _bpipe, name );
207 throw Exception(
string(
"non-existent data packet field: ") + name );
209 return static_cast<T*
>(
static_cast<void*
>( bpipe_dpktf_data( dpktf, core_image ) ) );
223 T*
hdrf_data(
const char* name,
size_t idx = BPHdrfIdx_LAST ) {
225 void *data = bpipe_hdrf_data( _bpipe, name, idx );
228 throw Exception(
string(
"non-existent data packet field: ") + name );
230 return static_cast<T*
>( data );
232 void map(
int npkts = 1 );
234 size_t read_dpkts ();
238 void write_dpkts( BPipeOutput* bpo = BPOutputChannel_ALL );
240 BPipe* bpipe( ) {
return _bpipe ; }
244 std::vector< BPipeOutput* > bpo;
248 size_t core_image_size;
258 #endif // ! BPIPEXX_H