Creates an metaRangeProcess object in form of an R6 class that stores and handles all the parts that define a process.
Public fields
fun
<function>
The processes function. This will be called when the process is executed.
Methods
Method new()
Creates a new metaRangeProcess object
Usage
metaRangeProcess$new(
process_name,
id = "",
process_fun,
execution_priority,
env,
env_label = NULL
)
Arguments
process_name
<string>
name of the process.id
<string>
optional ID of the process.process_fun
<function>
The function to be called when the process is executed. It will be executed in the specified environment (see argument: env) and has access to all the variables in that environment. This function may not have any arguments, i.e.is.null(formals(process_fun))
must beTRUE
.execution_priority
<integer>
the priority of the process. The lower the number the earlier the process is executed (1 == highest priority). Note that the priority is only used to sort the processes in the priority queue. The actual execution order is determined by the order of the processes in the queue.env
<environment>
the environment where the process should be executed.env_label
<string>
optional name of the execution environment. Just used as a human readable label for debug purposes.
Examples
# Note: Only for illustration purposes. Use the add_process method of the
# simulation object to add processes to a simulation.
pr <- metaRangeProcess$new(
process_name = "ecological_process",
process_fun = function() {
cat("Execute ecological process!")
},
execution_priority = 1L,
env = new.env(),
env_label = "a_species_name"
)
pr
Method get_PID()
get the process ID
Examples
pr <- metaRangeProcess$new("A", "1", \() {}, 1, new.env())
pr$get_PID()
Method get_name()
get the process name
Examples
pr <- metaRangeProcess$new("A", "1", \() {}, 1, new.env())
pr$get_name()
Method get_priority()
get the process execution priority
Examples
pr <- metaRangeProcess$new("A", "1", \() {}, 1, new.env())
pr$get_priority()
Method get_env_label()
get the name of the process execution environment
Examples
pr <- metaRangeProcess$new("A", "1", \() {}, 1, new.env(), "human_readable_label")
pr$get_env_label()
Method print()
Prints information about the process to the console
Examples
pr <- metaRangeProcess$new("A", "1", \() {}, 1, new.env())
pr$print()
Examples
## ------------------------------------------------
## Method `metaRangeProcess$new`
## ------------------------------------------------
# Note: Only for illustration purposes. Use the add_process method of the
# simulation object to add processes to a simulation.
pr <- metaRangeProcess$new(
process_name = "ecological_process",
process_fun = function() {
cat("Execute ecological process!")
},
execution_priority = 1L,
env = new.env(),
env_label = "a_species_name"
)
pr
#> Process name: ecological_process
#> PID: PID-17cdf2a13-ecological_process-a_species_name
#> execution_priority: 1
#> execution_environment_label: a_species_name
#> $fun: function() {
#> cat("Execute ecological process!")
#> }
#> <environment: 0x0000022b99637210>
## ------------------------------------------------
## Method `metaRangeProcess$get_PID`
## ------------------------------------------------
pr <- metaRangeProcess$new("A", "1", \() {}, 1, new.env())
pr$get_PID()
#> [1] "PID-17b5f38901-A-"
## ------------------------------------------------
## Method `metaRangeProcess$get_name`
## ------------------------------------------------
pr <- metaRangeProcess$new("A", "1", \() {}, 1, new.env())
pr$get_name()
#> [1] "A"
## ------------------------------------------------
## Method `metaRangeProcess$get_priority`
## ------------------------------------------------
pr <- metaRangeProcess$new("A", "1", \() {}, 1, new.env())
pr$get_priority()
#> [1] 1
## ------------------------------------------------
## Method `metaRangeProcess$get_env_label`
## ------------------------------------------------
pr <- metaRangeProcess$new("A", "1", \() {}, 1, new.env(), "human_readable_label")
pr$get_env_label()
#> [1] "human_readable_label"
## ------------------------------------------------
## Method `metaRangeProcess$print`
## ------------------------------------------------
pr <- metaRangeProcess$new("A", "1", \() {}, 1, new.env())
pr$print()
#> Process name: A
#> PID: PID-16ea446ab1-A-
#> execution_priority: 1
#> execution_environment_label:
#> $fun: \() {}
#> <environment: 0x0000022b99a83d40>