3.2 Data packet data fields
Data fields in data packets are a bit more complicated to work with.
Data packet field names must be unique. Data packets actually
pass through three states as they are processed by the bpipe
library:
- input
- The image of the data packet as it exists in the
input data stream.
- core
- The image of the data packet in memory, in the form available to the
program. This may differ from the input image because of additions,
deletions, or resizes of data fields requested by the program
- output
- The image of the data packet as written to the output stream. It may
differ from the core image if the program has requested field deletions
or resizing. Each output stream may have a different set of field
deletions or resizes and thus different output images.
The program has great flexibility in determining how data packet fields
are passed on. A few scenarios may provide illumination:
- The program simulates a detector, and accepts photons which have been
projected to a given axial station. Since it no longer needs the
direction cosines, it requests that they be deleted from the core image.
Subsequent calculations require only percent polarization, so the full
polarization information need not be output. It thus creates a new data
field for the summary information in the core image, and requests that
the full polarization information be deleted from the output image.
- The program simulates a non-destructive beam mapper, recording the
position and energy of photons at a particular axial station. Since it
is non-destructive, it must pass on all of the information for each
photon. The only information required for the diagnostic output is the
photon's position and energy. It thus creates two output streams, and
directs the interface routines to delete all but the position and energy
from the output image for the diagnostic output stream, leaving the
other stream as a carbon copy of the input.
The bpipe
library takes care of the transformations from one
state to the next. There are a few simple rules for the data packet
field manipulations:
- additions are made to the core image only
- deletions are made to the input image and the core image
- deletions or resizes of the input image's fields are performed before
the program has accessed the data packet
- deletions or resizes of the core image's fields are made when the
core image is written to the output streams.
All manipulations of data packet field definitions take place before
any data packets are passed to the application by the bpipe
interface. Because all packets on a data stream have the same format,
the definitions must be frozen before reading and writing data
packets.