Allow S4 methods to be set for loom
authorPaul Hoffman <phoffman@nygenome.org>
Thu, 2 Nov 2017 19:58:17 +0000 (15:58 -0400)
committerPaul Hoffman <phoffman@nygenome.org>
Thu, 2 Nov 2017 19:58:17 +0000 (15:58 -0400)
DESCRIPTION
NAMESPACE
R/internal.R [new file with mode: 0644]

index 110b554c085976b449096f8d830983181b1c3a47..1455bab576c1526cdeb45091a616b8275b2962eb 100644 (file)
@@ -19,6 +19,7 @@ Imports:
   itertools
 Collate:
   'loom.R'
+  'internal.R'
 License: GPL-3
 Encoding: UTF-8
 LazyData: true
index 1815515e2aec3bcbd0b00d8304e65c3500e9829e..a027ff57281cce9b6c20bda27889ae2037c6884d 100644 (file)
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -3,11 +3,16 @@
 export(connect)
 export(create)
 export(loom)
+export(map)
 export(validateLoom)
+import(R6)
 import(hdf5r)
 importFrom(R6,R6Class)
 importFrom(iterators,nextElem)
 importFrom(itertools,hasNext)
 importFrom(itertools,ichunk)
 importFrom(itertools,ihasNext)
+importFrom(methods,setOldClass)
 importFrom(utils,packageVersion)
+importFrom(utils,setTxtProgressBar)
+importFrom(utils,txtProgressBar)
diff --git a/R/internal.R b/R/internal.R
new file mode 100644 (file)
index 0000000..6584e17
--- /dev/null
@@ -0,0 +1,30 @@
+#' @import R6
+#' @importFrom methods setOldClass
+NULL
+
+.onLoad <- function(libname, pkgname) {
+  setOldClass(Classes = 'loom')
+}
+
+.onAttach <- function(libname, pkgname) {
+  .onLoad(libname = libname, pkgname = pkgname)
+}
+
+# # Examples setting S4 methods for R6 classes
+# # Requires the setOldClass from above
+# setGeneric(
+#   name = 'foo',
+#   signature = 'x',
+#   def = function(x) {
+#     return(standardGeneric(f = 'foo'))
+#   }
+# )
+#
+# setMethod(
+#   f = 'foo',
+#   signature = c('x' = 'loom'),
+#   definition = function(x) {
+#     print("Hello loom!")
+#     print(' -From foo')
+#   }
+# )