40#include <unordered_map>
66 return ::tim::get_hash(std::forward<std::string>(key));
71template <
int I,
int V,
typename... Args>
80 opaque_array.push_back(
81 { component::factory::get_opaque<type>(std::forward<Args>(args)...),
82 component::factory::get_typeids<type>() });
89template <
int I,
int V,
typename... Args>
100template <
int I,
typename Tp,
typename... Args>
109 obj.template initialize<type>(std::forward<Args>(args)...);
115template <
int I,
typename Tp,
typename... Args>
132 if(_id !=
"TIMEMORY_COMPONENTS_END")
134 using match_func_t = bool (*)(
const char*);
136 _vec.emplace_back(_func);
137 _idx.emplace_back(I);
151template <
typename Tp,
int... Ints,
typename... Args>
156 do_enumerator_init<Ints>(obj, idx, std::forward<Args>(args)...));
161template <
typename Tp,
int... Ints,
typename... Args>
166 std::vector<opaque_pair_t> opaque_array{};
168 opaque_array, idx, std::forward<Args>(args)...));
169 for(
auto&& itr : opaque_array)
170 obj.insert(std::move(itr.first), std::move(itr.second));
175template <
typename Tp,
int... Ints,
typename... Args>
180 std::vector<opaque_pair_t> opaque_array{};
182 opaque_array, idx, std::forward<Args>(args)...));
183 for(
auto&& itr : opaque_array)
189template <
typename Tp,
int... Ints,
typename... Args>
194 std::vector<opaque_pair_t> opaque_array{};
196 opaque_array, idx, std::forward<Args>(args)...));
197 for(
auto&& itr : opaque_array)
198 obj.configure(std::move(itr.first), std::move(itr.second));
203template <
int... Ints>
217template <
typename Tp,
typename Arg,
typename... Args>
222 std::forward<Arg>(arg), std::forward<Args>(args)...);
227template <
typename Tp,
typename Arg,
typename... Args>
229insert(Tp& obj,
int idx, Arg&& arg, Args&&... args)
232 std::forward<Arg>(arg), std::forward<Args>(args)...);
237template <
typename Tp,
typename Arg,
typename... Args>
242 std::forward<Arg>(arg), std::forward<Args>(args)...);
247template <
typename Tp,
typename Arg,
typename... Args>
252 std::forward<Arg>(arg), std::forward<Args>(args)...);
261 std::function<void(
const char*)>>;
262 static auto _data = []() {
268 std::stringstream ss;
269 ss <<
"Valid choices are: [";
270 for(
auto itr = _set.begin(); itr != _set.end(); ++itr)
272 ss <<
"'" << (*itr) <<
"'";
273 size_t _dist = std::distance(_set.begin(), itr);
274 if(_dist + 1 < _set.size())
278 auto _choices = ss.str();
279 auto _msg = [_choices](
const char* itr) {
280 fprintf(stderr,
"Unknown component: '%s'. %s\n", itr, _choices.c_str());
282 return data_t(_vec, _idx, _msg);
285 auto& _vec = std::get<0>(_data);
286 auto& _enum = std::get<1>(_data);
288 for(
size_t i = 0; i < _vec.size(); ++i)
290 if(_vec[i](_key.c_str()))
294 std::get<2>(_data)(key.c_str());
312template <
typename Tp>
321template <
typename Tp>
330template <
typename Tp>
339template <
typename Tp>
348template <
typename Tp>
357template <
typename Tp>
366template <
typename Tp>
#define TIMEMORY_COMPONENTS_END
#define IF_CONSTEXPR(...)
typename enumerator< Idx >::type enumerator_t
void configure(Tp &obj, int idx, scope::config _scope)
int enumerate(const std::string &key)
std::make_integer_sequence< int, I > make_int_sequence
void enumerator_enumerate(component_match_vector_t &_vec, component_match_index_t &_idx, component_match_set_t &_set, int_sequence< Ints... >)
void do_enumerator_enumerate(component_match_vector_t &_vec, component_match_index_t &_idx, component_match_set_t &_set)
std::pair< component::opaque, std::set< size_t > > opaque_pair_t
std::set< std::string > component_match_set_t
std::integer_sequence< int, Ints... > int_sequence
void insert(Tp &obj, int idx, Arg &&arg, Args &&... args)
enable_if_t< component::enumerator< I >::value, void > do_enumerator_init(Tp &obj, int idx, Args &&... args)
enable_if_t< component::enumerator< I >::value &&I !=V, void > do_enumerator_generate(std::vector< opaque_pair_t > &opaque_array, int idx, Args &&... args)
std::vector< TIMEMORY_COMPONENT > component_match_index_t
void enumerator_insert(Tp &obj, int idx, int_sequence< Ints... >, Args &&... args)
void initialize(Tp &obj, int idx, Arg &&arg, Args &&... args)
std::vector< bool(*)(const char *)> component_match_vector_t
void configure(int idx, Arg &&arg, Args &&... args)
void enumerator_init(Tp &obj, int idx, int_sequence< Ints... >, Args &&... args)
void enumerator_configure(int idx, int_sequence< Ints... >, Args &&... args)
typename data< Tp >::type data_t
typename std::decay< T >::type decay_t
Alias template for decay.
typename std::enable_if< B, T >::type enable_if_t
Alias template for enable_if.
tim::mpl::apply< std::string > string
This is a critical specialization for mapping string and integers to component types at runtime....
static constexpr const char * id()
concept that specifies that a type is not necessarily marked as not available but is still a dummy ty...
this data type encodes the options of storage scope. The default is hierarchical (tree) scope....
static string_t tolower(string_t str)
#define TIMEMORY_FOLD_EXPRESSION(...)