Giter Site home page Giter Site logo

afsm's Introduction

Another Finite State Machine

afsm is a finite state machine C++14 library designed for usage in multithreaded asynchronous environment.

Inspiration and Motivation

The afsm library was inspired by ::boost::msm library and implemented so that the migration from ::boost::msm was a bunch of search and replace operations. The main motivation was to create a thread-safe FSM library and to achieve decent compile times for large and complex state machines not sacrificing performance. A state machine defined with afms library compiles several times faster than same library defined with ::boost::msm and has similar (or better) performance. You can find some benchmark results here.

Features

Planned features

  • State machine persistense

Synopsis

Here is a UML diagram of a trivial state machine and source code that it is mapped to. minimal

#include <afsm/fsm.hpp>
// Events
struct start {};
struct stop {};

// State machine definition
struct minimal_def : ::afsm::def::state_machine<minimal_def> {
    //@{
    /** @name States */
    struct initial      : state<initial> {};
    struct running      : state<running> {};
    struct terminated   : terminal_state<terminated> {};
    //@}

    using initial_state = initial;
    using transitions   = transition_table<
        /*  State       Event       Next        */
        tr< initial,    start,      running     >,
        tr< running,    stop,       terminated  >
    >;
};

// State machine object
using minimal = ::afsm::state_machine<minimal_def>;

void use()
{
    mimimal fsm;
    fsm.process_event(start{});
    fsm.process_event(stop{});
}

You can find a tutorial covering most of basic features here.

Documentation

Please see project wiki for documentation. TODO doxygen generated documentation.

Installation

The library is header only and doesn't requre build or installation. Just add the afsm/include and lib/meta/include directories under the root of this repository to your include paths.

CMake subproject

You can add the library to your project as a subtree, e.g. lib/afsm, and in your root CMakeLists.txt file just do the following:

add_subdirectory(lib/afsm)
include_directories(${AFSM_INCLUDE_DIRS})

TODO write docs on gitrc subtree commands and link to the repository

Installation to System Directories

git clone [email protected]:zmij/afsm.git
mkdir afsm/build
cd afsm/build
cmake ..
sudo make install

Finding the AFSM Package

find_package(AFSM REQUIRED) # Will set AFSM_INCLUDE_DIRS variable

License

The Artistic License 2.0

afsm's People

Contributors

zmij avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.