    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    module Bindings.HDF5.PropertyList.FAPL
        ( module Bindings.HDF5.PropertyList

        , FAPL
        , FileAccessPropertyList

        , setAlignment
        , getAlignment

        , setFamilyOffset
        , getFamilyOffset

        , setFCloseDegree
        , getFCloseDegree
        ) where

    import           Bindings.HDF5.Core
    import           Bindings.HDF5.Error
    import           Bindings.HDF5.PropertyList
    import           Bindings.HDF5.Raw.H5F
    import           Bindings.HDF5.Raw.H5P

    import           Control.Arrow              ((***))
    import           Foreign.Ptr.Conventions

    class PropertyList t => FileAccessPropertyList t where
    newtype FAPL = FAPL PropertyListID
        deriving (FAPL -> FAPL -> Bool
    (FAPL -> FAPL -> Bool) -> (FAPL -> FAPL -> Bool) -> Eq FAPL
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: FAPL -> FAPL -> Bool
    == :: FAPL -> FAPL -> Bool
    $c/= :: FAPL -> FAPL -> Bool
    /= :: FAPL -> FAPL -> Bool
    Eq, FAPL -> HId_t
    (FAPL -> HId_t) -> HId FAPL
    forall t. (t -> HId_t) -> HId t
    $chid :: FAPL -> HId_t
    hid :: FAPL -> HId_t
    HId, HId_t -> FAPL
    (HId_t -> FAPL) -> FromHId FAPL
    forall t. (HId_t -> t) -> FromHId t
    $cuncheckedFromHId :: HId_t -> FAPL
    uncheckedFromHId :: HId_t -> FAPL
    FromHId, FAPL -> Bool
    (FAPL -> Bool) -> HDFResultType FAPL
    forall t. (t -> Bool) -> HDFResultType t
    $cisError :: FAPL -> Bool
    isError :: FAPL -> Bool
    HDFResultType, FromHId FAPL
    HId FAPL
    (HId FAPL, FromHId FAPL) => PropertyListOrClass FAPL
    forall t. (HId t, FromHId t) => PropertyListOrClass t
    PropertyListOrClass)
    instance PropertyList FAPL where
        staticPlistClass :: Tagged FAPL PropertyListClassID
    staticPlistClass = PropertyListClassID -> Tagged FAPL PropertyListClassID
    forall {k} (s :: k) b. b -> Tagged s b
    Tagged PropertyListClassID
    fileAccess
    instance FileAccessPropertyList FAPL

    setAlignment :: FileAccessPropertyList fapl => fapl -> HSize -> HSize -> IO ()
    setAlignment :: forall fapl.
    FileAccessPropertyList fapl =>
    fapl -> HSize -> HSize -> IO ()
    setAlignment fapl
    fapl HSize
    threshold HSize
    alignment =
        IO HErr_t -> IO ()
    forall t. HDFResultType t => IO t -> IO ()
    withErrorCheck_ (IO HErr_t -> IO ()) -> IO HErr_t -> IO ()
    forall a b. (a -> b) -> a -> b
    $
            HId_t -> HSize_t -> HSize_t -> IO HErr_t
    h5p_set_alignment (fapl -> HId_t
    forall t. HId t => t -> HId_t
    hid fapl
    fapl) (HSize -> HSize_t
    hSize HSize
    threshold) (HSize -> HSize_t
    hSize HSize
    alignment)

    getAlignment :: FileAccessPropertyList fapl => fapl -> IO (HSize, HSize)
    getAlignment :: forall fapl.
    FileAccessPropertyList fapl =>
    fapl -> IO (HSize, HSize)
    getAlignment fapl
    fapl =
        ((HSize_t, HSize_t) -> (HSize, HSize))
    -> IO (HSize_t, HSize_t) -> IO (HSize, HSize)
    forall a b. (a -> b) -> IO a -> IO b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (HSize_t -> HSize
    HSize (HSize_t -> HSize)
    -> (HSize_t -> HSize) -> (HSize_t, HSize_t) -> (HSize, HSize)
    forall b c b' c'. (b -> c) -> (b' -> c') -> (b, b') -> (c, c')
    forall (a :: * -> * -> *) b c b' c'.
    Arrow a =>
    a b c -> a b' c' -> a (b, b') (c, c')
    *** HSize_t -> HSize
    HSize) (IO (HSize_t, HSize_t) -> IO (HSize, HSize))
    -> IO (HSize_t, HSize_t) -> IO (HSize, HSize)
    forall a b. (a -> b) -> a -> b
    $
            (Out HSize_t -> IO HSize_t) -> IO (HSize_t, HSize_t)
    forall a (m :: * -> *) b.
    (Storable a, MonadBaseControl IO m, MonadIO m) =>
    (Out a -> m b) -> m (a, b)
    withOut ((Out HSize_t -> IO HSize_t) -> IO (HSize_t, HSize_t))
    -> (Out HSize_t -> IO HSize_t) -> IO (HSize_t, HSize_t)
    forall a b. (a -> b) -> a -> b
    $ \Out HSize_t
    threshold ->
                (Out HSize_t -> IO ()) -> IO HSize_t
    forall a (m :: * -> *) b.
    (Storable a, MonadBaseControl IO m, MonadIO m) =>
    (Out a -> m b) -> m a
    withOut_ ((Out HSize_t -> IO ()) -> IO HSize_t)
    -> (Out HSize_t -> IO ()) -> IO HSize_t
    forall a b. (a -> b) -> a -> b
    $ \Out HSize_t
    alignment ->
                    IO HErr_t -> IO ()
    forall t. HDFResultType t => IO t -> IO ()
    withErrorCheck_ (IO HErr_t -> IO ()) -> IO HErr_t -> IO ()
    forall a b. (a -> b) -> a -> b
    $
                        HId_t -> Out HSize_t -> Out HSize_t -> IO HErr_t
    h5p_get_alignment (fapl -> HId_t
    forall t. HId t => t -> HId_t
    hid fapl
    fapl) Out HSize_t
    threshold Out HSize_t
    alignment

    -- TODO: implement these
    -- h5p_set_driver :: HId_t -> HId_t -> Ptr a -> IO HErr_t
    -- h5p_get_driver :: HId_t -> IO HId_t
    -- h5p_get_driver_info :: HId_t -> IO (Ptr a)

    setFamilyOffset :: FileAccessPropertyList fapl => fapl -> HSize -> IO ()
    setFamilyOffset :: forall fapl. FileAccessPropertyList fapl => fapl -> HSize -> IO ()
    setFamilyOffset fapl
    fapl HSize
    offset =
        IO HErr_t -> IO ()
    forall t. HDFResultType t => IO t -> IO ()
    withErrorCheck_ (IO HErr_t -> IO ()) -> IO HErr_t -> IO ()
    forall a b. (a -> b) -> a -> b
    $
            HId_t -> HSize_t -> IO HErr_t
    h5p_set_family_offset (fapl -> HId_t
    forall t. HId t => t -> HId_t
    hid fapl
    fapl) (HSize -> HSize_t
    hSize HSize
    offset)

    getFamilyOffset :: FileAccessPropertyList fapl => fapl -> IO HSize
    getFamilyOffset :: forall fapl. FileAccessPropertyList fapl => fapl -> IO HSize
    getFamilyOffset fapl
    fapl =
        (HSize_t -> HSize) -> IO HSize_t -> IO HSize
    forall a b. (a -> b) -> IO a -> IO b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap HSize_t -> HSize
    HSize (IO HSize_t -> IO HSize) -> IO HSize_t -> IO HSize
    forall a b. (a -> b) -> a -> b
    $
            (Out HSize_t -> IO ()) -> IO HSize_t
    forall a (m :: * -> *) b.
    (Storable a, MonadBaseControl IO m, MonadIO m) =>
    (Out a -> m b) -> m a
    withOut_ ((Out HSize_t -> IO ()) -> IO HSize_t)
    -> (Out HSize_t -> IO ()) -> IO HSize_t
    forall a b. (a -> b) -> a -> b
    $ \Out HSize_t
    offset ->
                IO HErr_t -> IO ()
    forall t. HDFResultType t => IO t -> IO ()
    withErrorCheck_ (IO HErr_t -> IO ()) -> IO HErr_t -> IO ()
    forall a b. (a -> b) -> a -> b
    $
                    HId_t -> Out HSize_t -> IO HErr_t
    h5p_get_family_offset (fapl -> HId_t
    forall t. HId t => t -> HId_t
    hid fapl
    fapl) Out HSize_t
    offset

    setFCloseDegree :: FileAccessPropertyList fapl => fapl -> H5F_close_degree_t -> IO ()
    setFCloseDegree :: forall fapl.
    FileAccessPropertyList fapl =>
    fapl -> H5F_close_degree_t -> IO ()
    setFCloseDegree fapl
    fapl H5F_close_degree_t
    degree =
      IO HErr_t -> IO ()
    forall t. HDFResultType t => IO t -> IO ()
    withErrorCheck_ (IO HErr_t -> IO ()) -> IO HErr_t -> IO ()
    forall a b. (a -> b) -> a -> b
    $
      HId_t -> H5F_close_degree_t -> IO HErr_t
    h5p_set_fclose_degree (fapl -> HId_t
    forall t. HId t => t -> HId_t
    hid fapl
    fapl) H5F_close_degree_t
    degree

    getFCloseDegree :: FileAccessPropertyList fapl => fapl -> IO H5F_close_degree_t
    getFCloseDegree :: forall fapl.
    FileAccessPropertyList fapl =>
    fapl -> IO H5F_close_degree_t
    getFCloseDegree fapl
    fapl =
      (Out H5F_close_degree_t -> IO ()) -> IO H5F_close_degree_t
    forall a (m :: * -> *) b.
    (Storable a, MonadBaseControl IO m, MonadIO m) =>
    (Out a -> m b) -> m a
    withOut_ ((Out H5F_close_degree_t -> IO ()) -> IO H5F_close_degree_t)
    -> (Out H5F_close_degree_t -> IO ()) -> IO H5F_close_degree_t
    forall a b. (a -> b) -> a -> b
    $ \Out H5F_close_degree_t
    degree ->
        IO HErr_t -> IO ()
    forall t. HDFResultType t => IO t -> IO ()
    withErrorCheck_ (IO HErr_t -> IO ()) -> IO HErr_t -> IO ()
    forall a b. (a -> b) -> a -> b
    $
          HId_t -> Out H5F_close_degree_t -> IO HErr_t
    h5p_get_fclose_degree (fapl -> HId_t
    forall t. HId t => t -> HId_t
    hid fapl
    fapl) Out H5F_close_degree_t
    degree

    -- TODO: implement these
    -- h5p_set_multi_type :: HId_t -> H5FD_mem_t -> IO HErr_t
    -- h5p_get_multi_type :: HId_t -> Out H5FD_mem_t -> IO HErr_t
    -- h5p_set_cache :: HId_t -> CInt -> CSize -> CSize -> CDouble -> IO HErr_t
    -- h5p_get_cache :: HId_t -> Out CInt -> Out CSize -> Out CSize -> Out CDouble -> IO HErr_t
    -- h5p_set_mdc_config :: HId_t -> In H5AC_cache_config_t -> IO HErr_t
    -- h5p_get_mdc_config :: HId_t -> Out H5AC_cache_config_t -> IO HErr_t
    -- h5p_set_gc_references :: HId_t -> CUInt -> IO HErr_t
    -- h5p_get_gc_references :: HId_t -> Out CUInt -> IO HErr_t
    -- h5p_set_meta_block_size :: HId_t -> HSize_t -> IO HErr_t
    -- h5p_get_meta_block_size :: HId_t -> Out HSize_t -> IO HErr_t
    -- h5p_set_sieve_buf_size :: HId_t -> CSize -> IO HErr_t
    -- h5p_get_sieve_buf_size :: HId_t -> Out CSize -> IO HErr_t
    -- h5p_set_small_data_block_size :: HId_t -> HSize_t -> IO HErr_t
    -- h5p_get_small_data_block_size :: HId_t -> Out HSize_t -> IO HErr_t
    -- h5p_set_libver_bounds :: HId_t -> H5F_libver_t -> H5F_libver_t -> IO HErr_t
    -- h5p_get_libver_bounds :: HId_t -> Out H5F_libver_t -> Out H5F_libver_t -> IO HErr_t
    -- h5p_set_elink_file_cache_size :: HId_t -> CUInt -> IO HErr_t
    -- h5p_get_elink_file_cache_size :: HId_t -> Out CUInt -> IO HErr_t