-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from mrc-ide/release-0.1.12
Release 0.1.12
- Loading branch information
Showing
35 changed files
with
1,409 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: individual | ||
Title: Framework for Specifying and Simulating Individual Based Models | ||
Version: 0.1.11 | ||
Version: 0.1.12 | ||
Authors@R: c( | ||
person( | ||
given = "Giovanni", | ||
|
@@ -27,6 +27,7 @@ Authors@R: c( | |
given = "Paul", | ||
family = "Liétar", | ||
role = c('aut'), | ||
comment = c(ORCID = "0009-0000-3813-6227"), | ||
email = '[email protected]' | ||
), | ||
person( | ||
|
@@ -64,7 +65,7 @@ Suggests: | |
testthat (>= 2.1.0), | ||
xml2, | ||
bench | ||
RoxygenNote: 7.2.1.9000 | ||
RoxygenNote: 7.2.3 | ||
VignetteBuilder: knitr | ||
LinkingTo: | ||
Rcpp, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,78 @@ | ||
#' @title Event Class | ||
#' @description Describes a general event in the simulation. | ||
#' @title EventBase Class | ||
#' @description Common functionality shared between simple and targeted events. | ||
#' @importFrom R6 R6Class | ||
#' @export | ||
Event <- R6Class( | ||
'Event', | ||
EventBase <- R6Class( | ||
'EventBase', | ||
public = list( | ||
|
||
.event = NULL, | ||
.listeners = list(), | ||
|
||
#' @description Initialise an Event. | ||
initialize = function() { | ||
self$.event <- create_event() | ||
}, | ||
|
||
#' @description Add an event listener. | ||
#' @param listener the function to be executed on the event, which takes a single | ||
#' argument giving the time step when this event is triggered. | ||
add_listener = function(listener) { | ||
self$.listeners <- c(self$.listeners, listener) | ||
}, | ||
|
||
#' @description Schedule this event to occur in the future. | ||
#' @param delay the number of time steps to wait before triggering the event, | ||
#' can be a scalar or a vector of values for events that should be triggered | ||
#' multiple times. | ||
schedule = function(delay) event_schedule(self$.event, delay), | ||
.timestep = function() event_base_get_timestep(self$.event), | ||
|
||
#' @description Stop a future event from triggering. | ||
clear_schedule = function() event_clear_schedule(self$.event), | ||
|
||
.tick = function() event_tick(self$.event), | ||
.tick = function() event_base_tick(self$.event), | ||
|
||
.process = function() { | ||
for (listener in self$.listeners) { | ||
if (event_should_trigger(self$.event)) { | ||
if (event_base_should_trigger(self$.event)) { | ||
if (inherits(listener, "externalptr")) { | ||
self$.process_listener_cpp(listener) | ||
} else { | ||
self$.process_listener(listener) | ||
} | ||
} | ||
} | ||
} | ||
) | ||
) | ||
|
||
#' @title Event Class | ||
#' @description Describes a general event in the simulation. | ||
#' @importFrom R6 R6Class | ||
#' @export | ||
Event <- R6Class( | ||
'Event', | ||
inherit=EventBase, | ||
public = list( | ||
#' @description Initialise an Event. | ||
initialize = function() { | ||
self$.event <- create_event() | ||
}, | ||
|
||
#' @description Schedule this event to occur in the future. | ||
#' @param delay the number of time steps to wait before triggering the event, | ||
#' can be a scalar or a vector of values for events that should be triggered | ||
#' multiple times. | ||
schedule = function(delay) event_schedule(self$.event, delay), | ||
|
||
#' @description Stop a future event from triggering. | ||
clear_schedule = function() event_clear_schedule(self$.event), | ||
|
||
.process_listener = function(listener) { | ||
listener(event_get_timestep(self$.event)) | ||
listener(self$.timestep()) | ||
}, | ||
|
||
.process_listener_cpp = function(listener){ | ||
.process_listener_cpp = function(listener) { | ||
process_listener( | ||
event = self$.event, | ||
listener = listener | ||
) | ||
}, | ||
|
||
# NOTE: intentionally empty | ||
.resize = function() {} | ||
.resize = function() {}, | ||
|
||
.checkpoint = function() { | ||
event_checkpoint(self$.event) | ||
}, | ||
.restore = function(time, schedule) { | ||
event_restore(self$.event, time, schedule) | ||
} | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.