{"id":17208191,"url":"https://github.com/stephanlachnit/serializiblefsm","last_synced_at":"2025-06-12T18:32:56.880Z","repository":{"id":101216870,"uuid":"565412586","full_name":"stephanlachnit/SerializibleFSM","owner":"stephanlachnit","description":" C++ Final State Machine library for easy network transport","archived":false,"fork":false,"pushed_at":"2024-02-19T21:15:30.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T11:23:09.739Z","etag":null,"topics":["cpp","cpp17","final-state-machine","fsm","header-only","network","serialization"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stephanlachnit.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}},"created_at":"2022-11-13T10:31:03.000Z","updated_at":"2022-11-14T09:32:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"6e7e0179-8d2b-42cd-b652-4ea34322cba7","html_url":"https://github.com/stephanlachnit/SerializibleFSM","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stephanlachnit/SerializibleFSM","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanlachnit%2FSerializibleFSM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanlachnit%2FSerializibleFSM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanlachnit%2FSerializibleFSM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanlachnit%2FSerializibleFSM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephanlachnit","download_url":"https://codeload.github.com/stephanlachnit/SerializibleFSM/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanlachnit%2FSerializibleFSM/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259519255,"owners_count":22870327,"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","cpp17","final-state-machine","fsm","header-only","network","serialization"],"created_at":"2024-10-15T02:47:48.962Z","updated_at":"2025-06-12T18:32:56.853Z","avatar_url":"https://github.com/stephanlachnit.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nCopyright © 2024 Stephan Lachnit \u003cstephanlachnit@debian.org\u003e\nSPDX-License-Identifier: MIT\n--\u003e\n\n# SerializableFSM\n\nSerializableFSM is a templated header-only final state machine C++20 library designed to be easily\nserializable for network transport. It achieves this by being templated by two enums: one for the\npossible states of the FSM, and one for the possible events the FSM may encounter.\n\n## Simple example\n\n```c++\n#include \u003ccassert\u003e\n#include \u003cSerializableFSM.hpp\u003e\n\n// Possible switch states\nenum class State {\n    On,\n    Off,\n};\n\n// Possible switch events\nenum class Event {\n    SwitchOn,\n    SwitchOff,\n};\n\n// Typedefs for prettier code\nclass Switch;\nusing BaseFSM = SerializableFSM::FSM\u003cSwitch, State, Event\u003e;\n\nclass Switch : public BaseFSM {\nprivate:\n    friend BaseFSM;\n\n    // Transition to turn switch on\n    auto switchOn(std::any /* user_data */) -\u003e State {\n        return State::On;\n    }\n\n    // Transition to turn switch off\n    auto switchOff(std::any /* user_data */) -\u003e State {\n        return State::Off;\n    }\n\npublic:\n    explicit Switch(State initial_state) : BaseFSM(this, initial_state, BaseFSM::StateTransitionMap({\n        // All transitions from the On state go here\n        {State::On, {{Event::SwitchOff, \u0026Switch::switchOff}}},\n        // All transitions from the Off state go here\n        {State::Off, {{Event::SwitchOn, \u0026Switch::switchOn}}},\n    })) {}\n};\n\nint main() {\n    // Define FSM with starting in Off state\n    Switch fsm {State::Off};\n\n    // Turn switch on\n    fsm.react(Event::SwitchOn);\n\n    // Switch is now in On state\n    assert(fsm.getState() == State::On);\n\n    return 0;\n}\n```\n\nFor more examples, take a look at the [examples](examples/) directory.\n\n## Build examples\n\nYou can build the examples with [Meson](https://mesonbuild.com/):\n\n```shell\nmeson setup build -Dexamples=true\nmeson compile -C build\n```\n\nThe examples are then located in `build/example`.\n\n## License\n\nLicensed under MIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanlachnit%2Fserializiblefsm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephanlachnit%2Fserializiblefsm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanlachnit%2Fserializiblefsm/lists"}