diff --git a/R/SimulationObjectClass.R b/R/SimulationObjectClass.R index 6813fda..22ca9d0 100644 --- a/R/SimulationObjectClass.R +++ b/R/SimulationObjectClass.R @@ -8,6 +8,7 @@ setClass("SimulationObject", effort = "ANY", detect = "ANY", report = "ANY", + metadata = "ANY", hash = "ANY" ) ) @@ -22,6 +23,7 @@ SimulationObject <- function(background, state_env = NULL, state_target_suitabil effort = effort, detect = detect, report = report, + metadata = list(), hash = NULL) new("SimulationObject", @@ -32,6 +34,7 @@ SimulationObject <- function(background, state_env = NULL, state_target_suitabil effort = effort, detect = detect, report = report, + metadata = list(), hash = hash_sim_obj(tmp) ) } diff --git a/R/sim_detect.R b/R/sim_detect.R index 1dcec4d..9a2b687 100644 --- a/R/sim_detect.R +++ b/R/sim_detect.R @@ -23,6 +23,8 @@ sim_detect <- function(simulation_object, fun, ...) { detections <- fun(simulation_object, ...) # validity checks + fun_args <- as.list(match.call()) + simulation_object_original@metadata[["detect"]] <- fun_args[3:length(fun_args)] simulation_object_original@detect <- detections simulation_object_original@hash <- hash_sim_obj(simulation_object_original) diff --git a/R/sim_effort.R b/R/sim_effort.R index b7e177e..8a2b596 100644 --- a/R/sim_effort.R +++ b/R/sim_effort.R @@ -23,6 +23,8 @@ sim_effort <- function(simulation_object, fun, ...) { effort <- fun(simulation_object, ...) # validity checks + fun_args <- as.list(match.call()) + simulation_object_original@metadata[["effort"]] <- fun_args[3:length(fun_args)] simulation_object_original@effort <- effort simulation_object_original@hash <- hash_sim_obj(simulation_object_original) diff --git a/R/sim_report.R b/R/sim_report.R index 209ef4b..f3ccef7 100644 --- a/R/sim_report.R +++ b/R/sim_report.R @@ -23,6 +23,8 @@ sim_report <- function(simulation_object, fun, ...) { report <- fun(simulation_object, ...) # validity checks + fun_args <- as.list(match.call()) + simulation_object_original@metadata[["report"]] <- fun_args[3:length(fun_args)] simulation_object_original@report <- report simulation_object_original@hash <- hash_sim_obj(simulation_object_original) diff --git a/R/sim_state_env.R b/R/sim_state_env.R index 1bddbe1..e61c8c2 100644 --- a/R/sim_state_env.R +++ b/R/sim_state_env.R @@ -55,6 +55,10 @@ sim_state_env <- function(simulation_object, fun= NULL, filename = NULL, spatras #create hash, having set the hash to NULL simulation_object_original@hash <- hash_sim_obj(simulation_object_original) + #set metadata + fun_args <- as.list(match.call()) + simulation_object_original@metadata[["state_env"]] <- fun_args[3:length(fun_args)] + # Return the updated simulation_object return(simulation_object_original) } diff --git a/R/sim_state_target_realise.R b/R/sim_state_target_realise.R index 9dbe185..e068470 100644 --- a/R/sim_state_target_realise.R +++ b/R/sim_state_target_realise.R @@ -28,6 +28,9 @@ sim_state_target_realise <- function(simulation_object,fun, filename=NULL, ...) realised <- write_raster_return_filename(realised,filename) } + fun_args <- as.list(match.call()) + simulation_object_original@metadata[["state_target_realised"]] <- fun_args[3:length(fun_args)] + simulation_object_original@state_target_realised <- realised simulation_object_original@hash <- hash_sim_obj(simulation_object_original) simulation_object_original diff --git a/R/sim_state_target_suitability.R b/R/sim_state_target_suitability.R index e635694..e5d4a47 100644 --- a/R/sim_state_target_suitability.R +++ b/R/sim_state_target_suitability.R @@ -28,6 +28,9 @@ sim_state_target_suitability <- function(simulation_object,fun,filename = NULL, suitability <- write_raster_return_filename(suitability,filename) } + fun_args <- as.list(match.call()) + simulation_object_original@metadata[["state_target_suitability"]] <- fun_args[3:length(fun_args)] + simulation_object_original@state_target_suitability <- suitability simulation_object_original@hash <- hash_sim_obj(simulation_object_original) simulation_object_original