{"id":17079431,"url":"https://github.com/cas4ey/signals_library","last_synced_at":"2025-03-23T12:26:45.905Z","repository":{"id":94964636,"uuid":"53806244","full_name":"cas4ey/signals_library","owner":"cas4ey","description":"SignalsLibrary (a.k.a. slib) is simple \"include and use\" library that provides anonimous function pointer (slib::delegate), function arguments list (slib::args_list) and simple messaging system (slib::signal and slib::slot)","archived":false,"fork":false,"pushed_at":"2016-07-09T20:19:06.000Z","size":56,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-28T18:46:04.567Z","etag":null,"topics":["c-plus-plus","delegate","delegated-events","signal","signals","signals-library","slot"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cas4ey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-13T20:32:56.000Z","updated_at":"2019-08-24T23:26:10.000Z","dependencies_parsed_at":"2023-04-13T12:00:05.094Z","dependency_job_id":null,"html_url":"https://github.com/cas4ey/signals_library","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cas4ey%2Fsignals_library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cas4ey%2Fsignals_library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cas4ey%2Fsignals_library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cas4ey%2Fsignals_library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cas4ey","download_url":"https://codeload.github.com/cas4ey/signals_library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245100889,"owners_count":20560893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-plus-plus","delegate","delegated-events","signal","signals","signals-library","slot"],"created_at":"2024-10-14T12:25:48.212Z","updated_at":"2025-03-23T12:26:45.880Z","avatar_url":"https://github.com/cas4ey.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"### signals_library (slib)\nSignalsLibrary (a.k.a. **slib**) is simple \"include and use\" library that provides anonimous function pointer (`slib::delegate`),\nfunction arguments list (`slib::args_list`) and simple messaging system (`slib::signal` and `slib::slot`).\n\n- **slib::delegate** is a template anonimous pointer to class method or static function. Delegates can be copied\nand stored in generic containers (for example, `std::vector`). Delegates are fast, small (it consists only\nof two pointers) and does not use dynamic memory allocation. `#include \"slib/delegate.hpp\"` and you are ready to use delegates. `slib::delegate` is redesigned idea of Sergey Ryazanov's [fast delegates](http://www.codeproject.com/Articles/11015/The-Impossibly-Fast-C-Delegates).\n- **slib::args_list** is a function arguments list. It can be used to store arguments to call a lot of functions later.\nAny argument in list can be changed at any time. It stores arguments in `std::tuple` and has methods for unpacking\narguments from tuple to call function/method/delegate/functor with these arguments. `#include \"slib/args_list.hpp\"` to\nuse `slib::args_list`.\n- **slib::signal** and **slib::slot** is simple messaging system. When signal emits, all connected slots are invoked.\nIf you have ever used Qt and it's signal-slot system then you understand what is it. You don't need to inherit from\nspecial base-class to use signals and slots (for example, in Qt you have to inherit from QObject class to be able\nto use signals and slots). Multiple slots can be connected to one signal; one slot can be also connected to multiple signals;\none signal can be connected to multiple signals like a slot (when parent signal emits, all connected signals emits too).\nSignal and slot automatically disconnects on destructor from all connected signals and slots, that's why signal and slot\ncan not be copied or copy-constructed - they fully belong to theirs owner-object.\n\n### compiling\nSignalsLibrary is using features of C++11 standard, so you have to use C++11 compatible compiler.\n\n### adding slib into your project\n1. Copy all files from `include/slib` to to your include directory (for example, `include/third_party/slib` or just `include/slib`). Please, note that `slib` is using [shared_allocator](https://github.com/cas4ey/shared_allocator/) as a third-party library (see **NOTE** below).\n2. Include necessary headers (`slib/delegate.hpp` and/or `slib/args_list.hpp` and/or `slib/signals.hpp`) and you are ready for using delegates, args_lists, signals and slots.\n\n**NOTE:** `slib::signal` and `slib::slot` requires dynamic linkage with `shared_allocator` (instructions can be found [here](https://github.com/cas4ey/shared_allocator/)). `slib::delegate` and `slib::args_list` does not need `shared_allocator`.\n\n### example code for slib::delegate\n```\n#include \"slib/delegate.hpp\"\n\nclass A\n{\npublic:\n  int f(int x) const\n  {\n    return x * x;\n  }\n};\n\nint g(int y)\n{\n  return y * 2;\n}\n\nint main()\n{\n  slib::delegate\u003cint(int)\u003e d;\n  A a;\n  \n  // invoke unbinded delegate\n  auto result0 = d(10); // result0 == 0\n  \n  // binding delegate to class const-method\n  d.bind_const\u003cA, \u0026A::f\u003e(\u0026a); // or --- d.BIND_CONST(A, \u0026a, f);\n  \n  auto result1 = d(10); // result1 == 100\n  auto result2 = d(5); // result2 == 25\n  \n  // bindning delegate to static function\n  d.bind\u003cg\u003e();\n  \n  auto result3 = d(10); // result3 == 20\n  auto result4 = d(5); // result4 == 10\n  \n  // unbinding delegate\n  d.unbind();\n  \n  // invoke unbinded delegate again\n  auto result5 = d(5); // result5 == 0\n  \n  return 0;\n}\n```\n\n# LICENSE\nSignalsLibrary is licensed under terms of GNU GPL v3 (see file LICENSE), but I plan to add more permissive licenses\nin the near future (LGPL or MIT licenses maybe). Send me a message if you are interested.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcas4ey%2Fsignals_library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcas4ey%2Fsignals_library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcas4ey%2Fsignals_library/lists"}