diff --git a/src/DistributedFactorGraphs.jl b/src/DistributedFactorGraphs.jl index b3733a0d..8f2cb90e 100644 --- a/src/DistributedFactorGraphs.jl +++ b/src/DistributedFactorGraphs.jl @@ -123,6 +123,9 @@ export getSolverData export getVariableType +# Softtype functions +export getDimension, getManifolds + # Small Data CRUD export SmallDataTypes, getSmallData, addSmallData!, updateSmallData!, deleteSmallData!, listSmallData, emptySmallData! export getSmallData, setSmallData! diff --git a/src/entities/DFGVariable.jl b/src/entities/DFGVariable.jl index ea2cd99a..39898f9e 100644 --- a/src/entities/DFGVariable.jl +++ b/src/entities/DFGVariable.jl @@ -4,16 +4,6 @@ abstract type InferenceVariable end -""" - $SIGNATURES -Interface function to return the softtype dimention of an InferenceVariable, extend this function for all Types<:InferenceVariable. -""" -function getDimension end -""" - $SIGNATURES -Interface function to return the softtype manifolds of an InferenceVariable, extend this function for all Types<:InferenceVariable. -""" -function getManifolds end ##============================================================================== ## VariableNodeData ##============================================================================== diff --git a/src/services/DFGVariable.jl b/src/services/DFGVariable.jl index 239c6fda..79894323 100644 --- a/src/services/DFGVariable.jl +++ b/src/services/DFGVariable.jl @@ -51,6 +51,37 @@ Alias for [`getSofttype`](@ref). """ getVariableType(args...) = getSofttype(args...) + +##------------------------------------------------------------------------------ +## InferenceVariable +##------------------------------------------------------------------------------ +""" + $SIGNATURES +Interface function to return the softtype dimention of an InferenceVariable, extend this function for all Types<:InferenceVariable. +""" +function getDimension end +""" + $SIGNATURES +Interface function to return the softtype manifolds of an InferenceVariable, extend this function for all Types<:InferenceVariable. +""" +function getManifolds end + +""" + @defVariable StructName dimension manifolds +A macro to create a new variable with name `StructName`, dimension and manifolds. +Example: +``` +DFG.@defVariable Pose2 3 (:Euclid, :Euclid, :Circular) +``` +""" +macro defVariable(structname, dimension::Int, manifolds)#::Vararg{Symbol})#NTuple{dimension, Symbol}) + # :(struct $structname <: InferenceVariable end) + return esc(quote + struct $structname <: InferenceVariable end + DistributedFactorGraphs.getDimension(::$structname) = $dimension + DistributedFactorGraphs.getManifolds(::$structname) = $manifolds + end) +end ##------------------------------------------------------------------------------ ## solvedCount ##------------------------------------------------------------------------------ diff --git a/test/consol_DataEntryBlobTests.jl b/test/consol_DataEntryBlobTests.jl index df87775e..bbc00da7 100644 --- a/test/consol_DataEntryBlobTests.jl +++ b/test/consol_DataEntryBlobTests.jl @@ -90,6 +90,13 @@ ade2,adb2 = addData!(dfg, :x2, deepcopy(ade), dataset1) @test adb == adb2# == adb3 deleteData!(dfg, :x2, :random) + +#test default folder store +dfs = FolderStore("/tmp/defaultfolderstore") +@test dfs.folder == "/tmp/defaultfolderstore" +@test dfs.key == :default_folder_store +@test dfs isa FolderStore{Vector{UInt8}} + ##============================================================================== ## Unimplemented store ##============================================================================== diff --git a/test/testBlocks.jl b/test/testBlocks.jl index f4366183..54172463 100644 --- a/test/testBlocks.jl +++ b/test/testBlocks.jl @@ -6,11 +6,13 @@ using UUIDs import Base: convert # Test InferenceVariable Types -struct TestSofttype1 <: InferenceVariable - dims::Int - manifolds::Tuple{Symbol} - TestSofttype1() = new(1,(:Euclid,)) -end +# struct TestSofttype1 <: InferenceVariable +# dims::Int +# manifolds::Tuple{Symbol} +# TestSofttype1() = new(1,(:Euclid,)) +# end + +DFG.@defVariable TestSofttype1 1 (:Euclid,) struct TestSofttype2 <: InferenceVariable dims::Int @@ -288,9 +290,10 @@ function DFGVariableSCA() #no accessors on dataDict, only CRUD - #deprecated - # @test @test_deprecated solverData(v1, :default) === v1.solverDataDict[:default] - + #softtype functions + testvar = TestSofttype1() + @test getDimension(testvar) == 1 + @test getManifolds(testvar) == (:Euclid,) # #TODO sort out # getPPEs