Renamed DataSource -> DataSet

This commit is contained in:
Giorgio Calderone 2020-03-16 15:27:22 +01:00
parent decfef901f
commit df01ee01db

View File

@ -16,7 +16,7 @@ export gnuplot, quit, quitall, setverbose,
#_____________________________________________________________________ #_____________________________________________________________________
# -------------------------------------------------------------------- # --------------------------------------------------------------------
mutable struct DataSource mutable struct DataSet
name::String name::String
lines::Vector{String} lines::Vector{String}
end end
@ -34,8 +34,8 @@ end
# -------------------------------------------------------------------- # --------------------------------------------------------------------
@quasiabstract mutable struct DrySession @quasiabstract mutable struct DrySession
sid::Symbol # session ID sid::Symbol # session ID
datas::Vector{DataSource} # data sources datas::Vector{DataSet} # data sets
plots::Vector{SinglePlot} # commands and plot commands (one entry for eahelemec plot of the multiplot) plots::Vector{SinglePlot} # commands and plot commands (one entry for each plot of the multiplot)
curmid::Int # current multiplot ID curmid::Int # current multiplot ID
end end
@ -63,6 +63,7 @@ mutable struct State
State() = new(Dict{Symbol, DrySession}(), true, "gnuplot", :default, Vector{String}(), false, false, 4) State() = new(Dict{Symbol, DrySession}(), true, "gnuplot", :default, Vector{String}(), false, false, 4)
end end
const state = State() const state = State()
state.dry = false
#_____________________________________________________________________ #_____________________________________________________________________
@ -104,18 +105,6 @@ function CheckGnuplotVersion(cmd::AbstractString)
end end
# --------------------------------------------------------------------
function __init__()
global state
try
ver = CheckGnuplotVersion(state.cmd)
state.dry = false
catch err
end
end
# -------------------------------------------------------------------- # --------------------------------------------------------------------
function parseKeywords(; kwargs...) function parseKeywords(; kwargs...)
template = (xrange=NTuple{2, Real}, template = (xrange=NTuple{2, Real},
@ -152,7 +141,7 @@ function DrySession(sid::Symbol)
global state global state
(sid in keys(state.sessions)) && (sid in keys(state.sessions)) &&
error("Gnuplot session $sid is already active") error("Gnuplot session $sid is already active")
out = DrySession(sid, Vector{DataSource}(), [SinglePlot()], 1) out = DrySession(sid, Vector{DataSet}(), [SinglePlot()], 1)
return out return out
end end
@ -203,9 +192,9 @@ function println(gp::Session, str::AbstractString)
end end
println(gp::DrySession, d::DataSource) = nothing println(gp::DrySession, d::DataSet) = nothing
function println(gp::Session, d::DataSource) function println(gp::Session, d::DataSet)
if typeof(gp) == concretetype(Session) if typeof(gp) == concretetype(Session)
if !state.silent && state.verbose if !state.silent && state.verbose
for ii in 1:length(d.lines) for ii in 1:length(d.lines)
@ -266,7 +255,7 @@ end
# -------------------------------------------------------------------- # --------------------------------------------------------------------
function reset(gp::DrySession) function reset(gp::DrySession)
gp.datas = Vector{DataSource}() gp.datas = Vector{DataSet}()
gp.plots = [SinglePlot()] gp.plots = [SinglePlot()]
gp.curmid = 1 gp.curmid = 1
println(gp, "reset session") println(gp, "reset session")
@ -293,7 +282,7 @@ function newdatasource(gp::DrySession, v::Vector{T}; name="") where T <: Abstrac
push!(accum, "$name << EOD") push!(accum, "$name << EOD")
append!(accum, v) append!(accum, v)
push!(accum, "EOD") push!(accum, "EOD")
d = DataSource(name, accum) d = DataSet(name, accum)
push!(gp.datas, d) push!(gp.datas, d)
println(gp, d) # Send directly to gnuplot process println(gp, d) # Send directly to gnuplot process
@ -307,7 +296,7 @@ function newdatasource(gp::DrySession, args...; name="")
name = "\$$name" name = "\$$name"
accum = dataset(args...) accum = dataset(args...)
accum[1] = name * accum[1] accum[1] = name * accum[1]
d = DataSource(name, accum) d = DataSet(name, accum)
push!(gp.datas, d) push!(gp.datas, d)
println(gp, d) # Send directly to gnuplot process println(gp, d) # Send directly to gnuplot process