-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
19 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,30 @@ | ||
""" | ||
Abstract type for dimension metadata wrappers. | ||
""" | ||
abstract type Metadata end | ||
abstract type Metadata{K,V} <: AbstractDict{K,V} end | ||
|
||
(::Type{T})() where T <: Metadata = T(Dict()) | ||
|
||
val(metadata::Metadata) = metadata.val | ||
|
||
abstract type AbstractDimMetadata <: Metadata end | ||
Base.get(metadata::Metadata, args...) = get(val(metadata), args...) | ||
Base.getindex(metadata::Metadata, args...) = getindex(val(metadata), args...) | ||
Base.setindex!(metadata::Metadata, args...) = setindex!(val(metadata), args...) | ||
Base.keys(metadata::Metadata) = keys(val(metadata)) | ||
Base.iterate(metadata::Metadata, args...) = iterate(val(metadata), args...) | ||
Base.IteratorSize(::Metadata{M}) where M = IteratorSize(M) | ||
Base.IteratorEltype(::Metadata{M}) where M = IteratorEltype(M) | ||
Base.eltype(::Metadata{M}) where M = eltype(M) | ||
Base.length(metadata::Metadata) = length(val(metadata)) | ||
|
||
abstract type AbstractArrayMetadata <: Metadata end | ||
abstract type AbstractDimMetadata{K,V} <: Metadata{K,V} end | ||
|
||
struct ArrayMetadata{M} <: AbstractArrayMetadata | ||
val::M | ||
end | ||
abstract type AbstractArrayMetadata{K,V} <: Metadata{K,V} end | ||
|
||
struct DimMetadata{M} <: AbstractDimMetadata | ||
val::M | ||
struct ArrayMetadata{K,V} <: AbstractArrayMetadata{K,V} | ||
val::Dict{K,V} | ||
end | ||
|
||
struct DimMetadata{K,V} <: AbstractDimMetadata{K,V} | ||
val::Dict{K,V} | ||
end |