friendev EtherDune TCP/IP library
/home/jander/temp/etherdune/Stateful.h
Go to the documentation of this file.
1 // EtherDune State tracking class
2 // Author: Javier Peletier <jm@friendev.com>
3 // Summary: Maintains a state variable and allows to pull out a state string representation for debugging
4 //
5 // Copyright (c) 2015 All Rights Reserved, http://friendev.com
6 //
7 // This source is subject to the GPLv2 license.
8 // Please see the License.txt file for more information.
9 // All other rights reserved.
10 //
11 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
12 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
14 // PARTICULAR PURPOSE.
15 
26 #ifndef _STATEFUL_H_
27 #define _STATEFUL_H_
28 
29 #include <ACross.h>
30 
31 class Stateful
32 {
33 protected:
34  uint8_t stateTimer;
35  uint8_t state;
36 
37  void setState(uint8_t newState, uint8_t timeout);
38 
39 public :
40 
41  inline uint8_t getState()
42  {
43  return state;
44  }
45 
46 #if _DEBUG
47  virtual __FlashStringHelper* getStateString() = 0;
53 #endif
54 
55 };
56 
57 
58 
59 
60 #endif
void setState(uint8_t newState, uint8_t timeout)
Changes to a new state
Definition: Stateful.cpp:28
uint8_t stateTimer
state timer, in ticks
Definition: Stateful.h:34
Maintains a state variable and allows to pull out a state string representation for debugging...
Definition: Stateful.h:31
uint8_t state
state code
Definition: Stateful.h:35
uint8_t getState()
Definition: Stateful.h:41