10#include <gtest/gtest.h>
22 static string msg =
"Hello";
28 int* counter =
static_cast<int*
>(data);
57 string* msg =
static_cast<string*
>(result);
136 void* result =
table2.execute_event(0);
137 EXPECT_EQ(*
static_cast<string*
>(result),
"Hello");
145 result =
table3.execute_event(0);
146 EXPECT_EQ(*
static_cast<string*
>(result),
"Hello");
172 EXPECT_EQ(*
static_cast<string*
>(result),
"Hello");
176 EXPECT_EQ(*
static_cast<int*
>(result), 42);
210 EXPECT_EQ(*
static_cast<string*
>(result),
"Hello");
264 table.
register_event(0, [](
const string& s) {
return "Hello, " + s; });
315 std::function<
double(
double)> square = [](
double x) {
return x * x; };
316 std::function<
double(
double)>
cube = [](
double x) {
return x * x * x; };
344 table1.register_event(0, [](
int x) {
return x * 10; });
size_t size() const noexcept
Count the number of elements of the list.
Dynamic (growable) event table implementation.
size_t size() const override
Get the current table size (implements Event_Table virtual method)
bool is_registered(const size_t index) const
Check if an event is registered at the given index.
void register_event(const size_t index, Callable &&fct)
Register an event at a specific index.
void unregister_event(const size_t index)
Unregister an event at the given index.
bool check(const size_t, F) const
Legacy check method (for backward compatibility).
auto execute_event(const size_t index, Args &&... args) const
Execute the event at the given index with type-safe arguments.
Fixed-size event table implementation.
size_t size() const override
Get table size (implements Event_Table virtual method)
Event-driven table abstraction for event-driven simulations.
void * event_echo(void *data)
void * event_hello(void *data)
void * event_increment(void *data)
std::string toupper(const char *str)
Convert a C std::string to upper-case.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.