Learn R Programming

Rcpp (version 0.9.15)

setRcppClass: Create a Class Extending a C++ Class

Description

A class is defined that includes the fields and methods of a C++ class defined, usually in this package. The R

Usage

setRcppClass(Class, CppClass, module, fields = list(), contains = , methods = , saveAs = Class, where = , ...)

Arguments

Class
The name for the new class.
CppClass
The C++ class defined in the C++ code for the package that this class extends. By default, the same as Class.
module
The Rcpp module in which the class is defined. The module does not have to be loaded separately; setRcppClass() will arrange to load the module.
fields, contains, methods
Additional fields, superclasses and method definitions in R

Value

  • A generator for the new class.

item

  • saveAs
  • where
  • ...

code

setRcppClass

Details

The call to this function normally appears in the source code for a package. It generates a load action that loads the specified module and extracts the C++ class definition specified.

R

Examples

Run this code
setRcppClass("World", 
    module = "yada", 
    fields = list(more = "character"),
    methods = list(
        test = function(what) message("Testing: ", what, "; ", more)),
    saveAs = "genWorld"
         )

Run the code above in your browser using DataLab