X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=hs-rrdtool.git;a=blobdiff_plain;f=Database%2FRRDtool%2FCreate.hs;h=5dd3b9f8fc12aadee9c64bef068dd335ee99b289;hp=3c403db46f99de5ad8af3c9bfb41b90145692361;hb=2787678974b80d73e91b49b6b7c5469c6eb5ac1e;hpb=f34eed5749bdaf7ff7b33230557b30115ae343f3 diff --git a/Database/RRDtool/Create.hs b/Database/RRDtool/Create.hs index 3c403db..5dd3b9f 100644 --- a/Database/RRDtool/Create.hs +++ b/Database/RRDtool/Create.hs @@ -1,4 +1,6 @@ {-# LANGUAGE + FlexibleContexts, + FlexibleInstances, TypeFamilies, UndecidableInstances #-} @@ -10,7 +12,7 @@ module Database.RRDtool.Create , createRRD -- Data.HList - , (.*.) + , (.&.) , HNil(..) -- Database.RRDtool.Expression @@ -173,22 +175,39 @@ dsTest = ComputedDataSource { } -} +-- |The name of the RRD you want to create. RRD files should end with +-- the extension @.rrd@. However, RRDtool will accept any filename. +newtype RRDPath = RRDPath FilePath + +-- |Do not clobber an existing file of the same name. +data KeepOldRRD = KeepOldRRD + +-- |Specifies the time in seconds since @1970-01-01 UTC@ when the +-- first value should be added to the RRD. RRDtool will not accept any +-- data timed before or at the time specified. (default: @now - 10s@) +newtype RRDStartTime = RRDStartTime POSIXTime + +-- |Specifies the base interval in seconds with which data will be fed +-- into the RRD. (default: 300 sec) +newtype RRDInterval = RRDInterval NominalDiffTime + +class RRDSpec s +instance ( HOccurs RRDPath s + , HOccursOpt KeepOldRRD s + , HOccursOpt RRDStartTime s + , HOccursOpt RRDInterval s + ) + => RRDSpec s + -- |The 'createRRD' function lets you set up new Round Robin Database -- (RRD) files. The file is created at its final, full size and filled -- with @*UNKNOWN*@ data. -createRRD - :: FilePath -- ^The name of the RRD you want to create. RRD files - -- should end with the extension @.rrd@. However, - -- RRDtool will accept any filename. - -> Bool -- ^Do not clobber an existing file of the same name. - -> Maybe POSIXTime -- ^Specifies the time in seconds since - -- @1970-01-01 UTC@ when the first value should - -- be added to the RRD. RRDtool will not accept - -- any data timed before or at the time - -- specified. (default: @now - 10s@) - -> Maybe NominalDiffTime -- ^Specifies the base interval in - -- seconds with which data will be fed - -- into the RRD. (default: 300 sec) --- -> [DataSource] -- ^Data sources to accept input from. - -> IO () +createRRD :: RRDSpec s => s -> IO () createRRD = error "FIXME" + +testMain :: IO () +testMain = let s = RRDPath "test.rrd" .&. + KeepOldRRD .&. + HNil + in + createRRD s