Learn R Programming

wyz.code.offensiveProgramming (version 1.1.24)

retrieveFactory: Retrieve the type factory object

Description

As factory may be modified, this function allows you to make changes and to record them in your own specialized type factory, to match various needs and ease reuse.

Usage

retrieveFactory()

Arguments

Value

An R

object that is a FunctionParameterTypeFactory.

Author

tools:::Rd_package_author("wyz.code.offensiveProgramming")

Maintainer: tools:::Rd_package_maintainer("wyz.code.offensiveProgramming")

Details

Retrieves a FunctionParameterTypeFactory from options variable named op_type_factory or provides a default type factory.

Examples

Run this code
##---- typical case ----
ff <- retrieveFactory()
ff$addSuffix('wo', "wo class", function(o_) is(o_, "wo"))
ff$addSuffix('yo', "yo class", function(o_) is(o_, "yo"))
ff$addSuffix('zo', "zo class", function(o_) is(o_, "zo"))

options('op_type_factory' = ff)
fg <- retrieveFactory() # retrieves the factory pointed by R variable ff
fg$getRecordedTypes()[suffix %in% c('wo', 'yo', 'zo')] # right behavior !

# wrong behavior as retrieveFactory will provide the default factory and not yours!
options('op_type_factory' = ff)
fh <- retrieveFactory() # retrieves the default factory
fh$getRecordedTypes()[suffix %in% c('wo', 'yo', 'zo')]

Run the code above in your browser using DataLab