diff --git a/ext/SolidStateDetectorsLegendHDF5IOExt.jl b/ext/SolidStateDetectorsLegendHDF5IOExt.jl index 3490003b1..64665858f 100644 --- a/ext/SolidStateDetectorsLegendHDF5IOExt.jl +++ b/ext/SolidStateDetectorsLegendHDF5IOExt.jl @@ -68,15 +68,24 @@ function SolidStateDetectors.simulate_waveforms( mcevents::AbstractVector{<:Name end -# Add support for reading and writing CartesianPoint and CylindricalPoint using LegendHDF5IO -function __init__() - LegendHDF5IO._datatype_dict["cartesianpoint"] = CartesianPoint - LegendHDF5IO._datatype_dict["cylindricalpoint"] = CylindricalPoint +# Add support for reading and writing CartesianPoint and CylindricalPoint using LegendHDF5IO. +# LegendHDF5IO v0.2 registers datatype names with `register_datatype!`, v0.1 through its +# datatype dictionary and `datatype_to_string`: +if isdefined(LegendHDF5IO, :register_datatype!) + function __init__() + LegendHDF5IO.register_datatype!("cartesianpoint", CartesianPoint) + LegendHDF5IO.register_datatype!("cylindricalpoint", CylindricalPoint) + end +else + function __init__() + LegendHDF5IO._datatype_dict["cartesianpoint"] = CartesianPoint + LegendHDF5IO._datatype_dict["cylindricalpoint"] = CylindricalPoint + end + + LegendHDF5IO.datatype_to_string(::Type{<:CartesianPoint}) = "cartesianpoint" + LegendHDF5IO.datatype_to_string(::Type{<:CylindricalPoint}) = "cylindricalpoint" end -LegendHDF5IO.datatype_to_string(::Type{<:CartesianPoint}) = "cartesianpoint" -LegendHDF5IO.datatype_to_string(::Type{<:CylindricalPoint}) = "cylindricalpoint" - # support writing points to HDF5 file using LH5Array diff --git a/test/Project.toml b/test/Project.toml index 0b7a10ffc..e1eb909df 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -23,4 +23,4 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" [compat] Geant4 = "0.3.1" LegendDataTypes = "0.1.3" -LegendHDF5IO = "0.1" +LegendHDF5IO = "0.1, 0.2"