{"id":13731121,"url":"https://github.com/Rosme/rsm","last_synced_at":"2025-05-08T03:33:04.141Z","repository":{"id":32177591,"uuid":"35750992","full_name":"Rosme/rsm","owner":"Rosme","description":"Utility Library","archived":false,"fork":false,"pushed_at":"2019-05-11T16:30:43.000Z","size":198,"stargazers_count":12,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-04T02:09:57.570Z","etag":null,"topics":["cpp-library","cpp14","rsm"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rosme.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-17T03:54:14.000Z","updated_at":"2022-07-01T08:16:17.000Z","dependencies_parsed_at":"2022-09-11T04:40:07.214Z","dependency_job_id":null,"html_url":"https://github.com/Rosme/rsm","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rosme%2Frsm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rosme%2Frsm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rosme%2Frsm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rosme%2Frsm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rosme","download_url":"https://codeload.github.com/Rosme/rsm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224695919,"owners_count":17354511,"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":["cpp-library","cpp14","rsm"],"created_at":"2024-08-03T02:01:24.165Z","updated_at":"2024-11-14T21:32:14.033Z","avatar_url":"https://github.com/Rosme.png","language":"C++","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# rsm\n\nrsm is a utility library that contains different utilities for different purposes. It`s basically different tools I tend to reprogram with every project that I decided to centralise in a library. It is programmed in C++ and requires C++11.\n\n### Build Status\t\t\n\nMaster: [![Build Status](https://img.shields.io/travis/Rosme/rsm/master.svg?label=linux+and+macOS)](https://travis-ci.org/Rosme/rsm) [![Build Status](https://img.shields.io/appveyor/ci/Rosme/rsm/master.svg?label=windows)](https://ci.appveyor.com/project/Rosme/rsm)\n\n### Features\n\n* Any\n    * Type-erasure class for generic storage\n    * Easy to use(copyable, movable)\n* Config\n    * Allow you to read from a configuration file\n    * Default Configuration type is a Key=Value type\n    * Allow declaration of custom configuration type\n* Logger\n    * Easy to use logger\n    * Two provided log device:\n        * To stdout\n        * To file\n* Matrix\n    * Matrix class for easier usage of matrix\n    * Safe and easy to use with operator()\n* Message Dispatcher\n    * Lightweight Message class to ship any kind of message\n    * Virtual Message Handler to handle messages using a key=\u003e message type association\n    * Async Message Dispatcher to dispatch messages in a asynchronous way\n    * Or monothread Message Dispatcher to dispatch the messages when you want\n* Timer\n    * Timer that can trigger a callback when timed out\n    * Can also trigger a callback when interrupted\n\n### Code Samples\n#### Any\n```cpp\nrsm::Any obj(std::vector\u003cint\u003e{0, 1, 2});\n\nif(obj.isValid()) {\n\tauto val = obj.get\u003cstd::vector\u003cint\u003e\u003e();\n    \n    for(const auto i : val) {\n    \t//...\n    }\n}\n```\n#### Config\n```cpp\nrsm::Config config;\nconfig.load(\"myConfig.txt\");\n\nif(config.hasConfig(\"key\")) {\n\tauto value = config.get(\"key\");\n}\n\nconfig.set(\"newKey\", 42);\n\nconfig.save(\"newConfig.txt\");\n```\n#### Logging\n```cpp\nrsm::Logger::addLogDevice(std::make_unique\u003crsm::FileLogDevice\u003e(myLogFile.txt));\nrsm::Logger::info() \u003c\u003c \"A Info Log\";\n\nMyStreambleObject myObject; \nrsm::Logger::debug() \u003c\u003c myObject; // Assuming myStreableObject overloads operator\u003c\u003c\n```\n#### Matrix\n```cpp\nrsm::Matrix\u003cint\u003e matrix(5, 10, 3); // Creates a 5x10 matrix filled with 3\n\nmatrix(2, 4) = 5; //Set value 5 to entry at row 2 and column 4\nauto value = matrix(1, 3); //Return the value at row 1 and column 3\n```\n#### Message Dispatcher (Async)\n```cpp\nclass MyHandler : public rsm::MessageHandler {\n\tvoid onMessage(const std::string\u0026 key, const rsm::Message\u0026 message) override {\n    \t//...\n    }\n};\n\nrsm::MessageDispatcher dispatcher;\nMyHandler handler;\n\nrsm::AsyncMessageDispatcher asyncDispatcher;\nasyncDispatcher.registerHandler(\"asyncKey\", handler);\nasyncDispatcher.startDispatching(); //Start thread for automatic dispatching of pushed message\nasyncDispatcher.pushMessage(\"asyncKey\", \"asyncMessage\"); //Push message and dispatch\nasyncDispatcher.stopDispatching(); //Stop dispatching and the dispatching thread\n```\n#### Message Dispatcher (Synchronous)\n```cpp\nclass MyHandler : public rsm::MessageHandler {\n\tvoid onMessage(const std::string\u0026 key, const rsm::Message\u0026 message) override {\n    \t//...\n    }\n};\n\nrsm::MessageDispatcher dispatcher;\nMyHandler handler;\n\ndispatcher.registerHandler(\"syncKey\", handler); //Register handler to a specific key\ndispatcher.pushMessage(\"syncKey\", \"syncMessage\"); //Push a message in the dispatching queue\ndispatcher.dispatch(); //Required to dispatch all message previsouly pushed\n```\n#### Timer\n```cpp\nrsm::Timer\u003cvoid(), void()\u003e timer;\ntimer.setTimeoutFunction([]() {\n\trsm::Logger::info() \u003c\u003c \"The timer timed out\";\n});\n\ntimer.setInterruptFunction([]() {\n\trsm::Logger::info() \u003c\u003c \"The timer has been interrupted\";\n});\n\ntimer.start(std::chrono::milliseconds(1000)); //Call the timeout function after 1seconds\n\ntimer.interrupt(); //Call the interrupt function and stop the timer\n```\n\n### License\n\nThe library is distributed under the zlib/png license. This basically means you can use rsm in any project(commercial or not, proprietary or open-source) for free. There is no restriction to the use. You don't even need to mention rsm or me, though it would be appreciated.\n\nWritten by Jean-Sébastien Fauteux","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRosme%2Frsm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRosme%2Frsm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRosme%2Frsm/lists"}