6 #include <boost/range/algorithm/sort.hpp> 20 template <
typename Fun>
35 bool debug = getenv(
"VCSN_DYN");
42 std::cerr <<
"Register(" <<
name_ <<
").set(" << sig <<
")\n";
51 std::cerr <<
"Register(" <<
name_ <<
").get(" << sig <<
")\n";
52 auto i =
map_.find(sig);
62 auto sigs = std::vector<std::string>();
63 sigs.reserve(
map_.size());
65 sigs.emplace_back(p.first.to_string());
68 auto res = std::string{};
69 res +=
" failed signature:\n";
71 res +=
" available versions:\n";
73 res +=
" " + s +
"\n";
93 ?
name_ +
": no such implementation\n" 101 ": compilation succeeded, " 102 "but function is unavailable\n",
111 template <
typename... Args>
114 -> decltype(std::declval<Fun>()(args...))
116 return (
get(sig))(std::forward<Args>(args)...);
119 template <
typename... Args>
122 -> decltype(std::declval<Fun>()(args...))
125 std::forward<Args>(args)...);
132 using map_t = std::unordered_map<signature, Fun*>;
140 #define REGISTRY_DEFINE(Name) \ 144 Registry<Name ## _t>& \ 145 Name ## _registry() \ 147 static Registry<Name ## _t> instance{#Name}; \ 152 Name ## _register(const signature& sig, Name ## _t fn) \ 154 return Name ## _registry().set(sig, fn); \
std::unordered_map< signature, Fun * > map_t
Signature -> pointer to implementation.
const Fun * get0(const signature &sig)
Get function for signature sig.
auto sort(const Aut &a) -> permutation_automaton< Aut >
std::string to_string() const
void compile(const std::string &ctx)
Compile, and load, a DSO with instantiations for ctx.
Registry(const std::string &name)
Create a register for an algorithm.
std::string signatures(const signature &sig) const
A message about a failed signature compilation.
std::string name_
Function name (e.g., "determinize").
auto call(Args &&... args) -> decltype(std::declval< Fun >()(args...))
An exception suited for our compilation errors.
Signature of a function call.
signature vsignature(Args &&... args)
The signature of (Args...).
bool debug
Whether log messages should be issued.
std::string assertions
If defined, static assertions that failed (ends with a eol).
#define VCSN_REQUIRE(Cond,...)
A macro similar to require.
auto call(const signature &sig, Args &&... args) -> decltype(std::declval< Fun >()(args...))
Call function for signature sig.