import(methods)
importFrom(utils, read.table)
importFrom(stats, setNames)
importFrom(tools, file_path_as_absolute)
importFrom(Matrix, sparseMatrix)

import(BiocGenerics)
import(S4Vectors)
import(IRanges)
import(S4Arrays)
import(SparseArray)
import(DelayedArray)
importFrom(rhdf5, h5createFile, h5createDataset, h5createGroup,
                  h5read, h5readAttributes, h5write, h5set_extent)
import(h5mread)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S4 classes
###

exportClasses(
    HDF5ArraySeed,
    HDF5Array, HDF5Matrix,
    ReshapedHDF5ArraySeed,
    ReshapedHDF5Array, ReshapedHDF5Matrix,
    HDF5RealizationSink,
    H5SparseMatrixSeed, CSC_H5SparseMatrixSeed, CSR_H5SparseMatrixSeed,
    H5SparseMatrix,
    H5ADMatrixSeed,
    Dense_H5ADMatrixSeed, CSC_H5ADMatrixSeed, CSR_H5ADMatrixSeed,
    H5ADMatrix,
    TENxMatrixSeed,
    TENxMatrix,
    TENxRealizationSink
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S3 methods
###

S3method(t, CSC_H5SparseMatrixSeed)
S3method(t, CSR_H5SparseMatrixSeed)
S3method(t, CSC_H5ADMatrixSeed)
S3method(t, CSR_H5ADMatrixSeed)

### We also export them thru the export() directive so that (a) they can be
### called directly, (b) tab-completion on the name of the generic shows them,
### and (c) methods() doesn't asterisk them.

export(
    t.CSC_H5SparseMatrixSeed,
    t.CSR_H5SparseMatrixSeed,
    t.CSC_H5ADMatrixSeed,
    t.CSR_H5ADMatrixSeed
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S4 methods for generics not defined in HDF5Array
###

exportMethods(
    ## Methods for generics defined in the base package:
    dim, dimnames, t,

    ## Methods for generics defined in the methods package:
    coerce, show,

    ## Methods for generics defined in the BiocGenerics package:
    path, "path<-", type, updateObject,

    ## Methods for generics defined in the S4Arrays package:
    extract_array, is_sparse, "is_sparse<-",

    ## Methods for generics defined in the SparseArray package:
    nzcount, extract_sparse_array,

    ## Methods for generics defined in the DelayedArray package:
    chunkdim, write_block,
    matrixClass, DelayedArray,
    close
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export non-generic functions
###

export(
    HDF5ArraySeed,
    HDF5Array,
    ReshapedHDF5ArraySeed,
    ReshapedHDF5Array,
    setHDF5DumpDir, getHDF5DumpDir,
    setHDF5DumpFile, getHDF5DumpFile, lsHDF5DumpFile,
    setHDF5DumpName, getHDF5DumpName,
    setHDF5DumpChunkLength, getHDF5DumpChunkLength,
    setHDF5DumpChunkShape, getHDF5DumpChunkShape,
    getHDF5DumpChunkDim,
    setHDF5DumpCompressionLevel, getHDF5DumpCompressionLevel,
    appendDatasetCreationToHDF5DumpLog, showHDF5DumpLog,
    HDF5RealizationSink, writeHDF5Array,
    saveHDF5SummarizedExperiment, loadHDF5SummarizedExperiment,
    quickResaveHDF5SummarizedExperiment,
    H5SparseMatrixSeed,
    H5SparseMatrix,
    H5ADMatrixSeed,
    H5ADMatrix,
    TENxMatrixSeed,
    TENxMatrix,
    TENxRealizationSink, writeTENxMatrix
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S4 generics defined in HDF5Array, and corresponding methods
###

export(
    ## H5SparseMatrixSeed-class.R:
    extractNonzeroDataByCol, extractNonzeroDataByRow
)

### Exactly the same list as above.
exportMethods(
    extractNonzeroDataByCol, extractNonzeroDataByRow
)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export internal utility functions for developers
###

export(
    shorten_assay2h5_links,
    restore_absolute_assay2h5_links,
    validate_HDF5ArraySeed_dataset_geometry,
    write_h5_assays,
    create_dir,
    replace_dir,
    check_and_delete_files,
    stop_if_bad_dir
)

