@@ -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 =  " " =  nothing , discover_from_metadata =  true ,
125128        initializesystem =  nothing , is_initializesystem =  false , preface =  [],
126129        checks =  true )
@@ -185,6 +188,17 @@ 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+     if  isempty (metadata)
192+         metadata =  MetadataT ()
193+     elseif  metadata isa  MetadataT
194+         metadata =  metadata
195+     else 
196+         meta =  MetadataT ()
197+         for  kvp in  metadata
198+             meta =  Base. ImmutableDict (meta, kvp)
199+         end 
200+         metadata =  meta
201+     end 
188202    System (Threads. atomic_add! (SYSTEM_COUNT, UInt (1 )), eqs, noise_eqs, jumps, constraints,
189203        costs, consolidate, dvs, ps, brownians, iv, observed, parameter_dependencies,
190204        var_to_name, name, description, defaults, guesses, systems, initialization_eqs,
@@ -621,6 +635,17 @@ function Base.hash(sys::System, h::UInt)
621635    return  h
622636end 
623637
638+ function  SymbolicUtils. getmetadata (sys:: AbstractSystem , k:: DataType , default)
639+     meta =  get_metadata (sys)
640+     return  get (meta, k, default)
641+ end 
642+ 
643+ function  SymbolicUtils. setmetadata (sys:: AbstractSystem , k:: DataType , v)
644+     meta =  get_metadata (sys)
645+     meta =  Base. ImmutableDict (meta, k =>  v):: MetadataT 
646+     @set  sys. metadata =  meta
647+ end 
648+ 
624649""" 
625650    $(TYPEDSIGNATURES)  
626651""" 
0 commit comments