This project demonstrates a simple state machine implementation in C++ with multiple states including INIT, POWERUP, RUN, SHUTDOWN, and ERROR.
g++
(GNU C++ Compiler)make
(Build automation tool)
-
Navigate to the project directory:
cd /path/to/project
-
Clean the build environment (optional but recommended to remove any previous builds):
make clean
-
Build the project:
make
This will compile the source files from the
src
directory and place the object files and the final executable in thebuild
directory. -
Run the executable:
./build/state_machine
- src/main.cpp: Contains the
main
function which drives the state machine. - src/state.h / src/state.cpp: Declaration and definition of the
State
class. - src/statemachine.h / src/statemachine.cpp: Declaration and definition of the
StateMachine
class. - src/actions.h / src/actions.cpp: Declarations and definitions of the state action functions.
To remove the built files and the executable, run:
make clean