Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

GenericClass

R6 class with generic reusable functionality


Description

R6 class with generic (abstract) new cloning functionality.

Public fields

object_generator

Class object generator used to create new clones, particularly for user inheritance.

attached

A list of dynamically attached attributes (name-value pairs).

Methods

Public methods


Method new()

Initialization method saves an object generator for new cloning.

Usage
GenericClass$new(object_generator = NULL, ...)
Arguments
object_generator

Class object generator used to create new clones, particularly for user inheritance.

...

Parameters passed individually (ignored).


Method new_clone()

Creates a new (re-initialized) object of the current (inherited) object class with optionally passed parameters.

Usage
GenericClass$new_clone(...)
Arguments
...

Parameters passed via the inherited class constructor (defined in initialize and run via new).

Returns

New object of the current (inherited) class.


Method clone()

The objects of this class are cloneable with this method.

Usage
GenericClass$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

object1 <- GenericClass$new()
class(object1)
# Referencing
object_ref <- object1
object_ref$attached$a <- 1
object1$attached
# Cloning
object2 <- object1$clone()
object2$attached$b <- 2
object1$attached
object2$attached
# New cloning
object3 <- object1$new_clone()
object3$attached$c <- 3
object1$attached
object3$attached

poems

Pattern-Oriented Ensemble Modeling System

v1.0.1
GPL-3
Authors
Sean Haythorne [aut, cre], Damien Fordham [aut], Stuart Brown [aut], Jessie Buettel [aut], Barry Brook [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.