altWrapper-api: AltWrapper APIs

Description Usage Arguments Details Value Examples

Description

AltWrapper APIs

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17

Arguments

className

Character, the name of an altWrapper class

methodName

Character, the name of a function

x

An altWrapper object

value

The data of an altWrapper object

duplicate

Whther duplicating the object(For the function setAltWrapperData)

warning

Logical, whether to give an warning if the class is not found.

Details

isAltClassDefined : Whether an altWrapper class exist or not

isAltMethodDefined : Whether an altWrapper method for an altWrapper class exist or not. This function will return FALSE if it cannot find the altWrapper class.

getAltClassName : Get the altWrapper class name by an altWrapper object

getAltClassType : Get the altWrapper class type by a class name or an altWrapper object

getAltMethod : Get the altWrapper method by a method name. Either className or x must be specified to find the altWrapper class.

getAltWrapperData : Get the data for an altWrapper object

setAltWrapperData : Set the data of an altWrapper object, if duplicate is TRUE, the function returns a duplication of the object. Set duplicate = FALSE only when the new value does not change the altWrapper object(e.g. caching on-dist data).

deleteAltClass : Delete an AltWrapper class

showAltClass : Show the status of an altWrapper class

Value

isAltClassDefined : Logical

isAltMethodDefined : Logical

getAltClassName : A character name

getAltClassType : A character indicating data type

getAltMethod : An R function or NULL value if the function is not found

getAltWrapperData : An R object

setAltWrapperData : The altWrapper object

deleteAltClass : No return value

showAltClass : No return value

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
## Define the ALTREP functions
length_func <- function(x) length(x)
get_ptr_func <- function(x,writeable) x


## Define the altWrapper class and its functions
setAltClass(className = "example", classType = "integer")
setAltMethod(className = "example", getLength = length_func)
setAltMethod(className = "example", getDataptr = get_ptr_func)

## Create an altWrapper object by providing the class name and data.
A <- newAltrep(className = "example", x = 1L:10L)
A

## Check the existance of an altWrapper class
isAltClassDefined(className = "example")

## Check the existance of a function of an altWrapper class
isAltMethodDefined(className = "example", methodName = "getLength")

## Get a function from an altWrapper class
getAltMethod(className = "example", methodName = "getLength")

## Get the class name by an altWrapper object
getAltClassName(A)

## Get the class type either by a class name or by an altWrapper object
getAltClassType(className = "example")
getAltClassType(x = A)

## Get the data of an altWrapper object
getAltWrapperData(x = A)

## Set the data of an altWrapper object
setAltWrapperData(x = A, value = 11L:20L)

## Show the status of an altWrapper class
## The class can be found either by its name or an altWrapper object
showAltClass(className = "example")
showAltClass(x = A)

Jiefei-Wang/AltWrapper documentation built on Oct. 30, 2019, 7:43 p.m.