From bc50e51fcce4c07dae3bc3afebef56383264869d Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Sun, 9 Aug 2020 15:28:42 +0200 Subject: [PATCH 1/2] Macro to creat a new <:InferenceVariable --- src/DistributedFactorGraphs.jl | 3 +++ src/entities/DFGVariable.jl | 10 ---------- src/services/DFGVariable.jl | 31 +++++++++++++++++++++++++++++++ test/testBlocks.jl | 12 +++++++----- 4 files changed, 41 insertions(+), 15 deletions(-) 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/testBlocks.jl b/test/testBlocks.jl index f4366183..139164f3 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 From 068df11a29e0cf5bcac98a7afd695689a86cd77a Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Mon, 10 Aug 2020 18:27:05 +0200 Subject: [PATCH 2/2] update tests for softtype macro and folderstore --- test/consol_DataEntryBlobTests.jl | 7 +++++++ test/testBlocks.jl | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/test/consol_DataEntryBlobTests.jl b/test/consol_DataEntryBlobTests.jl index 4a091dae..c55ce7f5 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 139164f3..54172463 100644 --- a/test/testBlocks.jl +++ b/test/testBlocks.jl @@ -290,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