[1505] | 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 | /** |
---|
[2171] | 30 | @file |
---|
[9567] | 31 | @brief Implementation of Identifiable. |
---|
[1505] | 32 | */ |
---|
| 33 | |
---|
[9565] | 34 | #include "Identifiable.h" |
---|
[3196] | 35 | |
---|
[6105] | 36 | #include <cassert> |
---|
[9667] | 37 | #include "core/CoreIncludes.h" |
---|
[9563] | 38 | #include "core/object/Context.h" |
---|
[1505] | 39 | #include "Identifier.h" |
---|
| 40 | |
---|
| 41 | namespace orxonox |
---|
| 42 | { |
---|
[10624] | 43 | RegisterClassNoArgs(Identifiable).virtualBase(); |
---|
[9667] | 44 | |
---|
[7401] | 45 | /** |
---|
| 46 | @brief Constructor: Sets the default values. |
---|
| 47 | */ |
---|
[9565] | 48 | Identifiable::Identifiable() |
---|
[1505] | 49 | { |
---|
[11071] | 50 | this->identifier_ = nullptr; |
---|
[9667] | 51 | this->objectPointers_.reserve(6); // Optimisation |
---|
[1505] | 52 | |
---|
[9667] | 53 | RegisterObject(Identifiable); |
---|
[1505] | 54 | } |
---|
| 55 | |
---|
[7401] | 56 | /// Returns true if the object's class is of the given type or a derivative. |
---|
[9565] | 57 | bool Identifiable::isA(const Identifier* identifier) |
---|
[1505] | 58 | { return this->getIdentifier()->isA(identifier); } |
---|
[7401] | 59 | /// Returns true if the object's class is exactly of the given type. |
---|
[9565] | 60 | bool Identifiable::isExactlyA(const Identifier* identifier) |
---|
[1505] | 61 | { return this->getIdentifier()->isExactlyA(identifier); } |
---|
[7401] | 62 | /// Returns true if the object's class is a child of the given type. |
---|
[9565] | 63 | bool Identifiable::isChildOf(const Identifier* identifier) |
---|
[1505] | 64 | { return this->getIdentifier()->isChildOf(identifier); } |
---|
[7401] | 65 | /// Returns true if the object's class is a direct child of the given type. |
---|
[9565] | 66 | bool Identifiable::isDirectChildOf(const Identifier* identifier) |
---|
[1505] | 67 | { return this->getIdentifier()->isDirectChildOf(identifier); } |
---|
[7401] | 68 | /// Returns true if the object's class is a parent of the given type. |
---|
[9565] | 69 | bool Identifiable::isParentOf(const Identifier* identifier) |
---|
[1505] | 70 | { return this->getIdentifier()->isParentOf(identifier); } |
---|
[7401] | 71 | /// Returns true if the object's class is a direct parent of the given type. |
---|
[9565] | 72 | bool Identifiable::isDirectParentOf(const Identifier* identifier) |
---|
[1505] | 73 | { return this->getIdentifier()->isDirectParentOf(identifier); } |
---|
| 74 | |
---|
| 75 | |
---|
[7401] | 76 | /// Returns true if the object's class is of the given type or a derivative. |
---|
[9565] | 77 | bool Identifiable::isA(const Identifiable* object) |
---|
[1505] | 78 | { return this->getIdentifier()->isA(object->getIdentifier()); } |
---|
[7401] | 79 | /// Returns true if the object's class is exactly of the given type. |
---|
[9565] | 80 | bool Identifiable::isExactlyA(const Identifiable* object) |
---|
[1505] | 81 | { return this->getIdentifier()->isExactlyA(object->getIdentifier()); } |
---|
[7401] | 82 | /// Returns true if the object's class is a child of the given type. |
---|
[9565] | 83 | bool Identifiable::isChildOf(const Identifiable* object) |
---|
[1505] | 84 | { return this->getIdentifier()->isChildOf(object->getIdentifier()); } |
---|
[7401] | 85 | /// Returns true if the object's class is a direct child of the given type. |
---|
[9565] | 86 | bool Identifiable::isDirectChildOf(const Identifiable* object) |
---|
[1505] | 87 | { return this->getIdentifier()->isDirectChildOf(object->getIdentifier()); } |
---|
[7401] | 88 | /// Returns true if the object's class is a parent of the given type. |
---|
[9565] | 89 | bool Identifiable::isParentOf(const Identifiable* object) |
---|
[1505] | 90 | { return this->getIdentifier()->isParentOf(object->getIdentifier()); } |
---|
[7401] | 91 | /// Returns true if the object's class is a direct child of the given type. |
---|
[9565] | 92 | bool Identifiable::isDirectParentOf(const Identifiable* object) |
---|
[1505] | 93 | { return this->getIdentifier()->isDirectParentOf(object->getIdentifier()); } |
---|
| 94 | } |
---|