Hierarchical State Machine framework in C++