Skip to content

engine::event_subscription_list

Paweł Waligóra edited this page Apr 18, 2024 · 4 revisions

This is the core of the entire engine.

Usage

meant to be used by modules to call their components

Example

module.h

#include"event_subscription_list.h"
namespace module {
	extern engine::event_subscribtion_list<> events;

	// other module variables, functions
}

module.cpp

#include"module.h"
engine::event_subscribtion_list<> module::events;
// other definitions

usage code:

#include "module.h"

// subscribing
void func() { /* code */ }
module::events.subscribe(func); // subscribing function

some_object o;
module::events.subscribe(std::bind(&some_object::some_method, &o)); // subscribing object method

module::events.subscribe([](){/* code */}); // subscribing lambda

// call subscribers
module::events.call_events();

// unsubscribing
int* id = module::events.subscribe([](){/* code */}); // subscribe returns a pointer
module::events.unsubscribe(&id); // that needs to be passed to list to unsubscribe

Home

Git Workflow

Issues

Coding Rules

Skrypty-Tutorial

Useful resources

Game Structure

Code Structure

Clone this wiki locally