emitter: uses type_id_v rather than a family
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#define CR_HOST
|
||||
|
||||
#include <cr.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <entt/signal/emitter.hpp>
|
||||
#include "types.h"
|
||||
|
||||
TEST(Lib, Emitter) {
|
||||
test_emitter emitter;
|
||||
int value{};
|
||||
|
||||
emitter.once<event>([&](event ev, test_emitter &) { value = ev.payload; });
|
||||
emitter.once<message>([&](message msg, test_emitter &) { value = msg.payload; });
|
||||
emitter.publish<event>(3);
|
||||
|
||||
ASSERT_EQ(value, 3);
|
||||
|
||||
cr_plugin ctx;
|
||||
ctx.userdata = &emitter;
|
||||
cr_plugin_load(ctx, PLUGIN);
|
||||
cr_plugin_update(ctx);
|
||||
|
||||
ASSERT_EQ(value, 42);
|
||||
|
||||
cr_plugin_close(ctx);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include <cr.h>
|
||||
#include <entt/signal/emitter.hpp>
|
||||
#include "types.h"
|
||||
|
||||
CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {
|
||||
switch (operation) {
|
||||
case CR_STEP:
|
||||
static_cast<test_emitter *>(ctx->userdata)->publish<message>(42);
|
||||
static_cast<test_emitter *>(ctx->userdata)->publish<message>(3);
|
||||
break;
|
||||
case CR_LOAD:
|
||||
case CR_UNLOAD:
|
||||
case CR_CLOSE:
|
||||
// nothing to do here, this is only a test.
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef ENTT_PLUGIN_EMITTER_TYPES_H
|
||||
#define ENTT_PLUGIN_EMITTER_TYPES_H
|
||||
|
||||
#include <entt/signal/emitter.hpp>
|
||||
|
||||
struct test_emitter
|
||||
: entt::emitter<test_emitter>
|
||||
{};
|
||||
|
||||
struct message {
|
||||
int payload;
|
||||
};
|
||||
|
||||
struct event {
|
||||
int payload;
|
||||
};
|
||||
|
||||
#endif // ENTT_PLUGIN_EMITTER_TYPES_H
|
||||
|
||||
Reference in New Issue
Block a user