exposeClass() will create both C++ and R code files to
expose the C++ class.
setRcppClass(Class, CppClass = , module = , fields = list(), contains = , methods = , saveAs = Class, where = , ...)
loadRcppClass(Class, CppClass = , module = , fields = character(), contains = character(), methods = , saveAs = Class, where = , ...)Class.
setRcppClass() will arrange to
load the module. By default, "class_" followed by the C++ class
name.If exposeClass() has been called, the necessary module
code will have been written in the src directory of the package.
setRefClass().
NULL.(This argument is currently needed because the actual class definition
must take place at package load time, to include C++ pointer
information.
Therefore the
value returned by setRcppClass() when called during package
installation is not the generator object returned by
setRefClass().
We may be able to hack
around this problem in the future.)
setRcppClass() call is included.
setRefClass().
saveAs argument, typically under the name of
the class.The value returned at installation time is a dummy. Future revisions
of the function may allow us to return a valid generator at install
time. We recommend using the standard style of assigning the value
to the name of the class, as one would do with setRefClass.
exposeClass() is called.R code for this class or (preferably) a subclass can define new fields and methods for the class. Methods for the R class can refer to methods and fields defined in C++ for the C++ class, if those have been exposed.
The fields and methods defined can include overriding C++ fields or methods. Keep in mind, however, that R methods can refer to C++ fields and methods, but not the reverse. If you override a C++ field or method, you essentially need to revise all code that refers to that field or method. Otherwise, the C++ code will continue to use the old C++ definition.
## Not run:
# setRcppClass("World",
# module = "yada",
# fields = list(more = "character"),
# methods = list(
# test = function(what) message("Testing: ", what, "; ", more)),
# saveAs = "genWorld"
# )
# ## End(Not run)
Run the code above in your browser using DataLab