Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core6/src/libraries/core/class/Identifiable.cc @ 9567

Last change on this file since 9567 was 9567, checked in by landauf, 11 years ago

details

  • Property svn:eol-style set to native
File size: 4.7 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/**
30    @file
31    @brief Implementation of Identifiable.
32*/
33
34#include "Identifiable.h"
35
36#include <cassert>
37#include "core/object/MetaObjectList.h"
38#include "core/object/Context.h"
39#include "Identifier.h"
40
41namespace orxonox
42{
43    /**
44        @brief Constructor: Sets the default values.
45    */
46    Identifiable::Identifiable()
47    {
48        this->identifier_ = 0;
49        this->parents_ = 0;
50        this->metaList_ = new MetaObjectList();
51        // Optimisation
52        this->objectPointers_.reserve(6);
53    }
54
55    /**
56        @brief Destructor: Removes the object from the object-lists
57    */
58    Identifiable::~Identifiable()
59    {
60//        if (!this->requestedDestruction_)
61//            orxout(internal_warning) << "Destroyed object without destroy() (" << this->getIdentifier()->getName() << ')' << endl;
62
63        this->unregisterObject();
64
65        // parents_ exists only if isCreatingHierarchy() of the associated Identifier returned true while creating the class
66        if (this->parents_)
67            delete this->parents_;
68    }
69
70    /**
71        @brief Removes this object from the object-lists.
72    */
73    void Identifiable::unregisterObject()
74    {
75        if (this->metaList_)
76            delete this->metaList_;
77        this->metaList_ = 0;
78    }
79
80    /// Returns true if the object's class is of the given type or a derivative.
81    bool Identifiable::isA(const Identifier* identifier)
82        { return this->getIdentifier()->isA(identifier); }
83    /// Returns true if the object's class is exactly of the given type.
84    bool Identifiable::isExactlyA(const Identifier* identifier)
85        { return this->getIdentifier()->isExactlyA(identifier); }
86    /// Returns true if the object's class is a child of the given type.
87    bool Identifiable::isChildOf(const Identifier* identifier)
88        { return this->getIdentifier()->isChildOf(identifier); }
89    /// Returns true if the object's class is a direct child of the given type.
90    bool Identifiable::isDirectChildOf(const Identifier* identifier)
91        { return this->getIdentifier()->isDirectChildOf(identifier); }
92    /// Returns true if the object's class is a parent of the given type.
93    bool Identifiable::isParentOf(const Identifier* identifier)
94        { return this->getIdentifier()->isParentOf(identifier); }
95    /// Returns true if the object's class is a direct parent of the given type.
96    bool Identifiable::isDirectParentOf(const Identifier* identifier)
97        { return this->getIdentifier()->isDirectParentOf(identifier); }
98
99
100    /// Returns true if the object's class is of the given type or a derivative.
101    bool Identifiable::isA(const Identifiable* object)
102        { return this->getIdentifier()->isA(object->getIdentifier()); }
103    /// Returns true if the object's class is exactly of the given type.
104    bool Identifiable::isExactlyA(const Identifiable* object)
105        { return this->getIdentifier()->isExactlyA(object->getIdentifier()); }
106    /// Returns true if the object's class is a child of the given type.
107    bool Identifiable::isChildOf(const Identifiable* object)
108        { return this->getIdentifier()->isChildOf(object->getIdentifier()); }
109    /// Returns true if the object's class is a direct child of the given type.
110    bool Identifiable::isDirectChildOf(const Identifiable* object)
111        { return this->getIdentifier()->isDirectChildOf(object->getIdentifier()); }
112    /// Returns true if the object's class is a parent of the given type.
113    bool Identifiable::isParentOf(const Identifiable* object)
114        { return this->getIdentifier()->isParentOf(object->getIdentifier()); }
115    /// Returns true if the object's class is a direct child of the given type.
116    bool Identifiable::isDirectParentOf(const Identifiable* object)
117        { return this->getIdentifier()->isDirectParentOf(object->getIdentifier()); }
118}
Note: See TracBrowser for help on using the repository browser.