Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 23, 2009, 7:28:48 PM (15 years ago)
Author:
rgrieder
Message:

Add a new core-feature: orxonox_cast<T>()
The functions casts objects like dynamic_cast, but uses the identifier instead for MSVC (much faster) and is just a redirection to dynamic_cast for GCC.
Also replaced almost all dynamic_casts (of course only those related to the class hierarchy).

Location:
code/branches/core4/src/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core4/src/network/NetworkFunction.h

    r3214 r3223  
    150150    {
    151151      if ( Synchronisable::getSynchronisable(objectID)!=0 )
    152         (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)));
     152        (*this->functor_)(orxonox_cast<T>(Synchronisable::getSynchronisable(objectID)));
    153153    }
    154154    inline void call(uint32_t objectID, const MultiType& mt1)
    155155    {
    156156      if ( Synchronisable::getSynchronisable(objectID)!=0 )
    157         (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1);
     157        (*this->functor_)(orxonox_cast<T>(Synchronisable::getSynchronisable(objectID)), mt1);
    158158    }
    159159    inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)
    160160    {
    161161      if ( Synchronisable::getSynchronisable(objectID)!=0 )
    162         (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2);
     162        (*this->functor_)(orxonox_cast<T>(Synchronisable::getSynchronisable(objectID)), mt1, mt2);
    163163    }
    164164    inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
    165165    {
    166166      if ( Synchronisable::getSynchronisable(objectID)!=0 )
    167         (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3);
     167        (*this->functor_)(orxonox_cast<T>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3);
    168168    }
    169169    inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
    170170    {
    171171      if ( Synchronisable::getSynchronisable(objectID)!=0 )
    172         (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4);
     172        (*this->functor_)(orxonox_cast<T>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4);
    173173    }
    174174    inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
    175175    {
    176176      if ( Synchronisable::getSynchronisable(objectID)!=0 )
    177         (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4, mt5);
     177        (*this->functor_)(orxonox_cast<T>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4, mt5);
    178178    }
    179179   
  • code/branches/core4/src/network/synchronisable/Synchronisable.cc

    r3214 r3223  
    7373    if (creator)
    7474    {
    75         Synchronisable* synchronisable_creator = dynamic_cast<Synchronisable*>(creator);
     75        Synchronisable* synchronisable_creator = orxonox_cast<Synchronisable>(creator);
    7676        if (synchronisable_creator && synchronisable_creator->objectMode_)
    7777        {
     
    161161      }
    162162      else
    163         creator = dynamic_cast<BaseObject*>(synchronisable_creator);
     163        creator = orxonox_cast<BaseObject>(synchronisable_creator);
    164164    }
    165165    assert(getSynchronisable(header.getObjectID())==0);   //make sure no object with this id exists
    166166    BaseObject *bo = id->fabricate(creator);
    167167    assert(bo);
    168     Synchronisable *no = dynamic_cast<Synchronisable *>(bo);
     168    Synchronisable *no = orxonox_cast<Synchronisable>(bo);
    169169    assert(no);
    170170    no->objectID=header.getObjectID();
Note: See TracChangeset for help on using the changeset viewer.