• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

spl/TriState.h

00001 /*
00002  *   This file is part of the Standard Portable Library (SPL).
00003  *
00004  *   SPL is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   SPL is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with SPL.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #ifndef _tristate_h
00018 #define _tristate_h
00019 
00026 class TriState
00027 {
00028 public:
00029         enum {
00030                 TS_HI = 1,
00031                 TS_LOW = -1,
00032                 TS_UNSET = 0
00033         };
00034 
00035         inline byte GetState() { return m_state; }
00036         inline void SetState(byte val) { m_state = val; }
00037         inline bool IsSet() { return m_state != TS_UNSET; }
00038         inline bool IsHigh() { return m_state == TS_HI; }
00039         inline bool IsLow() { return m_state == TS_LOW; }
00040         inline void SetHi() { m_state = TS_HI; }
00041         inline void SetLow() { m_state = TS_LOW; }
00042         inline void Clear() { m_state = TS_UNSET; }
00043 
00044 protected:
00045         char m_state;
00046 };
00047 
00050 #endif