|
1 | | -# CXXStateTree |
2 | | -A C++ Hierarchical State Tree Library |
| 1 | +<p align="center"> |
| 2 | + <img src="assets/logo.png" alt="CXXStateTree Logo" width="200"/> |
| 3 | +</p> |
| 4 | + |
| 5 | +<h1 align="center">CXXStateTree</h1> |
| 6 | +<p align="center"><i>Modern Hierarchical State Machine for C++20</i></p> |
| 7 | + |
| 8 | +## 🚀 Features |
| 9 | + |
| 10 | +* 🔧 Fluent builder API with lambda-based DSL |
| 11 | +* ⚡ Fast runtime performance with zero heap allocation |
| 12 | +* 🛡️ Optional guards and actions for transitions |
| 13 | +* 🔄 Event-based state transitions |
| 14 | +* 🧪 Google Test integration |
| 15 | +* 📈 Code coverage with Codecov |
| 16 | +* 🌳 Designed for extensibility: nested states, DOT export coming soon |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## 🛠️ Quick Example |
| 21 | + |
| 22 | +```cpp |
| 23 | +#include <iostream> |
| 24 | +#include "CXXStateTree/StateTree.hpp" |
| 25 | + |
| 26 | +using namespace CXXStateTree; |
| 27 | + |
| 28 | +int main() { |
| 29 | + auto machine = Builder() |
| 30 | + .initial("Idle") |
| 31 | + .state("Idle", [](State& s) { |
| 32 | + s.on("Start", "Running", nullptr, []() { |
| 33 | + std::cout << "Idle -> Running" << std::endl; |
| 34 | + }); |
| 35 | + }) |
| 36 | + .state("Running", [](State& s) { |
| 37 | + s.on("Stop", "Idle", nullptr, []() { |
| 38 | + std::cout << "Running -> Idle" << std::endl; |
| 39 | + }); |
| 40 | + }) |
| 41 | + .build(); |
| 42 | + |
| 43 | + machine.send("Start"); |
| 44 | + machine.send("Stop"); |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## 🧪 Running Tests |
| 51 | + |
| 52 | +```bash |
| 53 | +cmake -S . -B build -DENABLE_COVERAGE=ON |
| 54 | +cmake --build build |
| 55 | +cd build && ctest |
| 56 | +``` |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## 📦 Dependencies |
| 61 | + |
| 62 | +* C++20 compiler (GCC >= 10, Clang >= 11, MSVC >= 2019) |
| 63 | +* [GoogleTest](https://github.com/google/googletest) (auto-downloaded via CMake) |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## 📈 Code Coverage |
| 68 | + |
| 69 | +[](https://codecov.io/gh/your-org/your-repo) |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +## 📂 Directory Structure |
| 74 | + |
| 75 | +``` |
| 76 | +CXXStateTree/ |
| 77 | +├── include/CXXStateTree/ # Public header-only API |
| 78 | +├── examples/ # Usage examples |
| 79 | +├── tests/ # Google Test suite |
| 80 | +├── CMakeLists.txt # Project build |
| 81 | +└── .github/workflows/ci.yml # GitHub Actions CI |
| 82 | +``` |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +## 📋 License |
| 87 | + |
| 88 | +MPL2.0 License — see [LICENSE](LICENSE) for details. |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## 🌟 Coming Soon |
| 93 | + |
| 94 | +* Nested (hierarchical) state support |
| 95 | +* DOT/Graphviz state diagram export |
| 96 | +* Transitions with context/parameters |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## 👋 Contributions Welcome |
| 101 | + |
| 102 | +Issues, feature suggestions, and PRs are welcome! |
0 commit comments