Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.