Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/OrxonoxClass.cc @ 9193

Last change on this file since 9193 was 8858, checked in by landauf, 13 years ago

merged output branch back to trunk.

Changes:

  • you have to include util/Output.h instead of util/Debug.h
  • COUT(x) is now called orxout(level)
  • output levels are now defined by an enum instead of numbers. see util/Output.h for the definition
  • it's possible to use output contexts with orxout(level, context). see util/Output.h for some common contexts. you can define more contexts
  • you must use 'endl' at the end of an output message, '\n' does not flush the message

Output levels:

  • instead of COUT(0) use orxout()
  • instead of COUT(1) use orxout(user_error) or orxout(internal_error)
  • instead of COUT(2) use orxout(user_warning) or orxout(internal_warning)
  • instead of COUT(3) use orxout(user_status/user_info) or orxout(internal_status/internal_info)
  • instead of COUT(4) use orxout(verbose)
  • instead of COUT(5) use orxout(verbose_more)
  • instead of COUT(6) use orxout(verbose_ultra)

Guidelines:

  • user_* levels are for the user, visible in the console and the log-file
  • internal_* levels are for developers, visible in the log-file
  • verbose_* levels are for debugging, only visible if the context of the output is activated

Usage in C++:

  • orxout() << "message" << endl;
  • orxout(level) << "message" << endl;
  • orxout(level, context) << "message" << endl;

Usage in Lua:

  • orxout("message")
  • orxout(orxonox.level.levelname, "message")
  • orxout(orxonox.level.levelname, "context", "message")

Usage in Tcl (and in the in-game-console):

  • orxout levelname message
  • orxout_context levelname context message
  • shortcuts: log message, error message, warning message, status message, info message, debug message
  • Property svn:eol-style set to native
File size: 5.6 KB
RevLine 
[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
[7401]31    @brief Implementation of OrxonoxClass.
[1505]32*/
33
34#include "OrxonoxClass.h"
[3196]35
[6105]36#include <cassert>
[1505]37#include "MetaObjectList.h"
38#include "Identifier.h"
39
40namespace orxonox
41{
[7401]42    /**
43        @brief Constructor: Sets the default values.
44    */
[1747]45    OrxonoxClass::OrxonoxClass()
[1505]46    {
[1747]47        this->identifier_ = 0;
48        this->parents_ = 0;
[1505]49        this->metaList_ = new MetaObjectList();
[5929]50        this->referenceCount_ = 0;
51        this->requestedDestruction_ = false;
[6417]52        // Optimisation
53        this->objectPointers_.reserve(6);
[1505]54    }
55
[7401]56    /**
[7849]57        @brief Destructor: Removes the object from the object-lists, notifies all DestructionListener (for example @ref WeakPtr "weak pointers") that this object is being deleted.
[7401]58    */
[1505]59    OrxonoxClass::~OrxonoxClass()
60    {
[5929]61//        if (!this->requestedDestruction_)
[8858]62//            orxout(internal_warning) << "Destroyed object without destroy() (" << this->getIdentifier()->getName() << ')' << endl;
[5929]63
64        assert(this->referenceCount_ <= 0);
65
[6417]66        this->unregisterObject();
[1505]67
68        // parents_ exists only if isCreatingHierarchy() of the associated Identifier returned true while creating the class
69        if (this->parents_)
70            delete this->parents_;
[6417]71
[7849]72        // notify all destruction listeners
73        for (std::set<DestructionListener*>::iterator it = this->destructionListeners_.begin(); it != this->destructionListeners_.end(); )
[5929]74            (*(it++))->objectDeleted();
[1505]75    }
76
[7401]77    /**
78        @brief Deletes the object if no @ref orxonox::SmartPtr "smart pointers" point to this object. Otherwise schedules the object to be deleted as soon as possible.
79    */
[5929]80    void OrxonoxClass::destroy()
81    {
[6105]82        assert(this); // Just in case someone tries to delete a NULL pointer
[5929]83        this->requestedDestruction_ = true;
84        if (this->referenceCount_ == 0)
[6417]85        {
86            this->preDestroy();
87            if (this->referenceCount_ == 0)
88                delete this;
89        }
[5929]90    }
91
[7401]92    /**
93        @brief Removes this object from the object-lists.
94    */
[6417]95    void OrxonoxClass::unregisterObject()
96    {
97        if (this->metaList_)
98            delete this->metaList_;
99        this->metaList_ = 0;
100    }
101
[7401]102    /// Returns true if the object's class is of the given type or a derivative.
[1505]103    bool OrxonoxClass::isA(const Identifier* identifier)
104        { return this->getIdentifier()->isA(identifier); }
[7401]105    /// Returns true if the object's class is exactly of the given type.
[1505]106    bool OrxonoxClass::isExactlyA(const Identifier* identifier)
107        { return this->getIdentifier()->isExactlyA(identifier); }
[7401]108    /// Returns true if the object's class is a child of the given type.
[1505]109    bool OrxonoxClass::isChildOf(const Identifier* identifier)
110        { return this->getIdentifier()->isChildOf(identifier); }
[7401]111    /// Returns true if the object's class is a direct child of the given type.
[1505]112    bool OrxonoxClass::isDirectChildOf(const Identifier* identifier)
113        { return this->getIdentifier()->isDirectChildOf(identifier); }
[7401]114    /// Returns true if the object's class is a parent of the given type.
[1505]115    bool OrxonoxClass::isParentOf(const Identifier* identifier)
116        { return this->getIdentifier()->isParentOf(identifier); }
[7401]117    /// Returns true if the object's class is a direct parent of the given type.
[1505]118    bool OrxonoxClass::isDirectParentOf(const Identifier* identifier)
119        { return this->getIdentifier()->isDirectParentOf(identifier); }
120
121
[7401]122    /// Returns true if the object's class is of the given type or a derivative.
[1505]123    bool OrxonoxClass::isA(const OrxonoxClass* object)
124        { return this->getIdentifier()->isA(object->getIdentifier()); }
[7401]125    /// Returns true if the object's class is exactly of the given type.
[1505]126    bool OrxonoxClass::isExactlyA(const OrxonoxClass* object)
127        { return this->getIdentifier()->isExactlyA(object->getIdentifier()); }
[7401]128    /// Returns true if the object's class is a child of the given type.
[1505]129    bool OrxonoxClass::isChildOf(const OrxonoxClass* object)
130        { return this->getIdentifier()->isChildOf(object->getIdentifier()); }
[7401]131    /// Returns true if the object's class is a direct child of the given type.
[1505]132    bool OrxonoxClass::isDirectChildOf(const OrxonoxClass* object)
133        { return this->getIdentifier()->isDirectChildOf(object->getIdentifier()); }
[7401]134    /// Returns true if the object's class is a parent of the given type.
[1505]135    bool OrxonoxClass::isParentOf(const OrxonoxClass* object)
136        { return this->getIdentifier()->isParentOf(object->getIdentifier()); }
[7401]137    /// Returns true if the object's class is a direct child of the given type.
[1505]138    bool OrxonoxClass::isDirectParentOf(const OrxonoxClass* object)
139        { return this->getIdentifier()->isDirectParentOf(object->getIdentifier()); }
140}
Note: See TracBrowser for help on using the repository browser.