C++ state machine template class framework