Git Product home page Git Product logo

eslib's Introduction

EventSystem - C++ publish/subscribe

The EventSystem library provides a decoupled publish/subscribe event model. Event topics are registered by name and can have one or more typesafe paramerers. Subscribers can be lambdas, free functions or member functions. Events can be published asynchronously, and will be stored in a queue for synchronous processing.

ES::EventSystem es;

// subscribe with lambda
es.subscribe("Event", [](std::string arg) {
	std::cout << "Got argument " << arg << std::endl;
});

// subscribe with member function
Foo foo;
es.subscribe("AnotherEvent", &Foo::handleEvent, &foo);

// Multiple parameters are supported
es.subscribe("MultiparamEvent", [](std::string arg1, int arg2) {
	...
});

// enqueue an event
std::string eventContent = "Hello World!";
es.publish("Event", eventContent);

// process queued events
es.process();

Installation

EventSystem is a header-only library with no external dependencies. To use it, simply add the include directory to your include path. Alternatively, you can install it using CMake:

mkdir build && cd build
cmake ..
sudo make install

Then, you can use find_package(EventSystem) to locate the installation. The installed include directory path is stored in the CMake variable EventSystem_INCLUDE_DIR.

The library requires a language level of C++11. It has been tested with GCC 4.8 and Visual Studio 2015.

Documentation

The documentation is built using Doxygen. You can generate it through CMake:

mkdir build && cd build
cmake ..
make doc

The generated documentation can be found in doc/html.

License

This project is licensed under the BSD 3-clause license - see the LICENSE.md file for details. Some source code has been adapted from the pybind11 library (https://pybind11.readthedocs.io) which is released under the BSD 3-clause license.

Disclaimer

The copyright holders are not liable for any damage(s) incurred due to improper use of this software.

eslib's People

Contributors

mgienger avatar xfel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.