Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Nov 13, 2024
1 parent 214f7a4 commit 9e32233
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Embedded/EmbeddedCollections.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@

"""
struct EmbeddedCollection
recipes :: Vector{<:Function}
objects :: Dict{Symbol,Any}
bgmodel :: DiscreteModel
end
A collection of embedded objects on the same background model. This structure
provides a way to update all the stored objects at once.
## Constructor
- `EmbeddedCollection(recipes::Union{<:Function,Vector{<:Function}},bgmodel::DiscreteModel[,φh])`
If provided, `φh` will be used to compute the initial collection of objects. If not provided,
the collection will remain empty until `update_collection!` is called.
## API:
- `update_collection!(c::EmbeddedCollection,φh)`: Update the collection of objects using the level set function `φh`.
- `add_recipe!(c::EmbeddedCollection,r::Function[,φh])`: Add a recipe to the collection. Update the collection if `φh` is provided.
"""
struct EmbeddedCollection
recipes :: Vector{<:Function}
objects :: Dict{Symbol,Any}
Expand Down Expand Up @@ -31,6 +54,12 @@ end

function add_recipe!(c::EmbeddedCollection,r::Function)
push!(c.recipes,r)
return c
end

function add_recipe!(c::EmbeddedCollection,r::Function,φh)
push!(c.recipes,r)
update_collection!(c,φh)
end

function Base.getindex(c::EmbeddedCollection,key)
Expand Down

0 comments on commit 9e32233

Please sign in to comment.