1 /* Copyright (c) 2015-2022. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef XBT_AUTOMATON_HPP
8 #define XBT_AUTOMATON_HPP
12 #include <xbt/automaton.h>
17 /** Add a proposition to an automaton (the C++ way)
19 * This API hides all the callback and dynamic allocation hell from
20 * the used which can use C++ style functors and lambda expressions.
22 template <class F> xbt_automaton_propositional_symbol_t add_proposition(const_xbt_automaton_t a, const char* id, F f)
24 auto* callback = new F(std::move(f));
25 return xbt_automaton_propositional_symbol_new_callback(
26 a, id, [](void* cb) -> int { return (*(F*)cb)(); }, callback, [](void* cb) -> void { delete (F*)cb; });