-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Importing options data from agepro_json_model to agepro_inp_model, or creating new instances of any agepro model class creates unattended side effects for Reference class options_flag_container
As a consequence, a option class with non-default values will be flagged as FALSE, not the intended design.
Reproduce
Note
Using dev-0.8.0 branch @ 474474c
- load ageproR
- Create a new
agepro_inp_modelclass with default values.
inpfile <- agepro_inp_model$new()- Load in Uku_Example Input File (Or Example 4 from AGEPRO-GUI Examples). For this example, load in test-example4.inp from the inst subfolder of the working directory.
inpfile$read_inp("inst/Exampe_UKU.inp")- Use
inpfile$perc,inpfile$bounds,inpfile$retroadjust,inpfile$refpoint, andinpfile$scaleto print out their values.- Options for PERC, BOUNDS, and REFPOINT should have enabled (TRUE). retroadjust and scale is FALSE until a non-default value is set to its values.
- Create a new
agepro_json_modelclass with the following
jsonfile <- agepro_json_model$new(2019, 2026, 1, 32, 1000, 4, 3)json$perc,jsonfile$bounds,jsonfile$retroadjust,jsonfile$refpoint, andjsonfile$scalewill print out their values and FALSE options flag.inpfile$perc,inpfile$bounds,inpfile$retroadjust,inpfile$refpoint, andinpfile$scalewill print out their values and FALSE options flag.
Solution
6/24 Edit Instantiate object flag references at the agepro_model level and then appending a new parameter (option_flag) when initializing the Option Classes (percentile_summary, max_bounds, reference_points, scaliing_factors, and retrospective_adjustments). Object_flag references will be tied to the instance of agepro_class and passed to the specific option class.
initialize the options_flag_container class so new instances of classes will share the reference.
Reference: https://r6.r-lib.org/articles/Introduction.html#fields-containing-reference-objects