Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3265


Ignore:
Timestamp:
Jul 1, 2009, 1:24:30 PM (15 years ago)
Author:
rgrieder
Message:
  • Removed superfluous convertToString and convertFromString (replaced them with multi_cast)
  • Replaced all getConvertedValue with multi_cast since it doesn't involve a potential implicit cast of the argument (template type deduction always leads to the right type)
  • Using NilValue<T>() instead of zeroise<T>() for better performance (detail, but just caught my eye)
Location:
code/branches/core4/src
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core4/src/core/ArgumentCompletionFunctions.cc

    r3250 r3265  
    143143
    144144            for (std::list<unsigned int>::const_iterator it = threadnumbers.begin(); it != threadnumbers.end(); ++it)
    145                 threads.push_back(ArgumentCompletionListElement(getConvertedValue<unsigned int, std::string>(*it)));
     145                threads.push_back(ArgumentCompletionListElement(multi_cast<std::string>(*it)));
    146146
    147147            return threads;
  • code/branches/core4/src/core/ConfigFileManager.cc

    r3250 r3265  
    124124    {
    125125        if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
    126             return (this->name_ + "[" + getConvertedValue<unsigned int, std::string>(this->index_, "0") + "]" + "=" + this->value_);
    127         else
    128             return (this->name_ + "[" + getConvertedValue<unsigned int, std::string>(this->index_, "0") + "]=" + this->value_ + " " + this->additionalComment_);
     126            return (this->name_ + "[" + multi_cast<std::string>(this->index_, "0") + "]" + "=" + this->value_);
     127        else
     128            return (this->name_ + "[" + multi_cast<std::string>(this->index_, "0") + "]=" + this->value_ + " " + this->additionalComment_);
    129129    }
    130130
  • code/branches/core4/src/core/IRC.cc

    r3196 r3265  
    6868        {   COUT(1) << "Error while initializing Tcl (IRC): " << e.what();   }
    6969
    70         this->nickname_ = "orx" + getConvertedValue<int, std::string>((unsigned int)rand());
     70        this->nickname_ = "orx" + multi_cast<std::string>(static_cast<unsigned int>(rand()));
    7171        TclThreadManager::execute(threadID, "set nickname " + this->nickname_);
    7272        TclThreadManager::execute(threadID, "source irc.tcl");
  • code/branches/core4/src/core/TclThreadManager.cc

    r3196 r3265  
    9494        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
    9595        TclThreadManager::getInstance().threadCounter_++;
    96         std::string name = getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().threadCounter_);
     96        std::string name = multi_cast<std::string>(TclThreadManager::getInstance().threadCounter_);
    9797
    9898        TclInterpreterBundle* bundle = new TclInterpreterBundle;
     
    192192        {
    193193            boost::mutex::scoped_lock queue_lock(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queueMutex_);
    194             output += getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queue_.size());
     194            output += multi_cast<std::string>(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queue_.size());
    195195        }
    196196        output += "\t\t";
     
    201201        for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = TclThreadManager::getInstance().interpreterBundles_.begin(); it != TclThreadManager::getInstance().interpreterBundles_.end(); ++it)
    202202        {
    203             std::string output = getConvertedValue<unsigned int, std::string>((*it).first);
     203            std::string output = multi_cast<std::string>((*it).first);
    204204            output += "\t\t";
    205205            {
    206206                boost::mutex::scoped_lock queue_lock((*it).second->queueMutex_);
    207                 output += getConvertedValue<unsigned int, std::string>((*it).second->queue_.size());
     207                output += multi_cast<std::string>((*it).second->queue_.size());
    208208            }
    209209            output += "\t\t";
     
    342342        else
    343343        {
    344             this->error("Error: No Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(threadID) + " existing.");
     344            this->error("Error: No Tcl-interpreter with ID " + multi_cast<std::string>(threadID) + " existing.");
    345345            return 0;
    346346        }
     
    355355                output += " ";
    356356
    357             output += getConvertedValue<unsigned int, std::string>(*it);
     357            output += multi_cast<std::string>(*it);
    358358        }
    359359        return output;
     
    444444            if (bundle->queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
    445445            {
    446                 this->error("Error: Queue of Tcl-interpreter " + getConvertedValue<unsigned int, std::string>(threadID) + " is full, couldn't add command.");
     446                this->error("Error: Queue of Tcl-interpreter " + multi_cast<std::string>(threadID) + " is full, couldn't add command.");
    447447                return;
    448448            }
     
    492492        if (std::find(target->queriers_.begin(), target->queriers_.end(), target->id_) != target->queriers_.end())
    493493        {
    494             this->error("Error: Circular query (" + this->dumpList(target->queriers_) + " -> " + getConvertedValue<unsigned int, std::string>(target->id_) + "), couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(target->id_) + " from other interpreter with ID " + getConvertedValue<unsigned int, std::string>(querier->id_) + ".");
     494            this->error("Error: Circular query (" + this->dumpList(target->queriers_) + " -> " + multi_cast<std::string>(target->id_) + "), couldn't query Tcl-interpreter with ID " + multi_cast<std::string>(target->id_) + " from other interpreter with ID " + multi_cast<std::string>(querier->id_) + ".");
    495495            return false;
    496496        }
     
    585585                    else
    586586                    {
    587                         this->error("Error: Couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(threadID) + ", interpreter is busy right now.");
     587                        this->error("Error: Couldn't query Tcl-interpreter with ID " + multi_cast<std::string>(threadID) + ", interpreter is busy right now.");
    588588                    }
    589589                }
     
    665665        catch (Tcl::tcl_error const &e)
    666666        {
    667             TclThreadManager::getInstance().error("Tcl (ID " + getConvertedValue<unsigned int, std::string>(interpreterBundle->id_) + ") error: " + e.what());
     667            TclThreadManager::getInstance().error("Tcl (ID " + multi_cast<std::string>(interpreterBundle->id_) + ") error: " + e.what());
    668668        }
    669669        catch (std::exception const &e)
    670670        {
    671             TclThreadManager::getInstance().error("Error while executing Tcl (ID " + getConvertedValue<unsigned int, std::string>(interpreterBundle->id_) + "): " + e.what());
     671            TclThreadManager::getInstance().error("Error while executing Tcl (ID " + multi_cast<std::string>(interpreterBundle->id_) + "): " + e.what());
    672672        }
    673673
  • code/branches/core4/src/core/input/KeyBinder.cc

    r3196 r3265  
    187187        for (unsigned int iDev = 0; iDev < numberOfJoySticks_; iDev++)
    188188        {
    189             std::string deviceNumber = convertToString(iDev);
     189            std::string deviceNumber = multi_cast<std::string>(iDev);
    190190            // joy stick buttons
    191191            for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; i++)
  • code/branches/core4/src/orxonox/objects/gametypes/UnderAttack.cc

    r3196 r3265  
    173173            if ( gameTime_ <= timesequence_ && gameTime_ > 0)
    174174            {
    175                 std::string message = convertToString(timesequence_) + " seconds left!";
     175                std::string message = multi_cast<std::string>(timesequence_) + " seconds left!";
    176176/*
    177177                COUT(0) << message << std::endl;
  • code/branches/core4/src/orxonox/objects/weaponsystem/projectiles/LightningGunProjectile.cc

    r3196 r3265  
    5656        this->materialBase_ = material;   
    5757   
    58         BillboardProjectile::setMaterial(material + convertToString(this->textureIndex_));
     58        BillboardProjectile::setMaterial(material + multi_cast<std::string>(this->textureIndex_));
    5959    }
    6060
  • code/branches/core4/src/orxonox/overlays/OrxonoxOverlay.cc

    r3250 r3265  
    7272        // create the Ogre::Overlay
    7373        overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay_overlay_"
    74             + convertToString(hudOverlayCounter_s++));
     74            + multi_cast<std::string>(hudOverlayCounter_s++));
    7575
    7676        // create background panel (can be used to show any picture)
    7777        this->background_ = static_cast<Ogre::PanelOverlayElement*>(
    7878            Ogre::OverlayManager::getSingleton().createOverlayElement("Panel",
    79             "OrxonoxOverlay_background_" + convertToString(hudOverlayCounter_s++)));
     79            "OrxonoxOverlay_background_" + multi_cast<std::string>(hudOverlayCounter_s++)));
    8080        this->overlay_->add2D(this->background_);
    8181
  • code/branches/core4/src/orxonox/overlays/console/InGameConsole.cc

    r3262 r3265  
    220220        for (int i = 0; i < LINES; i++)
    221221        {
    222             this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + convertToString(i)));
     222            this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + multi_cast<std::string>(i)));
    223223            this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
    224224            this->consoleOverlayTextAreas_[i]->setFontName("MonofurConsole");
  • code/branches/core4/src/orxonox/overlays/hud/GametypeStatus.cc

    r3239 r3265  
    7070            {
    7171                if (gtinfo->isStartCountdownRunning())
    72                     this->setCaption(convertToString((int)ceil(gtinfo->getStartCountdown())));
     72                    this->setCaption(multi_cast<std::string>((int)ceil(gtinfo->getStartCountdown())));
    7373                else if (ce->isA(Class(Spectator)))
    7474                    this->setCaption("Press [Fire] to respawn");
  • code/branches/core4/src/orxonox/overlays/hud/HUDBar.cc

    r3250 r3265  
    7272
    7373        // create new material
    74         std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++);
     74        std::string materialname = "barmaterial" + multi_cast<std::string>(materialcount_s++);
    7575        Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
    7676        material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
  • code/branches/core4/src/orxonox/overlays/hud/HUDHealthBar.cc

    r3239 r3265  
    8383        {
    8484            this->setValue(this->owner_->getHealth() / this->owner_->getInitialHealth());
    85             this->textoverlay_->setCaption(convertToString((int)this->owner_->getHealth()));
     85            this->textoverlay_->setCaption(multi_cast<std::string>((int)this->owner_->getHealth()));
    8686        }
    8787
  • code/branches/core4/src/orxonox/overlays/hud/HUDNavigation.cc

    r3250 r3265  
    142142        // set text
    143143        int dist = (int) getDist2Focus();
    144         navText_->setCaption(convertToString(dist));
    145         float textLength = convertToString(dist).size() * navText_->getCharHeight() * 0.3;
     144        navText_->setCaption(multi_cast<std::string>(dist));
     145        float textLength = multi_cast<std::string>(dist).size() * navText_->getCharHeight() * 0.3;
    146146
    147147/*
  • code/branches/core4/src/orxonox/overlays/hud/HUDTimer.cc

    r3239 r3265  
    5959            if (gametype->getTimerIsActive())
    6060            {
    61                 this->setCaption(convertToString((int)gametype->getTime() + 1));
     61                this->setCaption(multi_cast<std::string>((int)gametype->getTime() + 1));
    6262            }
    6363        }
  • code/branches/core4/src/orxonox/overlays/hud/PongScore.cc

    r3239 r3265  
    8383            {
    8484                name1 = player1->getName();
    85                 score1 = convertToString(this->owner_->getScore(player1));
     85                score1 = multi_cast<std::string>(this->owner_->getScore(player1));
    8686            }
    8787
     
    8989            {
    9090                name2 = player2->getName();
    91                 score2 = convertToString(this->owner_->getScore(player2));
     91                score2 = multi_cast<std::string>(this->owner_->getScore(player2));
    9292            }
    9393
  • code/branches/core4/src/orxonox/overlays/hud/TeamBaseMatchScore.cc

    r3239 r3265  
    7171        if (this->owner_)
    7272        {
    73             std::string bases1 = "(" + convertToString(this->owner_->getTeamBases(0)) + ")";
    74             std::string bases2 = "(" + convertToString(this->owner_->getTeamBases(1)) + ")";
     73            std::string bases1 = "(" + multi_cast<std::string>(this->owner_->getTeamBases(0)) + ")";
     74            std::string bases2 = "(" + multi_cast<std::string>(this->owner_->getTeamBases(1)) + ")";
    7575
    76             std::string score1 = convertToString(this->owner_->getTeamPoints(0));
    77             std::string score2 = convertToString(this->owner_->getTeamPoints(1));
     76            std::string score1 = multi_cast<std::string>(this->owner_->getTeamPoints(0));
     77            std::string score2 = multi_cast<std::string>(this->owner_->getTeamPoints(1));
    7878
    7979            std::string output1;
  • code/branches/core4/src/orxonox/overlays/stats/CreateLines.cc

    r3196 r3265  
    9999    //    while (textColumns_.size() < numberOfColumns)
    100100    //    {
    101     //        Ogre::TextAreaOverlayElement* tempTextArea = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "StatsLineTextArea" + getName() + convertToString(lineIndex) + convertToString(colIndex)));
     101    //        Ogre::TextAreaOverlayElement* tempTextArea = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "StatsLineTextArea" + getName() + multi_cast<std::string>(lineIndex) + multi_cast<std::string>(colIndex)));
    102102    //        textColumns_.push_back(tempTextArea);
    103103    //        this->background_->addChild(tempTextArea);
  • code/branches/core4/src/orxonox/tools/BillboardSet.cc

    r3250 r3265  
    7474            if (GameMode::showsGraphics())
    7575            {
    76                 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
     76                this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + multi_cast<std::string>(BillboardSet::billboardSetCounter_s++), count);
    7777                this->billboardSet_->createBillboard(position);
    7878                this->billboardSet_->setMaterialName(file);
     
    9797            if (GameMode::showsGraphics())
    9898            {
    99                 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
     99                this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + multi_cast<std::string>(BillboardSet::billboardSetCounter_s++), count);
    100100                this->billboardSet_->createBillboard(position, colour);
    101101                this->billboardSet_->setMaterialName(file);
  • code/branches/core4/src/orxonox/tools/Mesh.cc

    r3250 r3265  
    6868            try
    6969            {
    70                 this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
     70                this->entity_ = this->scenemanager_->createEntity("Mesh" + multi_cast<std::string>(Mesh::meshCounter_s++), meshsource);
    7171                this->entity_->setCastShadows(this->bCastShadows_);
    7272
  • code/branches/core4/src/orxonox/tools/ParticleInterface.cc

    r3257 r3265  
    6969            try
    7070            {
    71                 this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
     71                this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + multi_cast<std::string>(ParticleInterface::counter_s++), templateName);
    7272                this->setSpeedFactor(1.0f);
    7373            }
  • code/branches/core4/src/orxonox/tools/TextureGenerator.cc

    r3196 r3265  
    7272        if (it == colourMap.end())
    7373        {
    74             std::string materialName = textureName + "_Material_" + convertToString(materialCount_s++);
     74            std::string materialName = textureName + "_Material_" + multi_cast<std::string>(materialCount_s++);
    7575            Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialName, "General");
    7676            material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
  • code/branches/core4/src/util/Convert.h

    r3250 r3265  
    361361    }
    362362
    363     // convert to string Shortcut
    364     template <class FromType>
    365     FORCEINLINE std::string convertToString(FromType value)
    366     {
    367         return getConvertedValue<FromType, std::string>(value);
    368     }
    369 
    370     // convert from string Shortcut
    371     template <class ToType>
    372     FORCEINLINE ToType convertFromString(std::string str)
    373     {
    374         return getConvertedValue<std::string, ToType>(str);
    375     }
    376 
    377363    ////////////////////////////////
    378364    // Special string conversions //
  • code/branches/core4/src/util/MultiTypeValue.h

    r3257 r3265  
    139139        inline operator bool()                 const { return getConvertedValue<T, bool>                (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    140140        inline operator void*()                const { return getConvertedValue<T, void*>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    141         inline operator std::string()          const { return getConvertedValue<T, std::string>         (this->value_, zeroise<std::string         >()); } /** @brief Returns the current value, converted to the requested type. */
    142         inline operator orxonox::Vector2()     const { return getConvertedValue<T, orxonox::Vector2>    (this->value_, zeroise<orxonox::Vector2    >()); } /** @brief Returns the current value, converted to the requested type. */
    143         inline operator orxonox::Vector3()     const { return getConvertedValue<T, orxonox::Vector3>    (this->value_, zeroise<orxonox::Vector3    >()); } /** @brief Returns the current value, converted to the requested type. */
    144         inline operator orxonox::Vector4()     const { return getConvertedValue<T, orxonox::Vector4>    (this->value_, zeroise<orxonox::Vector4    >()); } /** @brief Returns the current value, converted to the requested type. */
    145         inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, zeroise<orxonox::ColourValue>()); } /** @brief Returns the current value, converted to the requested type. */
    146         inline operator orxonox::Quaternion()  const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, zeroise<orxonox::Quaternion >()); } /** @brief Returns the current value, converted to the requested type. */
    147         inline operator orxonox::Radian()      const { return getConvertedValue<T, orxonox::Radian>     (this->value_, zeroise<orxonox::Radian     >()); } /** @brief Returns the current value, converted to the requested type. */
    148         inline operator orxonox::Degree()      const { return getConvertedValue<T, orxonox::Degree>     (this->value_, zeroise<orxonox::Degree     >()); } /** @brief Returns the current value, converted to the requested type. */
     141        inline operator std::string()          const { return getConvertedValue<T, std::string>         (this->value_, NilValue<std::string         >()); } /** @brief Returns the current value, converted to the requested type. */
     142        inline operator orxonox::Vector2()     const { return getConvertedValue<T, orxonox::Vector2>    (this->value_, NilValue<orxonox::Vector2    >()); } /** @brief Returns the current value, converted to the requested type. */
     143        inline operator orxonox::Vector3()     const { return getConvertedValue<T, orxonox::Vector3>    (this->value_, NilValue<orxonox::Vector3    >()); } /** @brief Returns the current value, converted to the requested type. */
     144        inline operator orxonox::Vector4()     const { return getConvertedValue<T, orxonox::Vector4>    (this->value_, NilValue<orxonox::Vector4    >()); } /** @brief Returns the current value, converted to the requested type. */
     145        inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, NilValue<orxonox::ColourValue>()); } /** @brief Returns the current value, converted to the requested type. */
     146        inline operator orxonox::Quaternion()  const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, NilValue<orxonox::Quaternion >()); } /** @brief Returns the current value, converted to the requested type. */
     147        inline operator orxonox::Radian()      const { return getConvertedValue<T, orxonox::Radian>     (this->value_, NilValue<orxonox::Radian     >()); } /** @brief Returns the current value, converted to the requested type. */
     148        inline operator orxonox::Degree()      const { return getConvertedValue<T, orxonox::Degree>     (this->value_, NilValue<orxonox::Degree     >()); } /** @brief Returns the current value, converted to the requested type. */
    149149
    150150        /** @brief Puts the current value on the stream */
  • code/branches/core4/src/util/StringUtils.cc

    r3250 r3265  
    4444    std::string getUniqueNumberString()
    4545    {
    46         return convertToString(getUniqueNumber());
     46        return multi_cast<std::string>(getUniqueNumber());
    4747    }
    4848
Note: See TracChangeset for help on using the changeset viewer.