-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
README states:
// get the root type from the hierarchy which serves as reference/pointer to base class.
using Event = ni::type_hierarchy::from_base<EventBase>;
// derive custom types, the first template argument must always be the derived type
// itself. This is required due to the missing reflections in C++ and is used to
// assign a unique id to the new type.
struct MouseEvent : ni::sub_type<MouseEvent, Event> {
int x, y;
MouseEvent(int x_, int y_) : x{x_}, y{y_} {}
};
struct KeyEvent : ni::sub_type<KeyEvent, Event> {
// ...
};
// 2nd level event
struct MouseButtonDownEvent : ni::sub_type<MouseButtonDownEvent, MouseEvent> {
// ...
};
It does not specify how to declare the constructor for MouseButtonDownEvent, or how to initialize the int x,y, parent members or how to declare and initialize the child members.
From experimenting, using the standard inheritance approach of:
struct MouseButtonDownEvent : ni::sub_type<MouseButtonDownEvent, MouseEvent>
{
bool button;
MouseButtonDownEvent(int x_, int y_, bool button_ ) : MouseEvent(x_, y_), button(button_) {}
does not compile. Instead I've had to do:
struct MouseButtonDownEvent : ni::sub_type<MouseButtonDownEvent, MouseEvent>
{
bool button;
MouseButtonDownEvent(int x_, int y_, bool button_ )
{
x = x_;
y = y_;
button = button_;
}
};
I'm not sure if this is intended method of initialization. More detail in the README would be very helpful.
Metadata
Metadata
Assignees
Labels
No labels