Skip to content

Commit 95aecf5

Browse files
committed
add timestamps to DFGFactor and Summary
1 parent e5826db commit 95aecf5

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

src/entities/DFGFactor.jl

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,30 @@ mutable struct GenericFunctionNodeData{T, S}
3131
end
3232

3333
"""
34-
$(SIGNATURES)
34+
$(TYPEDEF)
35+
3536
Fundamental structure for a DFG factor.
3637
"""
3738
mutable struct DFGFactor{T, S} <: AbstractDFGFactor
3839
label::Symbol
3940
tags::Vector{Symbol}
4041
data::GenericFunctionNodeData{T, S}
4142
solvable::Int
43+
timestamp::DateTime
4244
_internalId::Int64
4345
_variableOrderSymbols::Vector{Symbol}
44-
DFGFactor{T, S}(label::Symbol) where {T, S} = new{T, S}(label, Symbol[], GenericFunctionNodeData{T, S}(), 0, 0, Symbol[])
45-
DFGFactor{T, S}(label::Symbol, _internalId::Int64) where {T, S} = new{T, S}(label, Symbol[], GenericFunctionNodeData{T, S}(), 0, _internalId, Symbol[])
46+
# TODO back to front ts and _internalId for legacy reasons
47+
DFGFactor{T, S}(label::Symbol, _internalId::Int64=0, ts::DateTime=now()) where {T, S} = new{T, S}(label, Symbol[], GenericFunctionNodeData{T, S}(), 0, ts, 0, Symbol[])
48+
# DFGFactor{T, S}(label::Symbol, _internalId::Int64) where {T, S} = new{T, S}(label, Symbol[], GenericFunctionNodeData{T, S}(), 0, now(), _internalId, Symbol[])
4649
end
4750

51+
"""
52+
$(SIGNATURES)
53+
54+
Convenience constructor for DFG factor.
55+
"""
56+
DFGFactor(label::Symbol; tags::Vector{Symbol}=Symbol[], data::GenericFunctionNodeData{T, S}=GenericFunctionNodeData{T, S}(), solvable::Int=0, timestamp::DateTime=now(), _internalId::Int64=0, _variableOrderSymbols::Vector{Symbol}=Symbol[]) where {T, S} = DFGFactor{T,S}(label,tags,data,solvable,timestamp,_internalId,_variableOrderSymbols)
57+
4858
# Simply for convenience - don't export
4959
const PackedFunctionNodeData{T} = GenericFunctionNodeData{T, <: AbstractString}
5060
PackedFunctionNodeData(x1, x2, x3, x4, x5::S, x6::T, x7::String="", x8::Vector{Int}=Int[], x9::Int=0) where {T <: PackedInferenceType, S <: AbstractString} = GenericFunctionNodeData(x1, x2, x3, x4, x5, x6, x7, x8, x9)
@@ -80,6 +90,7 @@ SkeletonDFGFactor(label::Symbol, variableOrderSymbols::Vector{Symbol} = Symbol[]
8090

8191
const FactorDataLevel0 = Union{DFGFactor, DFGFactorSummary, SkeletonDFGFactor}
8292
const FactorDataLevel1 = Union{DFGFactor, DFGFactorSummary}
93+
# const FactorDataLevel2 = Union{DFGFactor}
8394

8495
"""
8596
$SIGNATURES
@@ -100,7 +111,21 @@ $SIGNATURES
100111
101112
Set the tags for a factor.
102113
"""
103-
setTag!s(f::FactorDataLevel0, tags::Vector{Symbol}) = f.tags = tags
114+
setTags!(f::FactorDataLevel0, tags::Vector{Symbol}) = f.tags = tags
115+
116+
"""
117+
$SIGNATURES
118+
119+
Get the timestamp from a DFGFactor object.
120+
"""
121+
timestamp(v::FactorDataLevel1) = v.timestamp
122+
123+
"""
124+
$SIGNATURES
125+
126+
Set the timestamp of a DFGFactor object.
127+
"""
128+
setTimestamp!(v::FactorDataLevel1, ts::DateTime) = v.timestamp = ts
104129

105130
"""
106131
$SIGNATURES

test/interfaceTests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ end
141141
@test setTimestamp!(v1, testTimestamp) == testTimestamp
142142
@test timestamp(v1) == testTimestamp
143143

144+
@test timestamp(f1) == f1.timestamp
145+
testTimestamp = now()
146+
@test setTimestamp!(f1, testTimestamp) == testTimestamp
147+
@test timestamp(f1) == f1.timestamp
148+
144149
@test estimates(v1) == v1.estimateDict
145150
@test estimate(v1, :notfound) == nothing
146151
@test solverData(v1) === v1.solverDataDict[:default]

0 commit comments

Comments
 (0)