# Namespace for lsmeans package

# Imports
# import(Matrix) -- NO LONGER NEEDED
import(methods)
import(mvtnorm)
import(estimability)

# 'requireNamespace' block below allows me to put multcomp in
# Imports instead of Depends. 
if (requireNamespace("multcomp", quietly = TRUE)) {
    importFrom(multcomp, cld, glht, modelparm)
    
    export(cld) # need user to see it even if multcomp not loaded
    
    S3method(cld, ref.grid)
    S3method(cld, lsm.list)
    S3method(glht, lsmlf)
    S3method(glht, ref.grid)
    S3method(modelparm, lsmwrap)
}

if (requireNamespace("plyr", quietly = TRUE)) {
    importFrom(plyr, alply)
}

if (requireNamespace("coda", quietly = TRUE)) {
    importFrom(coda, as.mcmc)
    export(as.mcmc)
    S3method(as.mcmc, ref.grid)
}


# Visible exports
exportPattern("*.lsmc")  #all contrast fcns
export(
    as.glht,
    contrast,
    lsm,
    lsm.basis,
    lsmeans, 
    lsmeans.character,
    lsmobj,
    lsmip,
    lsm.options,
    lstrends,
    recover.data,
    ref.grid,
    regrid,
    test
)

# S3 methods for recover.data and lsm.basis that are needed by other packages
S3method(recover.data, call)

S3method(recover.data, aovlist)
S3method(lsm.basis, aovlist)

S3method(recover.data, lm)
S3method(lsm.basis, lm)

S3method(recover.data, lme)
S3method(lsm.basis, lme)

S3method(recover.data, merMod)
S3method(lsm.basis, merMod)

S3method(lsm.basis, mlm) # recover.data for mlm uses lm

# S3 methods - 
# For clarity, I'm showing them all 
# but commenting out the ones used only interally

S3method(as.glht, ref.grid)

S3method(confint, ref.grid)
S3method(confint, lsm.list)

S3method(contrast, ref.grid)
S3method(contrast,lsm.list)

#S3method(glht, lsmlf)   # in namespace block above
#S3method(glht, ref.grid)

S3method(lsmeans, character)
S3method(lsmeans.character, default)
S3method(lsmeans.character, ref.grid)
S3method(lsmeans, default)
S3method(lsmeans, formula)
S3method(lsmeans, list)

S3method(lsmip, default)

#S3method(modelparm, lsmwrap) # in namespace block above

S3method(pairs, ref.grid)
S3method(pairs, lsm.list)

S3method(plot, lsmobj)
S3method(plot, summary.ref.grid)

S3method(predict, ref.grid)

S3method(print, ref.grid)
S3method(print, summary.ref.grid)
S3method(print, lsm.list)

S3method(str, ref.grid)
S3method(str, lsm.list)

S3method(summary, ref.grid)
S3method(summary, glht.list)
S3method(summary, lsm.list)

S3method(test, ref.grid)
S3method(test, lsm.list)

S3method(update, ref.grid)

S3method(vcov, ref.grid)



# interim support for old lsmeans function
# removed at version 2.14
#   export(.old.lsmeans)
#   S3method(print, lsm)
#   S3method(print, data.frame.lsm)
