BioCMAMC-ST
species_name_extractor.hpp
1
#ifndef __SPECIES_NAME_EXTRACTOR_HPP__
2
#define __SPECIES_NAME_EXTRACTOR_HPP__
3
4
#include <mc/traits.hpp>
5
6
namespace
impl
7
{
8
9
inline
auto
10
iota_species
(std::size_t n_c)
11
{
12
std::vector<std::string> v(n_c);
13
14
std::generate(
15
v.begin(), v.end(), [n = 0]()
mutable
{ return std::to_string(n++); });
16
17
return
v;
18
}
19
20
template
<ModelType T>
21
requires
(!
has_species_name<T>
)
22
auto
23
get_species_names_impl
()
24
{
25
return
iota_species
(T::n_c);
26
}
27
28
template
<ModelType T>
29
requires
has_species_name<T>
30
auto
31
get_species_names_impl
()
32
{
33
auto
rd = T::species();
34
35
if
(rd.size() == 0)
36
{
37
return
iota_species
(T::n_c);
38
}
39
40
if
(rd.size() != T::n_c && rd.size() != 0)
41
{
42
throw
std::invalid_argument(
"Missing species names"
);
43
}
44
45
return
std::vector<std::string>(rd.begin(), rd.end());
46
}
47
}
// namespace impl
48
49
#endif
has_species_name
Definition
traits.hpp:58
impl
Definition
species_name_extractor.hpp:7
impl::iota_species
auto iota_species(std::size_t n_c)
Definition
species_name_extractor.hpp:10
impl::get_species_names_impl
auto get_species_names_impl()
Definition
species_name_extractor.hpp:23
apps
libs
mc
includes
species_name_extractor.hpp
Generated by
1.14.0