Skip to content

Commit fec5ce5

Browse files
committed
add copyDataEntry!
1 parent 5cbec78 commit fec5ce5

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

src/DataBlobs/services/AbstractDataEntries.jl

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ buildSourceString(dfg::AbstractDFG, label::Symbol) =
2727
"""
2828
$(SIGNATURES)
2929
Get data entry
30+
31+
Also see: [`addDataEntry`](@ref), [`getDataBlob`](@ref), [`listDataEntries`](@ref)
3032
"""
3133
function getDataEntry(var::AbstractDFGVariable, key::Symbol)
3234
!hasDataEntry(var, key) && error("No dataEntry label $(key) found in variable $(getLabel(var))")
@@ -48,19 +50,16 @@ getDataEntry(dfg::AbstractDFG, label::Symbol, key::Union{Symbol,UUID}) = getData
4850
"""
4951
$(SIGNATURES)
5052
Add Data Entry to a DFG variable
53+
Should be extended if DFG variable is not returned by reference.
54+
55+
Also see: [`getDataEntry`](@ref), [`addDataBlob`](@ref), [`copyDataEntry!`](@ref)
5156
"""
5257
function addDataEntry!(var::AbstractDFGVariable, bde::AbstractDataEntry)
5358
haskey(var.dataDict, bde.label) && error("Data entry $(bde.label) already exists in variable $(getLabel(var))")
5459
var.dataDict[bde.label] = bde
5560
return bde
5661
end
5762

58-
59-
"""
60-
$(SIGNATURES)
61-
Add Data Entry to distributed factor graph.
62-
Should be extended if DFG variable is not returned by reference.
63-
"""
6463
function addDataEntry!(dfg::AbstractDFG, label::Symbol, bde::AbstractDataEntry)
6564
return addDataEntry!(getVariable(dfg, label), bde)
6665
end
@@ -173,3 +172,23 @@ function listDataEntrySequence( dfg::AbstractDFG,
173172
entMsk = entReg .!== nothing
174173
ents_[findall(entMsk)] |> _sort
175174
end
175+
176+
"""
177+
$SIGNATURES
178+
179+
Add a data entry into the destination variable which already exists
180+
in a source variable.
181+
182+
See also: [`addDataEntry!`](@ref), [`getDataEntry`](@ref), [`listDataEntries`](@ref), [`getDataBlob`](@ref)
183+
"""
184+
function copyDataEntry!(
185+
dst::AbstractDFG,
186+
dlbl::Symbol,
187+
src::AbstractDFG,
188+
slbl::Symbol,
189+
bllb::Union{Symbol, UUID, <:AbstractString, Regex}
190+
)
191+
#
192+
de = getDataEntry(src, slbl, bllb)
193+
addDataEntry!(dst, dlbl, de)
194+
end

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export copyGraph!, deepcopyGraph, deepcopyGraph!, buildSubgraph, mergeGraph!
197197
export addDataEntry!, getDataEntry, updateDataEntry!, deleteDataEntry!, getDataEntries, listDataEntries, hasDataEntry, hasDataEntry
198198
export listDataEntrySequence
199199
# convenience wrappers
200-
export addDataEntry!
200+
export addDataEntry!, copyDataEntry!
201201
# aliases
202202
export addData!
203203

0 commit comments

Comments
 (0)