Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VectorMapData #6

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/PSRBridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ include("abstract.jl")
include("data/adjusted_vector.jl")
include("data/any.jl")
include("data/map.jl")
include("data/vector_map.jl")
include("data/static_vector.jl")
include("data/time_series_file.jl")
include("data/time_series_vector.jl")
Expand Down
46 changes: 46 additions & 0 deletions src/data/vector_map.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@kwdef mutable struct VectorMapData <: AbstractData
collection_to::String
id::String
data::Vector{Vector{Int}} = []
end

function Base.convert(::Type{MapData}, tuple::Tuple{String, String})
return MapData(collection_to = tuple[1], id = tuple[2])
end

function Base.getindex(parameter::MapData, i::Integer)
return parameter.data[i]
end

function Base.length(parameter::MapData)
return length(parameter.data)
end

function Base.isempty(parameter::MapData)
return isempty(parameter.data)
end

function Base.iterate(parameter::MapData)
return iterate(parameter.data)
end

function Base.iterate(parameter::PSRBridge.MapData, i::Integer)
return iterate(parameter.data, i)
end

function raw_data(parameter::MapData)
return parameter.data
end

function initialize!(parameter::MapData, collection::AbstractCollection, db::DatabaseSQLite; kwargs...)
parameter.data = PSRI.get_vector_map(inputs.db, collection.id, parameter.collection_to, parameter.id)
return nothing
end

function update!(parameter::MapData, collection::AbstractCollection, db::DatabaseSQLite; kwargs...)
return nothing
end

function finalize!(parameter::MapData)
return nothing
end