Portability | unknown |
---|---|
Stability | unstable |
Maintainer | Conrad Parker <conrad@metadecks.org> |
API for implementing ZoomCache applications
- data TimeStamp = TS {}
- type TrackNo = Int
- data Codec = forall a . ZoomReadable a => Codec a
- type IdentifyCodec = ByteString -> Maybe Codec
- data DataRateType
- = ConstantDR
- | VariableDR
- data CacheFile = CacheFile {}
- class Typeable a => ZoomReadable a where
- trackIdentifier :: a -> ByteString
- readRaw :: (Nullable s, ListLike s Word8, Functor m, MonadIO m) => Iteratee s m a
- readSummary :: (Nullable s, ListLike s Word8, Functor m, MonadIO m) => Iteratee s m (SummaryData a)
- prettyRaw :: a -> String
- prettySummaryData :: SummaryData a -> String
- data ZoomRaw = forall a . ZoomReadable a => ZoomRaw [a]
- data ZoomSummary = forall a . ZoomReadable a => ZoomSummary (Summary a)
- data Packet = Packet {
- packetTrack :: !TrackNo
- packetEntryTime :: !TimeStamp
- packetExitTime :: !TimeStamp
- packetCount :: !Int
- packetData :: !ZoomRaw
- packetTimeStamps :: ![TimeStamp]
- data Summary a = Summary {
- summaryTrack :: !TrackNo
- summaryLevel :: !Int
- summaryEntryTime :: !TimeStamp
- summaryExitTime :: !TimeStamp
- summaryData :: !(SummaryData a)
- type TrackMap = IntMap TrackSpec
- data TrackSpec = TrackSpec {
- specType :: !Codec
- specDRType :: !DataRateType
- specRate :: !Rational
- specName :: !ByteString
- class ZoomWrite t where
- type ZoomW = StateT ZoomWHandle IO
- withFileWrite :: TrackMap -> Bool -> ZoomW () -> FilePath -> IO ()
- flush :: ZoomW ()
- data ZoomWHandle
- openWrite :: TrackMap -> Bool -> FilePath -> IO ZoomWHandle
- closeWrite :: ZoomWHandle -> IO ()
- watermark :: TrackNo -> ZoomW (Maybe Int)
- setWatermark :: TrackNo -> Int -> ZoomW ()
- mkTrackSpec :: ZoomReadable a => a -> DataRateType -> Rational -> ByteString -> TrackSpec
- oneTrack :: ZoomReadable a => a -> DataRateType -> Rational -> ByteString -> TrackMap
- standardIdentifiers :: [IdentifyCodec]
- module Data.Iteratee.ZoomCache
- module Data.ZoomCache.Pretty
Types
type IdentifyCodec = ByteString -> Maybe CodecSource
Identify the tracktype corresponding to a given Codec Identifier.
When parsing a zoom-cache file, the zoom-cache library will try each
of a given list [IdentifyTrack
].
The standard zoom-cache instances are provided in standardIdentifiers
.
When developing your own codecs it is not necessary to build a composite
IdentifyTrack
functions; it is sufficient to generate one for each new
codec type. A library of related zoom-cache codecs should export its own
[IdentifyTrack
] functions, usually called something like mylibIdentifiers.
These can be generated with identifyCodec
.
data DataRateType Source
Constant or Variable datarate. For constant datarate, timestamps are implied as incrementing by 1/datarate For variable datarate, explicit timestamps are attached to each datum, encoded as a separate block of timestamps in the Raw Data packet.
Global and track headers for a zoom-cache file
class Typeable a => ZoomReadable a whereSource
A codec instance must specify a SummaryData
type,
and implement all methods of this class.
trackIdentifier :: a -> ByteStringSource
The track identifier used for streams of type a
.
The value of the argument should be ignored by any instance of
ZoomReadable
, so that is safe to pass undefined
as the
argument.
readRaw :: (Nullable s, ListLike s Word8, Functor m, MonadIO m) => Iteratee s m aSource
An iteratee to read one value of type a
from a stream of something
like '[Word8]' or ByteString
.
readSummary :: (Nullable s, ListLike s Word8, Functor m, MonadIO m) => Iteratee s m (SummaryData a)Source
An iteratee to read one value of type 'SummaryData a' from a stream
of something like '[Word8]' or ByteString
.
prettyRaw :: a -> StringSource
Pretty printing, used for dumping values of type a
.
prettySummaryData :: SummaryData a -> StringSource
Pretty printing for values of type 'SummaryData a'.
forall a . ZoomReadable a => ZoomRaw [a] |
data ZoomSummary Source
forall a . ZoomReadable a => ZoomSummary (Summary a) |
Packet | |
|
A recorded block of summary data
Summary | |
|
Track specification
A specification of the type and name of each track
TrackSpec | |
|
The ZoomWrite class
The ZoomWrite class provides write
, a method to write a
Haskell value to an open ZoomCache file.
The ZoomW monad
type ZoomW = StateT ZoomWHandle IOSource
A StateT IO monad for writing a ZoomCache file
:: TrackMap | |
-> Bool | Whether or not to write raw data packets. If False, only summary blocks are written. |
-> ZoomW () | |
-> FilePath | |
-> IO () |
Run a ZoomW ()
action on a given file handle, using the specified
TrackMap
specification
Force a flush of ZoomCache summary blocks to disk. It is not usually necessary to call this function as summary blocks are transparently written at regular intervals.
ZoomWHandle IO functions
data ZoomWHandle Source
:: TrackMap | |
-> Bool | Whether or not to write raw data packets. If False, only summary blocks are written. |
-> FilePath | |
-> IO ZoomWHandle |
Open a new ZoomCache file for writing, using a specified TrackMap
.
closeWrite :: ZoomWHandle -> IO ()Source
Watermarks
watermark :: TrackNo -> ZoomW (Maybe Int)Source
Query the maximum number of data points to buffer for a given track before forcing a flush of all buffered data and summaries.
setWatermark :: TrackNo -> Int -> ZoomW ()Source
Set the maximum number of data points to buffer for a given track before forcing a flush of all buffered data and summaries.
TrackSpec helpers
mkTrackSpec :: ZoomReadable a => a -> DataRateType -> Rational -> ByteString -> TrackSpecSource
oneTrack :: ZoomReadable a => a -> DataRateType -> Rational -> ByteString -> TrackMapSource
Create a track map for a stream of a given type, as track no. 1
Standard identifiers
standardIdentifiers :: [IdentifyCodec]Source
IdentifyTrack
functions provided for standard codecs provided
by the zoom-cache library.
Iteratee parsers
module Data.Iteratee.ZoomCache
Pretty printing
module Data.ZoomCache.Pretty