Skip to content

Commit 14c4574

Browse files
committed
Fix property handling for linkedpropertylistener and cache
1 parent 7a99367 commit 14c4574

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/RecoPlans/Cache.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ function loadPlan!(plan::RecoPlan{<:ProcessResultCache}, dict::Dict{String, Any}
9292
param = loadPlan!(dict["param"], modDict)
9393
parent!(param, plan)
9494
end
95-
setvalues!(plan; param, cache, maxsize)
95+
setproperty!(plan, :maxsize, maxsize)
96+
setproperty!(plan, :cache, cache)
97+
setproperty!(plan, :param, param)
9698
return plan
9799
end
98100

src/RecoPlans/LinkedPropertyListener.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function toDictValue!(dict, value::LinkedPropertyListener)
3838
dict["fn"] = toDict(value.fn)
3939
end
4040

41-
function loadListener!(::Type{LinkedPropertyListener}, target::RecoPlan, targetProp, dict, args...)
41+
function loadListener!(::Type{LinkedPropertyListener}, target::RecoPlan, targetProp, dict, modDict)
4242
# Find the root plan
4343
root = parent(target)
4444
while !isnothing(parent(root))
@@ -48,7 +48,7 @@ function loadListener!(::Type{LinkedPropertyListener}, target::RecoPlan, targetP
4848
# From the root plan, find the source plan
4949
source = root
5050
for param in dict["plan"][1:end]
51-
source = getproperty(plan, Symbol(param))
51+
source = getproperty(source, Symbol(param))
5252
end
5353
sourceProp = Symbol(dict["field"])
5454

src/RecoPlans/Serialization.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ loadPlan(m::Module, name::AbstractString, modules::Vector{Module}) = loadPlan(pl
5959
Load a `RecoPlan` from a TOML file. The `modules` argument is a vector of modules that contain the types used in the plan.
6060
After loading the plan, the listeners are attached to the properties using `loadListener!`.
6161
"""
62-
function loadPlan(filename::Union{AbstractString, IO}, modules::Vector{Module})
62+
function loadPlan(filename::String, modules)
63+
open(filename) do io
64+
return loadPlan(io, modules)
65+
end
66+
end
67+
function loadPlan(filename::IO, modules::Vector{Module})
6368
dict = TOML.parse(filename)
6469
modDict = createModuleDataTypeDict(modules)
6570
plan = loadPlan!(dict, modDict)
@@ -189,7 +194,7 @@ function loadListeners!(root::RecoPlan, plan::RecoPlan{T}, dict, modDict) where
189194
end
190195
end
191196
for property in propertynames(plan)
192-
value = plan[property]
197+
value = getproperty(plan, property)
193198
if value isa RecoPlan
194199
loadListeners!(root, value, dict[string(property)], modDict)
195200
end
@@ -201,7 +206,7 @@ export loadListener
201206
202207
Load a listener from `dict` and attach it to property `name` of `plan`
203208
"""
204-
function loadListener!(plan, name::Symbol, dict, modDict)
209+
function loadListener!(plan, name::Symbol, dict, modDict)
205210
type = tomlType(dict, modDict)
206211
return loadListener!(type, plan, name, dict, modDict)
207212
end

0 commit comments

Comments
 (0)