[802] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * |
---|
| 4 | * |
---|
| 5 | * License notice: |
---|
| 6 | * |
---|
| 7 | * This program is free software; you can redistribute it and/or |
---|
| 8 | * modify it under the terms of the GNU General Public License |
---|
| 9 | * as published by the Free Software Foundation; either version 2 |
---|
| 10 | * of the License, or (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 Free Software |
---|
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 20 | * |
---|
| 21 | * Author: |
---|
| 22 | * Fabian 'x3n' Landau |
---|
| 23 | * Co-authors: |
---|
| 24 | * ... |
---|
| 25 | * |
---|
| 26 | */ |
---|
| 27 | |
---|
| 28 | #ifndef _ClassTreeMask_H__ |
---|
| 29 | #define _ClassTreeMask_H__ |
---|
| 30 | |
---|
| 31 | #include <list> |
---|
[803] | 32 | #include <stack> |
---|
[802] | 33 | |
---|
| 34 | #include "CorePrereqs.h" |
---|
| 35 | |
---|
| 36 | namespace orxonox |
---|
| 37 | { |
---|
| 38 | class ClassTreeMaskNode |
---|
| 39 | { |
---|
| 40 | friend class ClassTreeMask; |
---|
[803] | 41 | friend class ClassTreeMaskIterator; |
---|
[802] | 42 | |
---|
| 43 | public: |
---|
| 44 | ClassTreeMaskNode(const Identifier* subclass, bool bIncluded = true); |
---|
| 45 | ~ClassTreeMaskNode(); |
---|
| 46 | |
---|
| 47 | void include(); |
---|
| 48 | void exclude(); |
---|
| 49 | void setIncluded(bool bIncluded); |
---|
| 50 | |
---|
| 51 | void addSubnode(ClassTreeMaskNode* subnode); |
---|
| 52 | |
---|
| 53 | bool isIncluded() const; |
---|
| 54 | bool isExcluded() const; |
---|
| 55 | |
---|
| 56 | const Identifier* getClass() const; |
---|
| 57 | |
---|
| 58 | private: |
---|
| 59 | const Identifier* subclass_; |
---|
| 60 | bool bIncluded_; |
---|
| 61 | std::list<ClassTreeMaskNode*> subnodes_; |
---|
| 62 | }; |
---|
| 63 | |
---|
[803] | 64 | class ClassTreeMaskIterator |
---|
| 65 | { |
---|
| 66 | public: |
---|
| 67 | ClassTreeMaskIterator(ClassTreeMaskNode* node); |
---|
| 68 | ~ClassTreeMaskIterator(); |
---|
| 69 | |
---|
| 70 | ClassTreeMaskIterator& operator++(); |
---|
| 71 | ClassTreeMaskNode* operator*() const; |
---|
| 72 | ClassTreeMaskNode* operator->() const; |
---|
| 73 | operator bool(); |
---|
| 74 | bool operator==(ClassTreeMaskNode* compare); |
---|
| 75 | bool operator!=(ClassTreeMaskNode* compare); |
---|
| 76 | |
---|
| 77 | private: |
---|
| 78 | std::stack<std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator> > nodes_; |
---|
[807] | 79 | std::list<ClassTreeMaskNode*> rootlist_; |
---|
[803] | 80 | }; |
---|
| 81 | |
---|
[802] | 82 | class ClassTreeMask |
---|
| 83 | { |
---|
| 84 | public: |
---|
| 85 | ClassTreeMask(); |
---|
[807] | 86 | ClassTreeMask(const ClassTreeMask& other); |
---|
[802] | 87 | ~ClassTreeMask(); |
---|
| 88 | |
---|
| 89 | void include(const Identifier* subclass); |
---|
| 90 | void exclude(const Identifier* subclass); |
---|
| 91 | void add(const Identifier* subclass, bool bInclude); |
---|
| 92 | void reset(); |
---|
[803] | 93 | void clean(); |
---|
[802] | 94 | |
---|
[803] | 95 | bool isIncluded(const Identifier* subclass) const; |
---|
| 96 | bool isExcluded(const Identifier* subclass) const; |
---|
[802] | 97 | |
---|
[807] | 98 | ClassTreeMask& operator=(const ClassTreeMask& other); |
---|
| 99 | |
---|
| 100 | ClassTreeMask& operator+(); |
---|
| 101 | ClassTreeMask operator-() const; |
---|
| 102 | |
---|
[803] | 103 | ClassTreeMask operator+(const ClassTreeMask& other) const; |
---|
| 104 | ClassTreeMask operator*(const ClassTreeMask& other) const; |
---|
[807] | 105 | ClassTreeMask operator-(const ClassTreeMask& other) const; |
---|
[803] | 106 | ClassTreeMask operator!() const; |
---|
| 107 | |
---|
[807] | 108 | ClassTreeMask& operator+=(const ClassTreeMask& other); |
---|
| 109 | ClassTreeMask& operator*=(const ClassTreeMask& other); |
---|
| 110 | ClassTreeMask& operator-=(const ClassTreeMask& other); |
---|
| 111 | |
---|
[803] | 112 | ClassTreeMask operator&(const ClassTreeMask& other) const; |
---|
| 113 | ClassTreeMask operator|(const ClassTreeMask& other) const; |
---|
| 114 | ClassTreeMask operator^(const ClassTreeMask& other) const; |
---|
| 115 | ClassTreeMask operator~() const; |
---|
| 116 | |
---|
[807] | 117 | ClassTreeMask& operator&=(const ClassTreeMask& other); |
---|
| 118 | ClassTreeMask& operator|=(const ClassTreeMask& other); |
---|
| 119 | ClassTreeMask& operator^=(const ClassTreeMask& other); |
---|
| 120 | |
---|
| 121 | friend std::ostream& operator<<(std::ostream& out, const ClassTreeMask& mask); |
---|
| 122 | |
---|
[802] | 123 | private: |
---|
| 124 | void add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude); |
---|
[803] | 125 | bool isIncluded(ClassTreeMaskNode* node, const Identifier* subclass) const; |
---|
| 126 | void clean(ClassTreeMaskNode* node); |
---|
[802] | 127 | |
---|
| 128 | ClassTreeMaskNode* root_; |
---|
| 129 | }; |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | #endif /* _ClassTreeMask_H__ */ |
---|