Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network64/src/util/mbool.h @ 2355

Last change on this file since 2355 was 2245, checked in by scheusso, 16 years ago

most coding is done, still testing now
types should get transfered in platform independent formats now

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _mbool_H__
30#define _mbool_H__
31
32#include "UtilPrereqs.h"
33
34namespace orxonox
35{
36    struct _UtilExport mbool
37    {
38//        friend Synchronisable::registerVariable<>()
39        public:
40            inline mbool(bool value = false)
41                { this->value_.memory_ = 0; this->value_.bool_ = value; }
42            inline mbool(const mbool& value)
43                { this->value_.memory_ = value.value_.memory_; }
44
45            inline const mbool& operator=(bool value)
46                { if (value != this->value_.bool_) { ++this->value_.memory_; } return (*this); }
47            inline const mbool& operator=(const mbool& value)
48                { this->value_.memory_ = value.value_.memory_; return (*this); }
49
50            inline mbool& operator++()
51                { ++this->value_.memory_; return (*this); }
52            inline mbool operator++(int i)
53                { mbool temp = (*this); ++this->value_.memory_; return temp; }
54
55            inline operator bool() const
56                { return this->value_.bool_; }
57
58            inline bool operator==(bool other) const
59                { return this->value_.bool_ == other; }
60            inline bool operator!=(bool other) const
61                { return this->value_.bool_ != other; }
62
63            inline bool operator==(const mbool& other) const
64                { return this->value_.memory_ == other.value_.memory_; }
65            inline bool operator!=(const mbool& other) const
66                { return this->value_.memory_ != other.value_.memory_; }
67
68            inline bool operator!() const
69                { return (!this->value_.bool_); }
70           
71            inline unsigned char& getMemory(){ return value_.memory_; }
72
73        private:
74            union
75            {
76                bool bool_ : 1;
77                unsigned char memory_;
78            } value_;
79    };
80}
81
82#endif /* _mbool_H__ */
Note: See TracBrowser for help on using the repository browser.