@@ -114,11 +114,11 @@ Base.@kwdef struct FactorDFG <: AbstractDFGFactor
114114 nstime:: String
115115 fnctype:: String
116116 solvable:: Int
117- data:: String
117+ data:: Union{ String, Nothing} = nothing # TODO deprecated in v0.27 remove data completely, use state and observJSON
118118 metadata:: String
119119 _version:: String = string (_getDFGVersion ())
120120 state:: FactorState
121- observJSON:: String # serialized opbservation
121+ observJSON:: String # serialized observation
122122 # blobEntries::Vector{Blobentry}#TODO should factor have blob entries?
123123end
124124
@@ -131,7 +131,7 @@ StructTypes.StructType(::Type{FactorDFG}) = StructTypes.UnorderedStruct()
131131StructTypes. idproperty (:: Type{FactorDFG} ) = :id
132132StructTypes. omitempties (:: Type{FactorDFG} ) = (:id ,)
133133
134- # TODO deprecate, added in v0.26 as a bridge to new serialization structure
134+ # TODO deprecate, added in v0.27 as a bridge to new serialization structure
135135function FactorDFG (
136136 id:: Union{UUID, Nothing} ,
137137 label:: Symbol ,
@@ -141,7 +141,7 @@ function FactorDFG(
141141 nstime:: String ,
142142 fnctype:: String ,
143143 solvable:: Int ,
144- data:: String ,
144+ data:: Union{Nothing, String} ,
145145 metadata:: String ,
146146 _version:: String ,
147147 state:: Union{Nothing, FactorState} ,
@@ -300,25 +300,28 @@ function FactorCompute(
300300 variableOrder:: Union{Vector{Symbol}, Tuple} ,
301301 observation:: AbstractFactor ,
302302 state:: FactorState = FactorState (),
303- workmem = Ref {FactorOperationalMemory} () ;
303+ _workmem = nothing ;
304304 tags:: Set{Symbol} = Set {Symbol} (),
305305 timestamp:: Union{DateTime, ZonedDateTime} = now (localzone ()),
306306 solvable:: Int = 1 ,
307307 nstime:: Nanosecond = Nanosecond (0 ),
308308 id:: Union{UUID, Nothing} = nothing ,
309309 smallData:: Dict{Symbol, SmallDataTypes} = Dict {Symbol, SmallDataTypes} (),
310- solverData = nothing
310+ solverData = nothing ,
311311)
312312 if isnothing (solverData)
313313 refsolverData = Ref {GenericFunctionNodeData} () # TODO solverData deprecated in v0.27 WIP
314314 else
315- Base. depwarn (
316- " `FactorCompute` solverData is deprecated" ,
317- :FactorCompute ,
318- )
315+ Base. depwarn (" `FactorCompute` solverData is deprecated" , :FactorCompute )
319316 refsolverData = Ref (solverData)
320317 end
321-
318+
319+ if isnothing (_workmem)
320+ workmem = Ref {FactorOperationalMemory} ()
321+ else
322+ workmem = Ref (_workmem)
323+ end
324+
322325 return FactorCompute (
323326 id,
324327 label,
@@ -362,9 +365,9 @@ function FactorCompute(
362365 )
363366
364367 if solverData. fnc isa FactorOperationalMemory
365- workmem = Ref ( solverData. fnc)
368+ workmem = solverData. fnc
366369 else
367- workmem = Ref {FactorOperationalMemory} ()
370+ workmem = nothing
368371 end
369372
370373 return FactorCompute (
@@ -383,9 +386,20 @@ function FactorCompute(
383386 )
384387end
385388
386- Base. getproperty (x:: FactorCompute , f:: Symbol ) = begin
387- if f == :solvable || f == :solverData
389+ function Base. getproperty (x:: FactorCompute , f:: Symbol )
390+ if f == :solvable
388391 getfield (x, f)[]
392+ elseif f == :solverData
393+ Base. depwarn (
394+ " `FactorCompute` field `$(f) ` is deprecated, use `getObservation`, `getState` or `getWorkmem` instead." ,
395+ :getproperty ,
396+ )
397+ # error("WIP removing direct access, breaking change in v0.27, use `state` or `Workmem` instead.")
398+ if isassigned (getfield (x, f))
399+ getfield (x, f)[]
400+ else
401+ nothing
402+ end
389403 elseif f == :_variableOrderSymbols
390404 [getfield (x, f)... ]
391405 else
0 commit comments