1 /***************************************************************************
2  *   Copyright (C) 2009 by Andrey Afletdinov <fheroes2@gmail.com>          *
3  *                                                                         *
4  *   Part of the Free Heroes2 Engine:                                      *
5  *   http://sourceforge.net/projects/fheroes2                              *
6  *                                                                         *
7  *   This program is free software; you can redistribute it and/or modify  *
8  *   it under the terms of the GNU General Public License as published by  *
9  *   the Free Software Foundation; either version 2 of the License, or     *
10  *   (at your option) any later version.                                   *
11  *                                                                         *
12  *   This program is distributed in the hope that it will be useful,       *
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
15  *   GNU General Public License for more details.                          *
16  *                                                                         *
17  *   You should have received a copy of the GNU General Public License     *
18  *   along with this program; if not, write to the                         *
19  *   Free Software Foundation, Inc.,                                       *
20  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
21  ***************************************************************************/
22 
23 #ifndef H2BITMODES_H
24 #define H2BITMODES_H
25 
26 #include "types.h"
27 
28 class StreamBase;
29 
30 class BitModes
31 {
32 public:
BitModes()33     BitModes()
34         : modes( 0 )
35     {}
36 
SetModes(u32 f)37     void SetModes( u32 f )
38     {
39         modes |= f;
40     }
41 
ResetModes(u32 f)42     void ResetModes( u32 f )
43     {
44         modes &= ~f;
45     }
46 
Modes(u32 f)47     bool Modes( u32 f ) const
48     {
49         return ( modes & f ) != 0;
50     }
51 
52 protected:
53     friend StreamBase & operator<<( StreamBase &, const BitModes & );
54     friend StreamBase & operator>>( StreamBase &, BitModes & );
55 
56     u32 modes;
57 };
58 
59 StreamBase & operator<<( StreamBase &, const BitModes & );
60 StreamBase & operator>>( StreamBase &, BitModes & );
61 
62 #endif
63