Skip to content

Commit 8c1e2f1

Browse files
authored
Bloblet type (#1190)
Co-authored-by: Johannes Terblanche <[email protected]>
1 parent a93f8da commit 8c1e2f1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ end
521521
include("errors.jl")
522522

523523
include("entities/AbstractDFG.jl")
524+
include("entities/Bloblet.jl")
524525

525526
# Data Blob extensions
526527
include("DataBlobs/entities/BlobEntry.jl")

src/entities/Bloblet.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
struct Bloblet
2+
label::Symbol
3+
val::String
4+
end
5+
6+
const Bloblets = LittleDict{Symbol, Bloblet}
7+
8+
StructUtils.structlike(::Type{Bloblets}) = false
9+
StructUtils.arraylike(::Type{Bloblets}) = false
10+
StructUtils.dictlike(::Type{Bloblets}) = false
11+
StructUtils.noarg(::Type{Bloblets}) = false
12+
13+
function StructUtils.lower(bloblet::Bloblets)
14+
return map(collect(values(bloblet))) do (m)
15+
return (label = m.label, val = m.val)
16+
end
17+
end
18+
19+
function StructUtils.lift(::Type{Bloblets}, json_vector::Vector)
20+
return Bloblets(
21+
Symbol(x["label"]) => Bloblet(Symbol(x["label"]), x["val"]) for x in json_vector
22+
)
23+
end

0 commit comments

Comments
 (0)