Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core5/src/libraries/core/OrxonoxClass.cc @ 5791

Last change on this file since 5791 was 5791, checked in by landauf, 15 years ago

Added destroy() function to OrxonoxClass.
Removed destroy() functions from some subclasses.
Expanded Timer to accept Functors of other classes too.

  • Property svn:eol-style set to native
File size: 4.6 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 the OrxonoxClass Class.
32*/
33
34#include "OrxonoxClass.h"
35
36#include "MetaObjectList.h"
37#include "Identifier.h"
38
39namespace orxonox
40{
41    /** @brief Constructor: Sets the default values. */
42    OrxonoxClass::OrxonoxClass()
43    {
44        this->identifier_ = 0;
45        this->parents_ = 0;
46        this->metaList_ = new MetaObjectList();
47        this->referenceCount_ = 0;
48        this->requestedDestruction_ = false;
49    }
50
51    /** @brief Destructor: Deletes, if existing, the list of the parents. */
52    OrxonoxClass::~OrxonoxClass()
53    {
54        delete this->metaList_;
55
56        // parents_ exists only if isCreatingHierarchy() of the associated Identifier returned true while creating the class
57        if (this->parents_)
58            delete this->parents_;
59    }
60
61    /** @brief Deletes the object if no smart pointers point to this object. Otherwise schedules the object to be deleted as soon as possible. */
62    void OrxonoxClass::destroy()
63    {
64        if (this->referenceCount_ > 0)
65            this->requestedDestruction_ = true;
66        else
67            delete this;
68    }
69
70    /** @brief Returns true if the objects class is of the given type or a derivative. */
71    bool OrxonoxClass::isA(const Identifier* identifier)
72        { return this->getIdentifier()->isA(identifier); }
73    /** @brief Returns true if the objects class is exactly of the given type. */
74    bool OrxonoxClass::isExactlyA(const Identifier* identifier)
75        { return this->getIdentifier()->isExactlyA(identifier); }
76    /** @brief Returns true if the objects class is a child of the given type. */
77    bool OrxonoxClass::isChildOf(const Identifier* identifier)
78        { return this->getIdentifier()->isChildOf(identifier); }
79    /** @brief Returns true if the objects class is a direct child of the given type. */
80    bool OrxonoxClass::isDirectChildOf(const Identifier* identifier)
81        { return this->getIdentifier()->isDirectChildOf(identifier); }
82    /** @brief Returns true if the objects class is a parent of the given type. */
83    bool OrxonoxClass::isParentOf(const Identifier* identifier)
84        { return this->getIdentifier()->isParentOf(identifier); }
85    /** @brief Returns true if the objects class is a direct parent of the given type. */
86    bool OrxonoxClass::isDirectParentOf(const Identifier* identifier)
87        { return this->getIdentifier()->isDirectParentOf(identifier); }
88
89
90    /** @brief Returns true if the objects class is of the given type or a derivative. */
91    bool OrxonoxClass::isA(const OrxonoxClass* object)
92        { return this->getIdentifier()->isA(object->getIdentifier()); }
93    /** @brief Returns true if the objects class is exactly of the given type. */
94    bool OrxonoxClass::isExactlyA(const OrxonoxClass* object)
95        { return this->getIdentifier()->isExactlyA(object->getIdentifier()); }
96    /** @brief Returns true if the objects class is a child of the given type. */
97    bool OrxonoxClass::isChildOf(const OrxonoxClass* object)
98        { return this->getIdentifier()->isChildOf(object->getIdentifier()); }
99    /** @brief Returns true if the objects class is a direct child of the given type. */
100    bool OrxonoxClass::isDirectChildOf(const OrxonoxClass* object)
101        { return this->getIdentifier()->isDirectChildOf(object->getIdentifier()); }
102    /** @brief Returns true if the objects class is a parent of the given type. */
103    bool OrxonoxClass::isParentOf(const OrxonoxClass* object)
104        { return this->getIdentifier()->isParentOf(object->getIdentifier()); }
105    /** @brief Returns true if the objects class is a direct child of the given type. */
106    bool OrxonoxClass::isDirectParentOf(const OrxonoxClass* object)
107        { return this->getIdentifier()->isDirectParentOf(object->getIdentifier()); }
108}
Note: See TracBrowser for help on using the repository browser.