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
Gauthier Quesnel
irritator
Commits
d6947c1c
Commit
d6947c1c
authored
Jun 07, 2021
by
Gauthier Quesnel
Browse files
external-sources: add enum to string functions
parent
16f26f14
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/gui/sources.cpp
View file @
d6947c1c
...
...
@@ -318,7 +318,7 @@ editor::show_sources_window(bool* is_show)
ImGui
::
TextUnformatted
(
cst_src
->
name
.
c_str
());
ImGui
::
TableNextColumn
();
ImGui
::
TextUnformatted
(
external_source_str
[
ordinal
(
external_source_type
::
constant
)
]
);
external_source_str
(
external_source_type
::
constant
));
ImGui
::
TableNextColumn
();
ImGui
::
Text
(
"%"
PRIu64
,
cst_src
->
buffer
.
size
());
ImGui
::
TableNextColumn
();
...
...
@@ -362,7 +362,7 @@ editor::show_sources_window(bool* is_show)
ImGui
::
TextUnformatted
(
txt_src
->
name
.
c_str
());
ImGui
::
TableNextColumn
();
ImGui
::
TextUnformatted
(
external_source_str
[
ordinal
(
external_source_type
::
text_file
)
]
);
external_source_str
(
external_source_type
::
text_file
));
ImGui
::
TableNextColumn
();
ImGui
::
Text
(
"%"
PRIu64
,
txt_src
->
buffer
.
size
);
ImGui
::
TableNextColumn
();
...
...
@@ -394,7 +394,7 @@ editor::show_sources_window(bool* is_show)
ImGui
::
TextUnformatted
(
bin_src
->
name
.
c_str
());
ImGui
::
TableNextColumn
();
ImGui
::
TextUnformatted
(
external_source_str
[
ordinal
(
external_source_type
::
binary_file
)
]
);
external_source_str
(
external_source_type
::
binary_file
));
ImGui
::
TableNextColumn
();
ImGui
::
Text
(
"%"
PRIu64
,
bin_src
->
buffer
.
size
);
ImGui
::
TableNextColumn
();
...
...
@@ -424,12 +424,11 @@ editor::show_sources_window(bool* is_show)
ImGui
::
TextUnformatted
(
rnd_src
->
name
.
c_str
());
ImGui
::
TableNextColumn
();
ImGui
::
TextUnformatted
(
external_source_str
[
ordinal
(
external_source_type
::
random
)
]
);
external_source_str
(
external_source_type
::
random
));
ImGui
::
TableNextColumn
();
ImGui
::
Text
(
"%"
PRIu64
,
rnd_src
->
buffer
.
size
);
ImGui
::
TableNextColumn
();
ImGui
::
TextUnformatted
(
distribution_type_str
[
ordinal
(
rnd_src
->
distribution
)]);
ImGui
::
TextUnformatted
(
distribution_str
(
rnd_src
->
distribution
));
}
ImGui
::
EndTable
();
...
...
lib/include/irritator/external_source.hpp
View file @
d6947c1c
...
...
@@ -140,10 +140,16 @@ external_source_type_cast(int value, external_source_type* type) noexcept
return
true
;
}
static
inline
const
char
*
external_source_str
[]
=
{
"binary_file"
,
"constant"
,
"random"
,
"text_file"
};
static
inline
const
char
*
external_source_type_string
[]
=
{
"binary_file"
,
"constant"
,
"random"
,
"text_file"
};
inline
const
char
*
external_source_str
(
const
external_source_type
type
)
noexcept
{
return
external_source_type_string
[
static_cast
<
int
>
(
type
)];
}
enum
class
distribution_type
{
...
...
@@ -166,13 +172,20 @@ enum class distribution_type
weibull
,
};
static
inline
const
char
*
distribution_type_str
[]
=
{
static
const
char
*
distribution_type_str
ing
[]
=
{
"bernouilli"
,
"binomial"
,
"cauchy"
,
"chi_squared"
,
"exponential"
,
"exterme_value"
,
"fisher_f"
,
"gamma"
,
"geometric"
,
"lognormal"
,
"negative_binomial"
,
"normal"
,
"poisson"
,
"student_t"
,
"uniform_int"
,
"uniform_real"
,
"weibull"
};
inline
const
char
*
distribution_str
(
const
distribution_type
type
)
noexcept
{
return
distribution_type_string
[
static_cast
<
int
>
(
type
)];
}
struct
constant_source
{
small_string
<
23
>
name
;
...
...
lib/include/irritator/io.hpp
View file @
d6947c1c
...
...
@@ -662,18 +662,18 @@ private:
if
(
!
(
is
>>
type_str
))
return
status
::
io_file_format_error
;
auto
it
=
binary_find
(
std
::
begin
(
distribution_type_str
),
std
::
end
(
distribution_type_str
),
auto
it
=
binary_find
(
std
::
begin
(
distribution_type_str
ing
),
std
::
end
(
distribution_type_str
ing
),
type_str
,
[](
const
char
*
left
,
const
char
*
right
)
{
return
std
::
strcmp
(
left
,
right
)
==
0
;
});
if
(
it
==
std
::
end
(
distribution_type_str
))
if
(
it
==
std
::
end
(
distribution_type_str
ing
))
return
status
::
io_file_format_error
;
const
auto
dist_id
=
std
::
distance
(
std
::
begin
(
distribution_type_str
),
it
);
std
::
distance
(
std
::
begin
(
distribution_type_str
ing
),
it
);
auto
&
elem
=
srcs
.
random_sources
.
alloc
();
if
(
auto
ret
=
elem
.
init
(
srcs
.
block_size
,
srcs
.
block_number
);
...
...
@@ -1544,8 +1544,7 @@ struct writer
const
auto
id
=
srcs
.
random_sources
.
get_id
(
src
);
const
auto
index
=
get_index
(
id
);
os
<<
index
<<
' '
<<
distribution_type_str
[
ordinal
(
src
->
distribution
)];
os
<<
index
<<
' '
<<
distribution_str
(
src
->
distribution
);
write
(
*
src
);
...
...
Write
Preview
Markdown
is supported
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