Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LimaGroup
Lima2
Commits
26c8a6e3
Commit
26c8a6e3
authored
Feb 16, 2022
by
Alejandro Homs Puron
Browse files
[IO] Use H5 type deduction machinery in writer
parent
819c629a
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/lima/io/h5/wrapper/datatype.hpp
View file @
26c8a6e3
...
...
@@ -23,6 +23,7 @@ namespace io
{
// clang-format off
template
<
typename
T
>
struct
deduct
;
template
<
>
struct
deduct
<
bool
>
{
static
const
hid_t
type
()
{
return
H5T_NATIVE_HBOOL
;
}
};
template
<
>
struct
deduct
<
unsigned
char
>
{
static
const
hid_t
type
()
{
return
H5T_NATIVE_UINT8
;
}
};
template
<
>
struct
deduct
<
signed
char
>
{
static
const
hid_t
type
()
{
return
H5T_NATIVE_INT8
;
}
};
template
<
>
struct
deduct
<
char
>
{
static
const
hid_t
type
()
{
return
H5T_NATIVE_INT8
;
}
};
...
...
include/lima/io/h5/writer.hpp
View file @
26c8a6e3
...
...
@@ -63,47 +63,10 @@ namespace io
static
const
bool
is_supported
=
false
;
};
template
<
>
struct
write_support_private
<
std
::
uint8_t
,
boost
::
gil
::
gray_t
>
template
<
typename
Channel
>
struct
write_support_private
<
Channel
,
boost
::
gil
::
gray_t
>
:
deduct
<
Channel
>
{
static
const
bool
is_supported
=
true
;
static
const
hid_t
type
()
{
return
H5T_NATIVE_UINT8
;
}
};
template
<
>
struct
write_support_private
<
std
::
int8_t
,
boost
::
gil
::
gray_t
>
:
write_support_private
<
std
::
uint8_t
,
boost
::
gil
::
gray_t
>
{
};
template
<
>
struct
write_support_private
<
std
::
uint16_t
,
boost
::
gil
::
gray_t
>
{
static
const
bool
is_supported
=
true
;
static
const
hid_t
type
()
{
return
H5T_NATIVE_UINT16
;
}
};
template
<
>
struct
write_support_private
<
std
::
int16_t
,
boost
::
gil
::
gray_t
>
:
write_support_private
<
std
::
uint16_t
,
boost
::
gil
::
gray_t
>
{
};
template
<
>
struct
write_support_private
<
std
::
uint32_t
,
boost
::
gil
::
gray_t
>
{
static
const
bool
is_supported
=
true
;
static
const
hid_t
type
()
{
return
H5T_NATIVE_UINT32
;
}
};
template
<
>
struct
write_support_private
<
std
::
int32_t
,
boost
::
gil
::
gray_t
>
:
write_support_private
<
std
::
uint32_t
,
boost
::
gil
::
gray_t
>
{
};
template
<
>
struct
write_support_private
<
float
,
boost
::
gil
::
gray_t
>
{
static
const
bool
is_supported
=
true
;
static
const
hid_t
type
()
{
return
H5T_NATIVE_FLOAT
;
}
};
template
<
typename
View
>
...
...
@@ -154,34 +117,8 @@ namespace io
inline
predef_datatype
datatype
(
pixel_enum
px
)
{
hid_t
res
;
switch
(
px
)
{
case
pixel_enum
::
gray8
:
res
=
H5T_NATIVE_UINT8
;
break
;
case
pixel_enum
::
gray8s
:
res
=
H5T_NATIVE_INT8
;
break
;
case
pixel_enum
::
gray16
:
res
=
H5T_NATIVE_UINT16
;
break
;
case
pixel_enum
::
gray16s
:
res
=
H5T_NATIVE_INT16
;
break
;
case
pixel_enum
::
gray32
:
res
=
H5T_NATIVE_UINT32
;
break
;
case
pixel_enum
::
gray32s
:
res
=
H5T_NATIVE_INT32
;
break
;
case
pixel_enum
::
gray32f
:
res
=
H5T_NATIVE_FLOAT
;
break
;
default:
LIMA_THROW_EXCEPTION
(
lima
::
hdf5_error
(
"Unsupported pixel type"
));
}
return
predef_datatype
(
res
);
return
std
::
visit
([](
auto
p
)
{
return
predef_datatype
::
create
<
typename
decltype
(
p
)
::
type
>
();
},
typeof_pixel
(
px
));
}
class
writer
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment