Skip to content

Commit ff85ab1

Browse files
authored
Use dispatch for isPrior to allow overloading (#679)
* use dispatch for isprior to allow overloading * update tests for isPrior
1 parent 198c588 commit ff85ab1

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/services/DFGFactor.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,18 @@ setSolverData!(f::DFGFactor, data::GenericFunctionNodeData) = f.solverData = dat
134134
135135
Return `::Bool` on whether given factor `fc::Symbol` is a prior in factor graph `dfg`.
136136
"""
137-
function isPrior(dfg::G, fc::Symbol)::Bool where G <: AbstractDFG
137+
function isPrior(dfg::AbstractDFG, fc::Symbol)
138138
fco = getFactor(dfg, fc)
139-
getFactorType(fco) isa AbstractPrior
139+
isPrior(getFactorType(fco))
140140
end
141141

142+
function isPrior(::AbstractPrior)
143+
return true
144+
end
145+
146+
function isPrior(::AbstractRelative)
147+
return false
148+
end
142149

143150
##==============================================================================
144151
## Layer 2 CRUD (none) and Sets

test/testBlocks.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ struct TestSofttype2 <: InferenceVariable
2121
end
2222

2323

24-
struct TestFunctorInferenceType1 <: FunctorInferenceType end
25-
struct TestFunctorInferenceType2 <: FunctorInferenceType end
24+
struct TestFunctorInferenceType1 <: AbstractRelative end
25+
struct TestFunctorInferenceType2 <: AbstractRelative end
2626

2727
struct TestAbstractPrior <: AbstractPrior end
2828
struct TestAbstractRelativeFactor <: AbstractRelativeFactor end

0 commit comments

Comments
 (0)