diff RemotedbConn.R @ 1:253d531a0193 draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
author prog
date Sat, 03 Sep 2016 17:02:01 -0400
parents
children 20d69a062da3
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RemotedbConn.R	Sat Sep 03 17:02:01 2016 -0400
@@ -0,0 +1,31 @@
+if ( ! exists('RemotedbConn')) {
+
+	source('BiodbConn.R')
+	source(file.path('UrlRequestScheduler.R'), chdir = TRUE)
+
+	#####################
+	# CLASS DECLARATION #
+	#####################
+	
+	RemotedbConn <- setRefClass("RemotedbConn", contains = "BiodbConn", fields = list(.scheduler = "UrlRequestScheduler"))
+
+	###############
+	# CONSTRUCTOR #
+	###############
+
+	RemotedbConn$methods( initialize = function(useragent = NA_character_, scheduler = NULL, ...) {
+
+		# Check useragent
+		( ! is.null(useragent) && ! is.na(useragent)) || stop("You must specify a valid useragent string (e.g.: \"myapp ; my.email@address\").")
+
+		# Set scheduler
+		if (is.null(scheduler))
+			scheduler <- UrlRequestScheduler$new(n = 3)
+		inherits(scheduler, "UrlRequestScheduler") || stop("The scheduler instance must inherit from UrlRequestScheduler class.")
+		scheduler$setUserAgent(useragent) # set agent
+		.scheduler <<- scheduler
+	
+		callSuper(...) # calls super-class initializer with remaining parameters
+	})
+
+}