Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 2, 2015, 11:22:03 PM (9 years ago)
Author:
landauf
Message:

use actual types instead of 'auto'. only exception is for complicated template types, e.g. when iterating over a map

Location:
code/branches/cpp11_v2/src/libraries/core/class
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/core/class/Identifier.cc

    r10821 r10916  
    8787        for (std::list<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)
    8888            const_cast<Identifier*>(*it)->directChildren_.erase(this);
    89         for (const auto & elem : this->children_)
    90             const_cast<Identifier*>(elem)->parents_.remove(this);
    91         for (const auto & elem : this->directChildren_)
    92             const_cast<Identifier*>(elem)->directParents_.remove(this);
    93 
    94         for (auto & elem : this->configValues_)
    95             delete (elem.second);
    96         for (auto & elem : this->xmlportParamContainers_)
    97             delete (elem.second);
    98         for (auto & elem : this->xmlportObjectContainers_)
    99             delete (elem.second);
     89        for (const Identifier* child : this->children_)
     90            const_cast<Identifier*>(child)->parents_.remove(this);
     91        for (const Identifier* directChild : this->directChildren_)
     92            const_cast<Identifier*>(directChild)->directParents_.remove(this);
     93
     94        for (auto& mapEntry : this->configValues_)
     95            delete (mapEntry.second);
     96        for (auto& mapEntry : this->xmlportParamContainers_)
     97            delete (mapEntry.second);
     98        for (auto& mapEntry : this->xmlportObjectContainers_)
     99            delete (mapEntry.second);
    100100    }
    101101
     
    157157        if (this->directParents_.empty())
    158158        {
    159             for (const auto & elem : initializationTrace)
    160                 if (elem != this)
    161                     this->parents_.push_back(elem);
     159            for (const Identifier* identifier : initializationTrace)
     160                if (identifier != this)
     161                    this->parents_.push_back(identifier);
    162162        }
    163163        else
     
    261261
    262262        // if any parent class is virtual, it will be instantiated first, so we need to add them first.
    263         for (const auto & elem : this->parents_)
    264         {
    265             if ((elem)->isVirtualBase())
     263        for (const Identifier* parent : this->parents_)
     264        {
     265            if (parent->isVirtualBase())
    266266            {
    267                 for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(elem)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(elem)->parents_.end(); ++it_parent_parent)
     267                for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(parent)->parents_.end(); ++it_parent_parent)
    268268                    this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent);
    269                 this->addIfNotExists(expectedIdentifierTrace, elem);
     269                this->addIfNotExists(expectedIdentifierTrace, parent);
    270270            }
    271271        }
    272272
    273273        // now all direct parents get created recursively. already added identifiers (e.g. virtual base classes) are not added again.
    274         for (const auto & elem : this->directParents_)
    275         {
    276             for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(elem)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(elem)->parents_.end(); ++it_parent_parent)
     274        for (const Identifier* directParent : this->directParents_)
     275        {
     276            for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(directParent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(directParent)->parents_.end(); ++it_parent_parent)
    277277                this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent);
    278             this->addIfNotExists(expectedIdentifierTrace, elem);
     278            this->addIfNotExists(expectedIdentifierTrace, directParent);
    279279        }
    280280
     
    285285
    286286            orxout(internal_warning) << "  Actual trace (after creating a sample instance):" << endl << "    ";
    287             for (const auto & elem : this->parents_)
    288                 orxout(internal_warning) << " " << (elem)->getName();
     287            for (const Identifier* parent : this->parents_)
     288                orxout(internal_warning) << " " << parent->getName();
    289289            orxout(internal_warning) << endl;
    290290
     
    295295
    296296            orxout(internal_warning) << "  Direct parents (according to class hierarchy definitions):" << endl << "    ";
    297             for (const auto & elem : this->directParents_)
    298                 orxout(internal_warning) << " " << (elem)->getName();
     297            for (const Identifier* directParent : this->directParents_)
     298                orxout(internal_warning) << " " << directParent->getName();
    299299            orxout(internal_warning) << endl;
    300300        }
  • code/branches/cpp11_v2/src/libraries/core/class/Identifier.h

    r10821 r10916  
    462462
    463463        if (updateChildren)
    464             for (const auto & elem : this->getChildren())
    465                 (elem)->updateConfigValues(false);
     464            for (const Identifier* child : this->getChildren())
     465                child->updateConfigValues(false);
    466466    }
    467467
  • code/branches/cpp11_v2/src/libraries/core/class/IdentifierManager.cc

    r10821 r10916  
    9393        {
    9494            Context temporaryContext(nullptr);
    95             for (auto identifier : this->identifiers_)
     95            for (Identifier* identifier : this->identifiers_)
    9696            {
    97                
    9897                if (identifier->isInitialized())
    9998                    continue;
     
    127126
    128127        // finish the initialization of all identifiers
    129         for (const auto & initializedIdentifier : initializedIdentifiers)
    130             (initializedIdentifier)->finishInitialization();
     128        for (Identifier* initializedIdentifier : initializedIdentifiers)
     129            initializedIdentifier->finishInitialization();
    131130
    132131        // only check class hierarchy in dev mode because it's an expensive operation and it requires a developer to fix detected problems anyway.
     
    144143    {
    145144        // check if there are any uninitialized identifiers remaining
    146         for (const auto & elem : this->identifiers_)
    147             if (!(elem)->isInitialized())
    148                 orxout(internal_error) << "Identifier was registered late and is not initialized: " << (elem)->getName() << " / " << (elem)->getTypeInfo().name() << endl;
     145        for (Identifier* identifier : this->identifiers_)
     146            if (!identifier->isInitialized())
     147                orxout(internal_error) << "Identifier was registered late and is not initialized: " << identifier->getName() << " / " << identifier->getTypeInfo().name() << endl;
    149148
    150149        // for all initialized identifiers, check if a sample instance behaves as expected according to the class hierarchy
    151150        Context temporaryContext(nullptr);
    152         for (const auto & initializedIdentifier : initializedIdentifiers)
     151        for (Identifier* initializedIdentifier : initializedIdentifiers)
    153152        {
    154             if (!(initializedIdentifier)->hasFactory())
     153            if (!initializedIdentifier->hasFactory())
    155154                continue;
    156155
    157             Identifiable* temp = (initializedIdentifier)->fabricate(&temporaryContext);
    158 
    159             for (const auto & elem : this->identifiers_)
     156            Identifiable* temp = initializedIdentifier->fabricate(&temporaryContext);
     157
     158            for (Identifier* identifier : this->identifiers_)
    160159            {
    161                 bool isA_AccordingToRtti = (elem)->canDynamicCastObjectToIdentifierClass(temp);
    162                 bool isA_AccordingToClassHierarchy = temp->isA((elem));
     160                bool isA_AccordingToRtti = identifier->canDynamicCastObjectToIdentifierClass(temp);
     161                bool isA_AccordingToClassHierarchy = temp->isA(identifier);
    163162
    164163                if (isA_AccordingToRtti != isA_AccordingToClassHierarchy)
    165164                {
    166                     orxout(internal_error) << "Class hierarchy does not match RTTI: Class hierarchy claims that " << (initializedIdentifier)->getName() <<
    167                         (isA_AccordingToClassHierarchy ? " is a " : " is not a ") << (elem)->getName() << " but RTTI says the opposite." << endl;
     165                    orxout(internal_error) << "Class hierarchy does not match RTTI: Class hierarchy claims that " << initializedIdentifier->getName() <<
     166                        (isA_AccordingToClassHierarchy ? " is a " : " is not a ") << identifier->getName() << " but RTTI says the opposite." << endl;
    168167                }
    169168            }
     
    184183    {
    185184        orxout(internal_status) << "Destroy class-hierarchy" << endl;
    186         for (const auto & elem : this->identifiers_)
    187             (elem)->reset();
     185        for (Identifier* identifier : this->identifiers_)
     186            identifier->reset();
    188187    }
    189188
     
    260259    {
    261260        // TODO: use std::type_index and a map to find identifiers by type_info (only with c++11)
    262         for (const auto & elem : this->identifiers_)
    263             if ((elem)->getTypeInfo() == typeInfo)
    264                 return (elem);
     261        for (Identifier* identifer : this->identifiers_)
     262            if (identifer->getTypeInfo() == typeInfo)
     263                return identifer;
    265264        return nullptr;
    266265    }
Note: See TracChangeset for help on using the changeset viewer.