@@ -9,6 +9,8 @@ struct Schedule{V <: BipartiteGraphs.Matching}
99 dummy_sub:: Dict{Any, Any}
1010end
1111
12+ const MetadataT = Base. ImmutableDict{DataType, Any}
13+
1214struct System <: AbstractSystem
1315 tag:: UInt
1416 eqs:: Vector{Equation}
@@ -38,7 +40,7 @@ struct System <: AbstractSystem
3840 discrete_events:: Vector{SymbolicDiscreteCallback}
3941 connector_type:: Any
4042 assertions:: Dict{BasicSymbolic, String}
41- metadata:: Any
43+ metadata:: MetadataT
4244 gui_metadata:: Any # ?
4345 is_dde:: Bool
4446 tstops:: Vector{Any}
@@ -60,7 +62,7 @@ struct System <: AbstractSystem
6062 brownians, iv, observed, parameter_dependencies, var_to_name, name, description,
6163 defaults, guesses, systems, initialization_eqs, continuous_events, discrete_events,
6264 connector_type, assertions = Dict {BasicSymbolic, String} (),
63- metadata = nothing , gui_metadata = nothing ,
65+ metadata = MetadataT () , gui_metadata = nothing ,
6466 is_dde = false , tstops = [], tearing_state = nothing , namespacing = true ,
6567 complete = false , index_cache = nothing , ignored_connections = nothing ,
6668 preface = nothing , parent = nothing , initializesystem = nothing ,
@@ -119,8 +121,9 @@ function System(eqs::Vector{Equation}, iv, dvs, ps, brownians = [];
119121 guesses = Dict (), systems = System[], initialization_eqs = Equation[],
120122 continuous_events = SymbolicContinuousCallback[], discrete_events = SymbolicDiscreteCallback[],
121123 connector_type = nothing , assertions = Dict {BasicSymbolic, String} (),
122- metadata = nothing , gui_metadata = nothing , is_dde = nothing , tstops = [],
123- tearing_state = nothing , ignored_connections = nothing , parent = nothing ,
124+ metadata = MetadataT (), gui_metadata = nothing ,
125+ is_dde = nothing , tstops = [], tearing_state = nothing ,
126+ ignored_connections = nothing , parent = nothing ,
124127 description = " " , name = nothing , discover_from_metadata = true ,
125128 initializesystem = nothing , is_initializesystem = false , preface = [],
126129 checks = true )
@@ -185,6 +188,7 @@ function System(eqs::Vector{Equation}, iv, dvs, ps, brownians = [];
185188
186189 assertions = Dict {BasicSymbolic, String} (unwrap (k) => v for (k, v) in assertions)
187190
191+ metadata = MetadataT (pairs (metadata)... )
188192 System (Threads. atomic_add! (SYSTEM_COUNT, UInt (1 )), eqs, noise_eqs, jumps, constraints,
189193 costs, consolidate, dvs, ps, brownians, iv, observed, parameter_dependencies,
190194 var_to_name, name, description, defaults, guesses, systems, initialization_eqs,
@@ -621,6 +625,17 @@ function Base.hash(sys::System, h::UInt)
621625 return h
622626end
623627
628+ function SymbolicUtils. getmetadata (sys:: AbstractSystem , k:: DataType , default)
629+ meta = get_metadata (sys)
630+ return get (meta, k, default)
631+ end
632+
633+ function SymbolicUtils. setmetadata (sys:: AbstractSystem , k:: DataType , v)
634+ meta = get_metadata (sys)
635+ meta = Base. ImmutableDict (meta, k => v):: MetadataT
636+ @set sys. metadata = meta
637+ end
638+
624639"""
625640 $(TYPEDSIGNATURES)
626641"""
0 commit comments