bpipexx
1.0.6_01
|
#include <bpipexx/bpipexx.h>
Public Member Functions | |
~Simple () | |
Destructor. More... | |
Simple () | |
Constructor. More... | |
Simple (const string &input, const string &output) | |
Constructor specifying input and output streams. More... | |
template<typename T > | |
void | add (HdrF< T > field) |
add a header field More... | |
template<typename T > | |
void | add (const DpktF< T > &field) |
add a data packet field More... | |
void | delete_hdrf (const char *name, size_t index=BPHdrfIdx_ALL) |
delete a header field More... | |
void | delete_dpktf (const char *name, BPDataSite site=BPDSite_OUTPUT, BPipeOutput *channel=BPOutputChannel_ALL) |
delete a data packet field More... | |
bool | has_hdrf (const char *name, size_t index=BPHdrfIdx_LAST) |
test if a header field exists More... | |
bool | has_dpktf (const char *name) |
test if a data packet field exists More... | |
template<typename T > | |
T * | dpktf_data (const char *name) |
get a pointer to the data in a data packet field More... | |
template<typename T > | |
T * | hdrf_data (const char *name, size_t idx=BPHdrfIdx_LAST) |
get a pointer to the data in a header packet field More... | |
void | map (int npkts=1) |
map the data packet fields onto memory. More... | |
size_t | read_dpkts () |
read in the next batch of data packets More... | |
void | write_hdr () |
write the output header More... | |
void | write_dpkts (BPipeOutput *bpo=BPOutputChannel_ALL) |
write a data packet More... | |
BPipe * | bpipe () |
A simple wrapper class providing optimized access to a binary pipe object.
The easiest means to create an object manipulating bpipe streams is to use the two argument constructor:
In this case it opens an output stream, but no input stream, suitable for a ray generater. For a filter, specify both streams, for a sink, specify only the input stream.
For more complex situations, don't specify any streams, and use the bpipe
accessor to manipulate the underlying bpipe
object directly:
Recall that the header accepts multiple fields with the same name.
The first step is to create a BPipeX::HdrF
object, then pass it to the add
method. The steps can be combined:
To delete a header field, use delete_hdrf:
Recall that the data packets can have only one field with a given name.
The first step is to create a BPipeX::DpktF
object, then pass it to the add
method. The steps can be combined:
To delete a data packet field from the output, use delete_dpktf:
See the documentation for delete_dpktf
for more complex use.
After all fields are created, the packet images must be mapped:
To access the location in the core image for a data packet field, use dpktf_data:
For filters or sinks, make sure to write the header prior to outputing any data packets:
Use read_dpkts
and write_dpkts
to read and write.
The streams will be closed upon destruction of the BPipeX::Simple
object.
SAOTrace::BPipeX::Simple::~Simple | ( | ) |
Destructor.
Destroy a BPipeX::Simple object, closing the associated output streams.
SAOTrace::BPipeX::Simple::Simple | ( | ) |
Constructor.
Construct the underlying bpipe
object without attaching any streams
SAOTrace::BPipeX::Simple::Simple | ( | const string & | input, |
const string & | output | ||
) |
Constructor specifying input and output streams.
Either of the parameters may be an empty string, indicating that that stream should not be attached.
[in] | input | the name of the input stream (may be stdin ) |
[in] | output | the name of the input stream (may be stdout ) |
Exception | if it is unable to attach the streams. |
|
inline |
add a header field
For example:
[in] | field | A BPipeX::HdrF object |
Exception | if unable to create the header field |
References SAOTrace::BPipeX::HdrF< T >::data().
|
inline |
add a data packet field
For example:
[in] | field | A BPipeX::DpktF object |
Exception | if unable to create the data packet field or the field exists with a different data type. |
void SAOTrace::BPipeX::Simple::delete_dpktf | ( | const char * | name, |
BPDataSite | site = BPDSite_OUTPUT , |
||
BPipeOutput * | channel = BPOutputChannel_ALL |
||
) |
delete a data packet field
Deletes the specified data packet field. By default the field is removed from the output image of all output channels. Set the site
parameter to change the data site or the channel
parameter to specify an alternate output channel
[in] | name | the name of the field to delete |
[in] | site | the optional data site in which to delete it. This may be one of
|
[in] | channel | optional channel output channel to delete from |
Exception | if there is an error |
void SAOTrace::BPipeX::Simple::delete_hdrf | ( | const char * | name, |
size_t | index = BPHdrfIdx_ALL |
||
) |
delete a header field
Deletes the specified header field. By default it will delete all header fields with the given name. Set the index
parameter to either the index of field to delete, or to BPHdrfIdx_LAST
to delete the last one.
[in] | name | the name of the field to delete |
[in] | index | the optional index of the field to delete. |
Exception | if there is an error |
|
inline |
get a pointer to the data in a data packet field
For example:
T | the type of the stored data. |
[in] | name | the name of the data packet field. |
bool SAOTrace::BPipeX::Simple::has_dpktf | ( | const char * | name) |
test if a data packet field exists
[in] | name | the name of the field |
true
if the field exists bool SAOTrace::BPipeX::Simple::has_hdrf | ( | const char * | name, |
size_t | index = BPHdrfIdx_LAST |
||
) |
test if a header field exists
[in] | name | the name of the field |
[in] | index | the optional index of the field to delete. Defaults to BPHdrfIdx_LAST |
true
if the field exists
|
inline |
get a pointer to the data in a header packet field
For example:
T | the type of the stored data. |
[in] | name | the name of the data packet field. |
[in] | idx | the index of the field. Defaults to the last one. |
void SAOTrace::BPipeX::Simple::map | ( | int | npkts = 1 ) |
map the data packet fields onto memory.
This function maps the data packet fields onto memory and allocates space for the images.
[in] | npkts | the optional number of packets to allocate space for. defaults to 1 |
Exception | if it is unable to allocate the image. |
size_t SAOTrace::BPipeX::Simple::read_dpkts | ( | ) |
read in the next batch of data packets
Read in the number of data packets specified by the map
method.
Exception | if there is an error reading the input stream |
void SAOTrace::BPipeX::Simple::write_dpkts | ( | BPipeOutput * | bpo = BPOutputChannel_ALL ) |
write a data packet
Writes a data packet to one or all output channels.
[in] | bpo | the optional output channel to write to. Defaults to writing to all output channels. |
Exception | if there is an error |
void SAOTrace::BPipeX::Simple::write_hdr | ( | ) |
write the output header
Writes header information to the output channels
Exception | if there is an error |