R/zzz.R

Defines functions .onLoad .Last.lib

#   Rshare: the shared environment package
#
#   Copyright (C) 2012 Charlie Friedemann (cfriedem at gmail dot com)
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

#' Rshare: the shared environment package
#'
#' This is the Rshare package. It is used to create a shared environment available to multiple \R sessions. 
#' The environment is hosted and served by one \R session, and other \R sessions may subscribe to this environment as clients.
#' Environments are parameterized by a port number. Objects may be written to and read from the shared environment. 
#' For an overview of the functions used to access the shared environment, see See \code{\link{get.Rshare}}\cr
#' \subsection{Server-side Hooks}{
#' In addition, a simple method of registering server-side hooks allows users to create custom functionality. 
#' These hooks work by dispatching certain types of objects received by the server to user-defined functions. 
#' User-defined functions may do anything, from displaying a message in the console to running an analysis and returning customized data.
#' See \code{\link{registerRshareHook}} for more information.
#' }
#'
#' @section Implementation:
#' The package works by utilizing Tcl sockets to create a lightweight framework for different \R sessions to share data.
#' It is written with a mixture of \R and Tcl code to allow for portability across mutliple operating systems. 
#' Be warned, the package is far from complete and functionality may change in the future to address current limitations.
#'
#' @section Details:
#' \tabular{ll}{
#'   Package: \tab Rshare\cr
#'   Version: \tab 1.0\cr
#'   License: \tab GPL Version 3 or later.\cr
#' }
#'
#' @name Rshare
#' @author Charlie Friedemann
#' @docType package
#' @aliases Rshare Rshare-package
NULL

.onLoad <- function(libname, pkgname) {
	# Initialize Rshare environment
	if (!exists(".Rshare")) .Rshare <<- new.env()
	packageStartupMessage("Loaded Rshare version 1.0: See ?Rshare for more information")
}

.Last.lib <- function(libpath) {
	envs <- ls(.Rshare)
	for (env in envs) {
		if (!identical(.Rshare[[env]]$.status,"closed")) stopRshare(as.integer(unlist(strsplit(env,"_",fixed=TRUE))[2]))
	}
}

Try the Rshare package in your browser

Any scripts or data that you put into this service are public.

Rshare documentation built on May 2, 2019, 5:23 p.m.