Skip to content

Commit ed6ea5b

Browse files
committed
add getFactorType
1 parent fa7503e commit ed6ea5b

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

src/Common.jl

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,49 @@ function sortVarNested(vars::Vector{Symbol})::Vector{Symbol}
7676
return retvars
7777
end
7878

79+
"""
80+
$SIGNATURES
81+
82+
Return the factor type used in a `::DFGFactor`.
83+
84+
Notes:
85+
- OBSOLETE, use newer getFactorType instead.
86+
87+
Related
88+
89+
getFactorType
90+
"""
91+
function getfnctype(data::GenericFunctionNodeData)
92+
# TODO what is this?
93+
if typeof(data).name.name == :VariableNodeData
94+
return VariableNodeData
95+
end
96+
97+
# this looks right
98+
return data.fnc.usrfnc!
99+
end
100+
function getfnctype(fact::DFGFactor; solveKey::Symbol=:default)
101+
data = getData(fact) # TODO , solveKey=solveKey)
102+
return getfnctype(data)
103+
end
104+
function getfnctype(dfg::T, lbl::Symbol; solveKey::Symbol=:default) where T <: AbstractDFG
105+
getfnctype(getFactor(dfg, exvertid))
106+
end
107+
108+
"""
109+
$SIGNATURES
110+
111+
Return user factor type from factor graph identified by label `::Symbol`.
112+
113+
Notes
114+
- Replaces older `getfnctype`.
115+
"""
116+
getFactorType(data::GenericFunctionNodeData) = data.fnc.usrfnc!
117+
getFactorType(fct::DFGFactor) = getFactorType(getData(fct))
118+
function getFactorType(dfg::G, lbl::Symbol) where G <: AbstractDFG
119+
getFactorType(getFactor(dfg, lbl))
120+
end
121+
79122

80123
"""
81124
$SIGNATURES
@@ -102,3 +145,29 @@ function lsfPriors(dfg::G)::Vector{Symbol} where G <: AbstractDFG
102145
end
103146
return priors
104147
end
148+
149+
"""
150+
$(SIGNATURES)
151+
152+
Variable nodes softtype information holding a variety of meta data associated with the type of variable stored in that node of the factor graph.
153+
154+
Related
155+
156+
getVariableType
157+
"""
158+
function getSofttype(vnd::VariableNodeData)
159+
return vnd.softtype
160+
end
161+
function getSofttype(v::DFGVariable; solveKey::Symbol=:default)
162+
return getSofttype(getData(v, solveKey=solveKey))
163+
end
164+
165+
"""
166+
$SIGNATURES
167+
168+
Return the DFGVariable softtype in factor graph `dfg<:AbstractDFG` and label `::Symbol`.
169+
"""
170+
getVariableType(var::DFGVariable; solveKey::Symbol=:default) = getSofttype(var, solvekey=solvekey)
171+
function getVariableType(dfg::G, lbl::Symbol; solveKey::Symbol=:default) where G <: AbstractDFG
172+
getVariableType(getVariable(dfg, lbl), solveKey=solveKey)
173+
end

src/DistributedFactorGraphs.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ export getSerializationModule, setSerializationModule!
3232
export pack, unpack
3333

3434
export isPrior, lsfPriors
35+
export getVariableType, getSofttype
36+
export getFactorType, getfnctype
3537

3638
include("services/AbstractDFG.jl")
3739
include("services/DFGVariable.jl")

0 commit comments

Comments
 (0)