@@ -94,13 +94,23 @@ function setSessionData(dfg::AbstractDFG, data::Dict{Symbol, String})::Bool
94
94
return true
95
95
end
96
96
97
- pushUserData! (dfg:: AbstractDFG , pair:: Pair{Symbol,String} ) = push! (dfg. userData, pair)
98
- pushRobotData! (dfg:: AbstractDFG , pair:: Pair{Symbol,String} ) = push! (dfg. userData, pair)
99
- pushSessionData! (dfg:: AbstractDFG , pair:: Pair{Symbol,String} ) = push! (dfg. userData, pair)
97
+ # NOTE with API standardization this should become something like:
98
+ # JT, I however do not feel we should force it, as I prever dot notation
99
+ getUserData (dfg:: AbstractDFG , key:: Symbol ):: Dict{Symbol, String} = dfg. UserData[key]
100
+ getRobotData (dfg:: AbstractDFG , key:: Symbol ):: Dict{Symbol, String} = dfg. RobotData[key]
101
+ getSessionData (dfg:: AbstractDFG , key:: Symbol ):: Dict{Symbol, String} = dfg. SessionData[key]
100
102
101
- popUserData! (dfg:: AbstractDFG , key:: Symbol ) = pop! (dfg. userData, key)
102
- popRobotData! (dfg:: AbstractDFG , key:: Symbol ) = pop! (dfg. userData, key)
103
- popSessionData! (dfg:: AbstractDFG , key:: Symbol ) = pop! (dfg. userData, key)
103
+ updateUserData! (dfg:: AbstractDFG , pair:: Pair{Symbol,String} ) = push! (dfg. userData, pair)
104
+ updateRobotData! (dfg:: AbstractDFG , pair:: Pair{Symbol,String} ) = push! (dfg. userData, pair)
105
+ updateSessionData! (dfg:: AbstractDFG , pair:: Pair{Symbol,String} ) = push! (dfg. userData, pair)
106
+
107
+ deleteUserData! (dfg:: AbstractDFG , key:: Symbol ) = pop! (dfg. userData, key)
108
+ deleteRobotData! (dfg:: AbstractDFG , key:: Symbol ) = pop! (dfg. userData, key)
109
+ deleteSessionData! (dfg:: AbstractDFG , key:: Symbol ) = pop! (dfg. userData, key)
110
+
111
+ emptyUserData! (dfg:: AbstractDFG ) = empty! (dfg. userData)
112
+ emptyRobotData! (dfg:: AbstractDFG ) = empty! (dfg. userData)
113
+ emptySessionData! (dfg:: AbstractDFG ) = empty! (dfg. userData)
104
114
105
115
"""
106
116
$(SIGNATURES)
@@ -432,6 +442,88 @@ function _copyIntoGraph!(sourceDFG::G, destDFG::H, variableFactorLabels::Vector{
432
442
return nothing
433
443
end
434
444
445
+ # TODO UNTESTED and NOT FILLED IN, just to define function signatures
446
+ """
447
+ $(SIGNATURES)
448
+ """
449
+ function getVariableSolverData (dfg:: AbstractDFG , variablekey:: Symbol , solvekey:: Symbol = :default )
450
+ return solverData (getVariable (dfg, variablekey), solvekey)
451
+ end
452
+
453
+ """
454
+ $(SIGNATURES)
455
+
456
+ """
457
+ function addVariableSolverData! (dfg:: AbstractDFG , variablekey:: Symbol , vnd:: VariableNodeData , solvekey:: Symbol = :default )
458
+ # for InMemoryDFGTypes, cloud would update here
459
+ error (" not implemented" )
460
+
461
+ var = getVariable (dfg, variablekey)
462
+
463
+ if haskey (var. solverDataDict, solvekey)
464
+ error (" VariableNodeData '$(solvekey) ' already exists" )
465
+ end
466
+
467
+ var. solverDataDict[solvekey] = vnd
468
+ # setSolverData!(var, vnd, solvekey)
469
+
470
+ end
471
+
472
+ """
473
+ $(SIGNATURES)
474
+ Add a new solver data entry from a deepcopy of the source variable solver data.
475
+ """
476
+ addVariableSolverData! (dfg:: AbstractDFG , sourceVariable:: DFGVariable , solvekey:: Symbol = :default ) =
477
+ addVariableSolverData! (dfg, sourceVariable. label, deepcopy (solverData (sourceVariable, solvekey)), solvekey)
478
+
479
+
480
+ """
481
+ $(SIGNATURES)
482
+ """
483
+ function updateVariableSolverData! (dfg:: AbstractDFG , variablekey:: Symbol , vnd:: VariableNodeData , solvekey:: Symbol = :default )
484
+
485
+ # This is basically just setSolverData
486
+ var = getVariable (dfg, variablekey)
487
+
488
+ # for InMemoryDFGTypes, cloud would update here
489
+ # var.solverDataDict[solvekey] = deepcopy(vnd)
490
+ setSolverData! (var, vnd, solvekey)
491
+ end
492
+
493
+ """
494
+ $(SIGNATURES)
495
+ Update the destination variable solver data with a deepcopy of the source variable solver data
496
+ """
497
+ updateVariableSolverData! (dfg:: AbstractDFG , sourceVariable:: DFGVariable , solvekey:: Symbol = :default ) =
498
+ updateVariableSolverData! (dfg, sourceVariable. label, deepcopy (solverData (sourceVariable, solvekey)), solvekey)
499
+
500
+ function updateVariableSolverData! (dfg:: AbstractDFG , sourceVariables:: Vector{DFGVariable} , solvekey:: Symbol = :default )
501
+ # I think cloud would do this in bulk for speed
502
+ for var in sourceVariables
503
+ updateVariableSolverData! (dfg, solverData (var, solvekey), var. label, solvekey)
504
+ end
505
+ end
506
+
507
+ """
508
+ $(SIGNATURES)
509
+ """
510
+ function deleteVariableSolverData! (dfg:: AbstractDFG , variablekey:: Symbol , solvekey:: Symbol = :default )
511
+
512
+ var = getVariable (dfg, variablekey)
513
+
514
+ if ! haskey (var. solverDataDict, solvekey)
515
+ error (" VariableNodeData '$(solvekey) ' does not exist" )
516
+ end
517
+
518
+ vnd = pop! (var. solverDataDict, solvekey)
519
+
520
+ return vnd
521
+ end
522
+
523
+ # deleteVariableSolverData!(dfg::AbstractDFG, sourceVariable::DFGVariable, solvekey::Symbol=:default) =
524
+ # deleteVariableSolverData!(dfg, sourceVariable.label, solvekey)
525
+
526
+
435
527
"""
436
528
$(SIGNATURES)
437
529
Merges and updates solver and estimate data for a variable (variable can be from another graph).
@@ -642,11 +734,11 @@ Checks whether it both exists in the graph and is a variable.
642
734
(If you rather want a quick for type, just do node isa DFGVariable)
643
735
"""
644
736
function isVariable (dfg:: G , sym:: Symbol ) where G <: AbstractDFG
645
- error (" isVariable not implemented for $(typeof (dfg)) " )
737
+ error (" isVariable not implemented for $(typeof (dfg)) " )
646
738
end
647
739
# Alias - bit ridiculous but know it'll come up at some point. Does existential and type check.
648
740
function isVariable (dfg:: G , node:: N ):: Bool where {G <: AbstractDFG , N <: DFGNode }
649
- return isVariable (dfg, node. label)
741
+ return isVariable (dfg, node. label)
650
742
end
651
743
652
744
"""
@@ -657,11 +749,11 @@ Checks whether it both exists in the graph and is a factor.
657
749
(If you rather want a quicker for type, just do node isa DFGFactor)
658
750
"""
659
751
function isFactor (dfg:: G , sym:: Symbol ) where G <: AbstractDFG
660
- error (" isFactor not implemented for $(typeof (dfg)) " )
752
+ error (" isFactor not implemented for $(typeof (dfg)) " )
661
753
end
662
754
# Alias - bit ridiculous but know it'll come up at some point. Does existential and type check.
663
755
function isFactor (dfg:: G , node:: N ):: Bool where {G <: AbstractDFG , N <: DFGNode }
664
- return isFactor (dfg, node. label)
756
+ return isFactor (dfg, node. label)
665
757
end
666
758
667
759
"""
0 commit comments