retrieveFactory: Retrieve the type factory object

View source: R/retrieveFactory.R

retrieveFactoryR Documentation

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()

Details

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

Value

An R object that is a FunctionParameterTypeFactory.

Author(s)

Fabien Gelineau <neonira@gmail.com>

Maintainer: Fabien Gelineau <neonira@gmail.com>

Examples

##---- 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')]

wyz.code.offensiveProgramming documentation built on Sept. 25, 2023, 9:05 a.m.