Skip to content

Commit 80a4758

Browse files
authored
Merge pull request #926 from JuliaRobotics/22Q4/api/packvarsimpler
simpler packVariable (API depr)
2 parents 0a5eab9 + 5165a3f commit 80a4758

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/Deprecated.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ function Base.convert(::Type{DateTime}, ts::ZonedDateTime)
99
return DateTime(ts, Local)
1010
end
1111

12+
13+
## ================================================================================
14+
## Add @deprecate in v0.19, remove after v0.20
15+
##=================================================================================
16+
17+
18+
# TODO ADD DEPRECATION
19+
packVariable(::AbstractDFG, v::DFGVariable) = packVariable(v)
20+
21+
22+
1223
## ================================================================================
1324
## Deprecate before v0.20 - Kept longer with error
1425
##=================================================================================

src/services/Serialization.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ end
121121
##==============================================================================
122122
## Variable Packing and unpacking
123123
##==============================================================================
124-
function packVariable(dfg::AbstractDFG, v::DFGVariable)
124+
function packVariable(v::DFGVariable)
125125
props = Dict{String, Any}()
126126
props["label"] = string(v.label)
127127
props["timestamp"] = Dates.format(v.timestamp, "yyyy-mm-ddTHH:MM:SS.ssszzz")
@@ -138,6 +138,7 @@ function packVariable(dfg::AbstractDFG, v::DFGVariable)
138138
return props #::Dict{String, Any}
139139
end
140140

141+
141142
"""
142143
$(SIGNATURES)
143144
@@ -346,7 +347,8 @@ end
346347

347348

348349
# returns a PackedVariableNodeData
349-
function packVariableNodeData(::G, d::VariableNodeData{T}) where {G <: AbstractDFG, T <: InferenceVariable}
350+
# FIXME, remove ::G
351+
function packVariableNodeData(d::VariableNodeData{T}) where {T <: InferenceVariable}
350352
@debug "Dispatching conversion variable -> packed variable for type $(string(d.variableType))"
351353
# TODO change to Vector{Vector{Float64}} which can be directly packed by JSON
352354
castval = if 0 < length(d.val)
@@ -379,7 +381,11 @@ function packVariableNodeData(::G, d::VariableNodeData{T}) where {G <: AbstractD
379381
d.solveKey)
380382
end
381383

382-
function unpackVariableNodeData(dfg::G, d::Union{<:PackedVariableNodeData,<:NamedTuple}) where G <: AbstractDFG
384+
385+
# @deprecate
386+
packVariableNodeData(::G, d::VariableNodeData{T}) where {G <: AbstractDFG, T <: InferenceVariable} = packVariableNodeData(d)
387+
388+
function unpackVariableNodeData(dfg::G, d::PackedVariableNodeData) where G <: AbstractDFG
383389
@debug "Dispatching conversion packed variable -> variable for type $(string(d.variableType))"
384390
# Figuring out the variableType
385391
# TODO deprecated remove in v0.11 - for backward compatibility for saved variableTypes.

0 commit comments

Comments
 (0)