state_machine_cpp
|
The state_machine_cpp library is a library written in C++17 which permits the development of algorithms by means of state-machines-like behaviors. It aims to be used when, among others, one wants to achieve the following goals:
To achieve these goals, algorithms are decomposed in a succession of states while the algorithmic flow is enforced by so-called transitions from one state to another. This decomposition of algorithms makes it possible to insert new states and new transitions to an existing algorithm without breaking the original algorithm and to be able to rewrite any part of the algorithm which comprises: state or transition removal, transition action overriding, transition flow overriding, algorithmic combination (i.e., sub-routines), etc.
Here is an example of the implementation of a for loop within the state-machine-like framework:
Be sure to check out our amazing tutorials!
You may also check our documentation!
When installing the library (see below), the compiler will evaluate the directive #if __has_include(<robin_hood/robin_hood.h>)
. If it evaluates to true, then the robin hood implementation of unordered_map will be used. Otherwise, the STL will be used (i.e., std::unordered_map
). (robin_hood is a header-only library that provides a fast implementation of hash tables.)
The following commands will install the library as a shared library.
The state_machine_cpp installs a cmake configuration file so that it can be easily imported. Simply use the cmake function find_package
to retrieve all imported targets. Thus, you can use the following code to import state_machine_cpp:
To build the documentation, use doxygen from the root folder:
To compile the tests, in your build
directory:
Then run with