Skip to content

Commit

Permalink
Merge pull request #83 from JuliaRobotics/maintenance/3Q19/hasfactor
Browse files Browse the repository at this point in the history
add features from IIF
  • Loading branch information
dehann authored Aug 20, 2019
2 parents 04ae091 + b47099b commit 8ecf0af
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/NeedsAHome.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

export hasFactor, hasVariable, isInitialized
export hasFactor, hasVariable, isInitialized, getFactorFunction, isVariable, isFactor

"""
$SIGNATURES
Expand Down Expand Up @@ -38,3 +38,37 @@ end
function isInitialized(dfg::G, label::Symbol; key::Symbol=:default)::Bool where G <: AbstractDFG
return isInitialized(getVariable(dfg, label), key=key)
end


"""
$SIGNATURES
Return whether `sym::Symbol` represents a variable vertex in the graph.
"""
isVariable(dfg::G, sym::Symbol) where G <: AbstractDFG = hasVariable(dfg, sym)

"""
$SIGNATURES
Return whether `sym::Symbol` represents a factor vertex in the graph.
"""
isFactor(dfg::G, sym::Symbol) where G <: AbstractDFG = hasFactor(dfg, sym)

"""
$SIGNATURES
Return reference to the user factor in `<:AbstractDFG` identified by `::Symbol`.
"""
getFactorFunction(fcd::GenericFunctionNodeData) = fcd.fnc.usrfnc!
getFactorFunction(fc::DFGFactor) = getFactorFunction(getData(fc))
function getFactorFunction(dfg::G, fsym::Symbol) where G <: AbstractDFG
getFactorFunction(getFactor(dfg, fsym))
end


"""
$SIGNATURES
Display and return to console the user factor identified by tag name.
"""
showFactor(fgl::G, fsym::Symbol) where G <: AbstractDFG = @show getFactor(fgl,fsym)

0 comments on commit 8ecf0af

Please sign in to comment.