From 0c3aa34cbbaf605571e953098964527ca42c8464 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Wed, 10 Apr 2013 22:32:08 +0200 Subject: digital/io-hub/src/apbirthday: centralize FSM definitions --- digital/io-hub/src/common-cc/fsm.hh | 44 +++++++++++++++++++++++++++++++ digital/io-hub/src/common-cc/fsm_queue.cc | 2 +- digital/io-hub/src/common-cc/fsm_queue.hh | 12 +-------- 3 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 digital/io-hub/src/common-cc/fsm.hh (limited to 'digital/io-hub/src/common-cc') diff --git a/digital/io-hub/src/common-cc/fsm.hh b/digital/io-hub/src/common-cc/fsm.hh new file mode 100644 index 00000000..300ea62f --- /dev/null +++ b/digital/io-hub/src/common-cc/fsm.hh @@ -0,0 +1,44 @@ +#ifndef fsm_hh +#define fsm_hh +// io-hub - Modular Input/Output. {{{ +// +// Copyright (C) 2013 Nicolas Schodet +// +// APBTeam: +// Web: http://apbteam.org/ +// Email: team AT apbteam DOT org +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// }}} + +extern "C" { +#define ANGFSM_NAME AI +#include "angfsm.h" +} + +#ifdef TARGET_host +typedef unsigned Branch; +#else +typedef angfsm_AI_branch_t Branch; +#endif + +#ifdef TARGET_host +typedef uint16_t Event; +#else +typedef angfsm_AI_event_t Event; +#endif + +#endif // fsm_hh diff --git a/digital/io-hub/src/common-cc/fsm_queue.cc b/digital/io-hub/src/common-cc/fsm_queue.cc index 816d836d..145f700a 100644 --- a/digital/io-hub/src/common-cc/fsm_queue.cc +++ b/digital/io-hub/src/common-cc/fsm_queue.cc @@ -37,7 +37,7 @@ FsmQueue::post (Event e) nb_++; } -FsmQueue::Event +Event FsmQueue::pop () { Event e; diff --git a/digital/io-hub/src/common-cc/fsm_queue.hh b/digital/io-hub/src/common-cc/fsm_queue.hh index 333bea80..5fe9c8cd 100644 --- a/digital/io-hub/src/common-cc/fsm_queue.hh +++ b/digital/io-hub/src/common-cc/fsm_queue.hh @@ -24,21 +24,11 @@ // // }}} #include "ucoolib/common.hh" - -extern "C" { -#define ANGFSM_NAME AI -#include "angfsm.h" -} +#include "fsm.hh" /// Handle asynchronous FSM event queue. class FsmQueue { - public: -#ifdef TARGET_host - typedef uint16_t Event; -#else - typedef angfsm_AI_event_t Event; -#endif public: /// Constructor. FsmQueue (); -- cgit v1.2.3