Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 453


Ignore:
Timestamp:
Dec 10, 2007, 5:07:46 PM (17 years ago)
Author:
landauf
Message:

added benschs Debug.h from orxonox_v1

include Debug.h or CoreIncludes.h and use it in the following way:
COUT(int) << bla;
PRINT(int)(bla);
PRINTF(int)(bla);

where 'bla' is the same as if you would use the normal std::cout or printf function
and 'int' is a value between 0 and 5:
0 = no debug output
1 = errors
2 = warnings
3 = info
4 = debug
5 = more debug

so to print a warning, use int = 2
for some unimportant debug information, use int = 4
and so on…

the level of the output is configured in the Debug.h file (later i'll add an entry to the config-file for the soft-level).

Location:
code/branches/objecthierarchy/src
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/CMakeLists.txt

    r443 r453  
    33# create a few variables to simplify life
    44SET(SRC_FILES orxonox/orxonox.cc loader/LevelLoader.cc xml/xmlParser.cc orxonox/core/IdentifierList.cc orxonox/core/Identifier.cc orxonox/core/MetaObjectList.cc orxonox/core/Factory.cc orxonox/core/OrxonoxClass.cc orxonox/core/ConfigValueContainer.cc orxonox/objects/BaseObject.cc orxonox/objects/test1.cc orxonox/objects/test2.cc orxonox/objects/test3.cc)
    5 SET(INC_FILES loader/LevelLoader.h xml/xmlParser.h orxonox/core/CoreIncludes.h orxonox/core/Identifier.h orxonox/core/Factory.h orxonox/core/ClassFactory.h orxonox/core/IdentifierList.h orxonox/core/ObjectList.h orxonox/core/MetaObjectList.h orxonox/core/Iterator.h orxonox/core/OrxonoxClass.h orxonox/core/ConfigValueContainer.h orxonox/objects/BaseObject.h orxonox/objects/Test.h orxonox/objects/test1.h orxonox/objects/test2.h orxonox/objects/test3.h orxonox/objects/Tickable.h orxonox/objects/Timer.h)
     5SET(INC_FILES loader/LevelLoader.h xml/xmlParser.h orxonox/core/CoreIncludes.h orxonox/core/Debug.h orxonox/core/Identifier.h orxonox/core/Factory.h orxonox/core/ClassFactory.h orxonox/core/IdentifierList.h orxonox/core/ObjectList.h orxonox/core/MetaObjectList.h orxonox/core/Iterator.h orxonox/core/OrxonoxClass.h orxonox/core/ConfigValueContainer.h orxonox/objects/BaseObject.h orxonox/objects/Test.h orxonox/objects/test1.h orxonox/objects/test2.h orxonox/objects/test3.h orxonox/objects/Tickable.h orxonox/objects/Timer.h)
    66
    77#Creates an executable
  • code/branches/objecthierarchy/src/orxonox/core/ClassFactory.h

    r452 r453  
    1010
    1111#include "Identifier.h"
     12#include "Debug.h"
    1213
    1314namespace orxonox
     
    4445        // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
    4546        ClassIdentifier<T>::getIdentifier()->startCreatingHierarchy();
    46 #if HIERARCHY_VERBOSE
    47         std::cout << "*** Create Factory -> Create Class\n";
    48 #endif
     47        COUT(4) << "*** Create Factory -> Create Class\n";
    4948        BaseObject* temp = ClassIdentifier<T>::getIdentifier()->fabricate();
    5049        delete temp;
  • code/branches/objecthierarchy/src/orxonox/core/CoreIncludes.h

    r450 r453  
    1717#include "OrxonoxClass.h"
    1818#include "ConfigValueContainer.h"
     19#include "Debug.h"
    1920
    2021#include "OgreVector2.h"
     
    5657    @param ClassName The name of the class
    5758*/
    58 #if HIERARCHY_VERBOSE
    5959#define RegisterObject(ClassName) \
    60     std::cout << "*** Register Object: " << #ClassName << "\n"; \
     60    COUT(4) << "*** Register Object: " << #ClassName << "\n"; \
    6161    InternRegisterObject(ClassName, false)
    62 #else
    63 #define RegisterObject(ClassName) \
    64     InternRegisterObject(ClassName, false)
    65 #endif
    6662
    6763/**
     
    6965    @param ClassName The name of the class
    7066*/
    71 #if HIERARCHY_VERBOSE
    7267#define RegisterRootObject(ClassName) \
    73     std::cout << "*** Register Root-Object: " << #ClassName << "\n"; \
     68    COUT(4) << "*** Register Root-Object: " << #ClassName << "\n"; \
    7469    InternRegisterRootObject(ClassName)
    75 #else
    76 #define RegisterRootObject(ClassName) \
    77     InternRegisterRootObject(ClassName)
    78 #endif
    7970
    8071/**
  • code/branches/objecthierarchy/src/orxonox/core/Identifier.cc

    r447 r453  
    4141    void Identifier::initialize(const IdentifierList* parents)
    4242    {
    43 #if HIERARCHY_VERBOSE
    44         std::cout << "*** Initialize " << this->name_ << "-Singleton.\n";
    45 #endif
     43        COUT(4) << "*** Initialize " << this->name_ << "-Singleton.\n";
    4644        this->bCreatedOneObject_ = true;
    4745
     
    7270        {
    7371            // Abstract classes don't have a factory and therefore can't create new objects
    74             std::cout << "Error: Cannot create an object of type '" << this->name_ << "'. Class is abstract.\n";
    75             std::cout << "Aborting...";
     72            COUT(1) << "Error: Cannot create an object of type '" << this->name_ << "'. Class is abstract.\n";
     73            COUT(1) << "Aborting...";
    7674            abort();
    7775        }
  • code/branches/objecthierarchy/src/orxonox/core/Identifier.h

    r452 r453  
    3232#include "Factory.h"
    3333#include "ConfigValueContainer.h"
    34 
    35 #define HIERARCHY_VERBOSE 0
    36 
     34#include "Debug.h"
    3735
    3836namespace orxonox
     
    118116            {
    119117                hierarchyCreatingCounter_s++;
    120 #if HIERARCHY_VERBOSE
    121                 std::cout << "*** Increased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << "\n";
    122 #endif
     118                COUT(4) << "*** Increased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << "\n";
    123119            }
    124120
     
    129125            {
    130126                hierarchyCreatingCounter_s--;
    131 #if HIERARCHY_VERBOSE
    132                 std::cout << "*** Decreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << "\n";
    133 #endif
     127                COUT(4) << "*** Decreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << "\n";
    134128            }
    135129
     
    206200    ClassIdentifier<T>* ClassIdentifier<T>::registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass)
    207201    {
    208 #if HIERARCHY_VERBOSE
    209         std::cout << "*** Register Class in " << name << "-Singleton.\n";
    210 #endif
     202        COUT(4) << "*** Register Class in " << name << "-Singleton.\n";
    211203
    212204        // It's a singleton, so maybe we have to create it first
    213205        if (!pointer_s)
    214206        {
    215 #if HIERARCHY_VERBOSE
    216             std::cout << "*** Register Class in " << name << "-Singleton -> Create Singleton.\n";
    217 #endif
     207            COUT(4) << "*** Register Class in " << name << "-Singleton -> Create Singleton.\n";
    218208            pointer_s = new ClassIdentifier();
    219209        }
     
    224214            // If no: We have to store the informations and initialize the Identifier
    225215
    226 #if HIERARCHY_VERBOSE
    227             std::cout << "*** Register Class in " << name << "-Singleton -> Initialize Singleton.\n";
    228 #endif
     216            COUT(4) << "*** Register Class in " << name << "-Singleton -> Initialize Singleton.\n";
    229217            pointer_s->name_ = name;
    230218            Factory::add(name, pointer_s); // Add the Identifier to the Factory
     
    247235        if (!pointer_s)
    248236        {
    249 #if HIERARCHY_VERBOSE
    250             std::cout << "*** Create Singleton.\n";
    251 #endif
     237            COUT(4) << "*** Create Singleton.\n";
    252238            pointer_s = new ClassIdentifier();
    253239        }
     
    263249    void ClassIdentifier<T>::addObject(T* object)
    264250    {
    265 #if HIERARCHY_VERBOSE
    266         std::cout << "*** Added object to " << ClassIdentifier<T>::getIdentifier()->getName() << "-list.\n";
    267 #endif
     251        COUT(4) << "*** Added object to " << ClassIdentifier<T>::getIdentifier()->getName() << "-list.\n";
    268252        object->getMetaList().add(ClassIdentifier<T>::getIdentifier()->objects_, ClassIdentifier<T>::getIdentifier()->objects_->add(object));
    269253    }
     
    300284                if (!identifier->isA(ClassIdentifier<T>::getIdentifier()))
    301285                {
    302                     std::cout << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!\n";
    303                     std::cout << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden.\n";
    304                     std::cout << "Aborting...\n";
     286                    COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!\n";
     287                    COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden.\n";
     288                    COUT(1) << "Aborting...\n";
    305289                    abort();
    306290                }
     
    346330                    if (this->identifier_)
    347331                    {
    348                         std::cout << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!\n";
    349                         std::cout << "Error: Couldn't fabricate a new Object.\n";
    350                         std::cout << "Aborting...\n";
     332                        COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!\n";
     333                        COUT(1) << "Error: Couldn't fabricate a new Object.\n";
     334                        COUT(1) << "Aborting...\n";
    351335                    }
    352336                    else
    353337                    {
    354                         std::cout << "Error: Couldn't fabricate a new Object - Identifier is undefined.\n";
    355                         std::cout << "Aborting...\n";
     338                        COUT(1) << "Error: Couldn't fabricate a new Object - Identifier is undefined.\n";
     339                        COUT(1) << "Aborting...\n";
    356340                    }
    357341
  • code/branches/objecthierarchy/src/orxonox/core/Iterator.h

    r452 r453  
    1818#ifndef _Iterator_H__
    1919#define _Iterator_H__
     20
     21#include "Debug.h"
    2022
    2123namespace orxonox
     
    100102                // Comparing with anything except zero makes no sense
    101103                if (compare != 0)
    102                     std::cout << "Warning: Comparing the " << ClassIdentifier<T>::getIdentifier()->getName() << "-List-Iterator with " << compare << " has no effect. Only comparison with 0 works.\n";
     104                    COUT(2) << "Warning: Comparing the " << ClassIdentifier<T>::getIdentifier()->getName() << "-List-Iterator with " << compare << " has no effect. Only comparison with 0 works.\n";
    103105
    104106                return (this->element_ != 0);
  • code/branches/objecthierarchy/src/orxonox/core/MetaObjectList.h

    r447 r453  
    1313#include "ObjectList.h"
    1414#include "Identifier.h"
     15#include "Debug.h"
    1516
    1617namespace orxonox
     
    6970
    7071
    71 #if HIERARCHY_VERBOSE
    72         std::cout << "*** Removing Object from " << ClassIdentifier<T>::getIdentifier()->getName() << "-list.\n";
    73 #endif
     72        COUT(4) << "*** Removing Object from " << ClassIdentifier<T>::getIdentifier()->getName() << "-list.\n";
    7473        delete this->element_;
    7574    }
Note: See TracChangeset for help on using the changeset viewer.