Skip to content

Commit

Permalink
Add identifiers to Reader, pass to openScopeFile
Browse files Browse the repository at this point in the history
  • Loading branch information
kfish committed Mar 26, 2012
1 parent e552cd3 commit 712ef30
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Scope/Layer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ genColors n rgb a = MWC.withSystemRandom (replicateM n . genColor rgb a)
scopeBufSize :: Int
scopeBufSize = 1024

openScopeFile :: FilePath -> IO ScopeFile
openScopeFile path = do
openScopeFile :: ScopeRead -> FilePath -> IO ScopeFile
openScopeFile (ScopeRead ReadMethods{..}) path = do
fd <- openFd path ReadOnly Nothing defaultFileFlags
let f = ScopeFile path fd undefined
cf <- scopeEnum f (iterHeaders standardIdentifiers)
cf <- scopeEnum f (iterHeaders readIdentifiers)
return f{scopeCF = cf}

scopeEnum :: ScopeRender m => ScopeFile -> I.Iteratee (Offset ByteString) m a -> m a
Expand Down Expand Up @@ -113,7 +113,7 @@ layersFromFile (ScopeRead ReadMethods{..}) file@ScopeFile{..} = do

addLayersFromFile :: ScopeRead -> FilePath -> Scope ui -> IO (Scope ui)
addLayersFromFile reader path scope = do
(newLayers, newBounds, newUTCBounds) <- layersFromFile reader =<< openScopeFile path
(newLayers, newBounds, newUTCBounds) <- layersFromFile reader =<< openScopeFile reader path
let scope' = scopeUpdate newBounds newUTCBounds scope
return $ scope' { layers = layers scope ++ newLayers }

Expand Down
4 changes: 3 additions & 1 deletion Scope/Numeric/IEEE754.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ instance ScopePlot Double where
rawLayerPlot = rawLayerPlotListDouble
summaryLayerPlot = summaryLayerPlotListDouble

----------------------------------------------------------------------

-- | ScopeRead methods to interpret numeric data as Double
scopeReadDouble :: ScopeRead
scopeReadDouble = ScopeRead (ReadMethods extentsDouble enumListDouble (enumSummaryListDouble 1))
scopeReadDouble = ScopeRead (ReadMethods standardIdentifiers extentsDouble enumListDouble (enumSummaryListDouble 1))

extentsDouble :: (Functor m, MonadIO m)
=> TrackNo -> Iteratee [Offset Block] m LayerExtents
Expand Down
3 changes: 2 additions & 1 deletion Scope/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ class ScopePlot a where
----------------------------------------------------------------------

data ReadMethods a = ReadMethods
{ readExtents :: forall m . (Functor m, MonadIO m) => TrackNo -> Iteratee [Offset Block] m LayerExtents
{ readIdentifiers :: [IdentifyCodec]
, readExtents :: forall m . (Functor m, MonadIO m) => TrackNo -> Iteratee [Offset Block] m LayerExtents
, rawConvEnee :: forall m . (Functor m, Monad m) => Enumeratee [Offset Block] [(TimeStamp, [a])] m ()
, summaryConvEnee :: forall m . (Functor m, Monad m) => Enumeratee [Offset Block] [[Summary a]] m ()
}
Expand Down

0 comments on commit 712ef30

Please sign in to comment.