diff --git a/src/base/macros/serialized.jl b/src/base/macros/serialized.jl new file mode 100644 index 0000000000000000000000000000000000000000..f2c654df70713cdc35428f2d5b8cb15b2d15db96 --- /dev/null +++ b/src/base/macros/serialized.jl @@ -0,0 +1,17 @@ +""" + _serialized_change_unwrap(fn::Symbol) + +Creates a simple wrapper structure that calls a function transparently on the +internal precached model. Internal type is returned (because this would break +the consistency of serialization). +""" +macro _serialized_change_unwrap(fn::Symbol) + docstring = """ + $fn(model::Serialized, ...) + + Calls [$fn](@ref) of the internal serialized model type. + Returns the modified un-serialized model. + """ + :(@doc $docstring $fn(model::Serialized, args...; kwargs...) = + $fn(unwrap_serialized(model), args...; kwargs...)) +end diff --git a/src/reconstruction/SerializedModel.jl b/src/reconstruction/SerializedModel.jl new file mode 100644 index 0000000000000000000000000000000000000000..1ded654add9f51645d34d0a8f1e8f5d64c9ef535 --- /dev/null +++ b/src/reconstruction/SerializedModel.jl @@ -0,0 +1,20 @@ + +# this just generates the necessary wrappers + +@_serialized_change_unwrap change_bound +@_serialized_change_unwrap change_bounds +@_serialized_change_unwrap add_reaction +@_serialized_change_unwrap remove_reaction +@_serialized_change_unwrap remove_reactions +@_serialized_change_unwrap remove_metabolite +@_serialized_change_unwrap remove_metabolites + +""" + unwrap_serialized(model::Serialized) + +Returns the model stored in the serialized structure. +""" +function unwrap_serialized(model::Serialized) + precache!(model) + model.m +end