.packageName <- "sg"
# The purpose of this file is to supply no functionality
# except easier access functions in R for external C 
# function calls. 
#
# For example instead of typing
#
#     > .External("sg", "send_command", "blah")
#
# one can simply type
#
#     > send_command(blah)
#
# where > is the R prompt.

# interface sg(arg1,arg2,...) as w/ matlab/octave/python
#
sg <- function(...) .External("sg",...,PACKAGE="sg")


# R specific interface

# Generic functions
#
send_command <- function(x) .External("sg","send_command",x,PACKAGE="sg")
set_features <- function(x,y) .External("sg","set_features",x,y,PACKAGE="sg")
add_features <- function(x,y) .External("sg","add_features",x,y,PACKAGE="sg")
set_labels <- function(x,y) .External("sg","set_labels", x,y,PACKAGE="sg")
get_kernel_matrix <- function() .External("sg","get_kernel_matrix",PACKAGE="sg")

# SVM functions
#
svm_classify <- function() .External("sg","svm_classify",PACKAGE="sg")
get_svm <- function() .External("sg","get_svm",PACKAGE="sg")
get_subkernel_weights <- function() .External("sg","get_subkernel_weights",PACKAGE="sg") 

# HMM functions
#
get_hmm <- function() .External("sg","get_hmm",PACKAGE="sg")
# By convention the file zzz.R in an R package
# contains two routinges called .First.lib and
# .Last.lib which are called when the package 
# is loaded respective unloaded during a R
# session.

# Load the shogun dynamic library at startup.
#
.First.lib <- function(lib,pkg) library.dynam("sg",pkg,lib) #dyn.load("../libs/sg.so")  

# Unload the library.
#
.Last.lib <- function() dyn.unload("sg.so") 

# Because in packages with namespaces .First.lib will not be loaded
# one needs another functions called .onLoad resp. .onUnload
#
.onLoad <- function() .First.lib()
.onUnload <- function() .Last.lib()

# a nice banner
#
.onAttach <- function() cat(paste("\nWelcome! This is ShoGun version 0.1\n"))
