Skip to content

Commit

Permalink
Add 'state_machine' package (ruslo#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
NukeBird authored and ruslo committed Nov 10, 2017
1 parent 7727cae commit 636f092
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/configs/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ hunter_config(CppNetlib VERSION 0.10.1-hunter-3)
hunter_config(CppNetlibUri VERSION 1.0.4-hunter)
hunter_config(CsvParserCPlusPlus VERSION 1.0.1)
hunter_config(Eigen VERSION 3.3.4-p0)
hunter_config(state_machine VERSION 1.1)
hunter_config(enet VERSION 1.3.13-p1)
hunter_config(Expat VERSION 2.1.1)
if(MSVC)
Expand Down
24 changes: 24 additions & 0 deletions cmake/projects/state_machine/hunter.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2016-2017, Ruslan Baratov
# All rights reserved.

# !!! DO NOT PLACE HEADER GUARDS HERE !!!

include(hunter_add_version)
include(hunter_cacheable)
include(hunter_download)
include(hunter_pick_scheme)

hunter_add_version(
PACKAGE_NAME
state_machine
VERSION
1.1
URL
"https://github.com/NukeBird/state_machine/archive/1.1.tar.gz"
SHA1
43F37F8D0EF067ED6F853D11F5875A4D83A06756
)

hunter_pick_scheme(DEFAULT url_sha1_cmake)
hunter_cacheable(state_machine)
hunter_download(PACKAGE_NAME state_machine)
20 changes: 20 additions & 0 deletions docs/packages/pkg/state_machine.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. spelling::

state_machine

.. index:: unsorted ; state_machine

.. _pkg.state_machine:

state_machine
=============

- `Official <https://github.com/NukeBird/state_machine>`__
- `Example <https://github.com/ruslo/hunter/blob/master/examples/state_machine/CMakeLists.txt>`__
- Added by `NukeBird <https://github.com/NukeBird>`__ (`pr-1163 <https://github.com/ruslo/hunter/pull/1163>`__)

.. code-block:: cmake
hunter_add_package(state_machine)
find_package(state_machine CONFIG REQUIRED)
target_link_libraries(sm state_machine)
16 changes: 16 additions & 0 deletions examples/state_machine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2016-2017, Ruslan Baratov
# All rights reserved.

cmake_minimum_required(VERSION 3.0)

# Emulate HunterGate:
# * https://github.com/hunter-packages/gate
include("../common.cmake")

project(download-state_machine)

hunter_add_package(state_machine)
find_package(state_machine CONFIG REQUIRED)

add_executable(sm foo.cpp)
target_link_libraries(sm state_machine)
30 changes: 30 additions & 0 deletions examples/state_machine/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <sm/state_machine.h>
#include <iostream>

struct Foo: public State
{
void update(float dt) override
{
std::cout << "(updated)" << std::endl;
}

void draw(float dt) override
{
std::cout << "(drawed)" << std::endl;
}
};

int main()
{
StateMachine machine;

machine.push_state<Foo>();

machine.update(0.0f);

machine.pop_state();

machine.update(0.0f);

return 0;
}

0 comments on commit 636f092

Please sign in to comment.