[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_; |
---|
| 79 | }; |
---|
| 80 | |
---|
[802] | 81 | class ClassTreeMask |
---|
| 82 | { |
---|
| 83 | public: |
---|
| 84 | ClassTreeMask(); |
---|
| 85 | ~ClassTreeMask(); |
---|
| 86 | |
---|
| 87 | void include(const Identifier* subclass); |
---|
| 88 | void exclude(const Identifier* subclass); |
---|
| 89 | void add(const Identifier* subclass, bool bInclude); |
---|
| 90 | void reset(); |
---|
[803] | 91 | void clean(); |
---|
[802] | 92 | |
---|
[803] | 93 | bool isIncluded(const Identifier* subclass) const; |
---|
| 94 | bool isExcluded(const Identifier* subclass) const; |
---|
[802] | 95 | |
---|
[803] | 96 | ClassTreeMask operator+(const ClassTreeMask& other) const; |
---|
| 97 | ClassTreeMask operator*(const ClassTreeMask& other) const; |
---|
| 98 | ClassTreeMask operator!() const; |
---|
| 99 | ClassTreeMask operator-(const ClassTreeMask& other) const; |
---|
| 100 | |
---|
| 101 | ClassTreeMask operator&(const ClassTreeMask& other) const; |
---|
| 102 | ClassTreeMask operator|(const ClassTreeMask& other) const; |
---|
| 103 | ClassTreeMask operator^(const ClassTreeMask& other) const; |
---|
| 104 | ClassTreeMask operator~() const; |
---|
| 105 | |
---|
[802] | 106 | private: |
---|
| 107 | void add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude); |
---|
[803] | 108 | bool isIncluded(ClassTreeMaskNode* node, const Identifier* subclass) const; |
---|
| 109 | void clean(ClassTreeMaskNode* node); |
---|
[802] | 110 | |
---|
| 111 | ClassTreeMaskNode* root_; |
---|
| 112 | }; |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | #endif /* _ClassTreeMask_H__ */ |
---|