Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7271


Ignore:
Timestamp:
Aug 30, 2010, 8:07:38 PM (14 years ago)
Author:
rgrieder
Message:

There is no such word as "casted".
Also inserted 4 static_casts and replaced dynamic_cast with orxonox_cast in WeakPtr and SmartPtr.
Moreover found some weird code in Iterator.h with casting. Casting a NULL pointer always yields another NULL pointer.

Location:
code/trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/core/CorePrereqs.h

    r7169 r7271  
    115115{
    116116    typedef std::string LanguageEntryLabel;
     117
     118    template <class T, class U>
     119    T orxonox_cast(U*);
    117120
    118121    class ArgumentCompleter;
  • code/trunk/src/libraries/core/Event.cc

    r7163 r7271  
    103103                    {
    104104                        // else cast the pointer to the desired class
    105                         void* castedOriginator = event.originator_->getDerivedPointer(this->subclass_->getClassID());
    106                         (*this->statefunction_)(event.activate_, castedOriginator);
     105                        void* castOriginator = event.originator_->getDerivedPointer(this->subclass_->getClassID());
     106                        (*this->statefunction_)(event.activate_, castOriginator);
    107107                    }
    108108                }
  • code/trunk/src/libraries/core/Identifier.h

    r7266 r7271  
    484484    */
    485485    template <class T, class U>
    486     FORCEINLINE T orxonox_cast(U source)
     486    FORCEINLINE T orxonox_cast(U* source)
    487487    {
    488488#ifdef ORXONOX_COMPILER_MSVC
  • code/trunk/src/libraries/core/Iterator.h

    r7268 r7271  
    3232
    3333    The Iterator of a given class allows to iterate through an ObjectList. Objects in
    34     this list are casted to the template argument of the Iterator.
     34    this list are cast to the template argument of the Iterator.
    3535
    3636    Usage:
     
    9595            inline Iterator(ObjectListElement<O>* element)
    9696            {
    97                 this->element_ = (element) ? static_cast<ObjectListBaseElement*>(element) : 0;
     97                this->element_ = element;
    9898                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
    9999                this->list_->registerIterator(this);
     
    107107            inline Iterator(const ObjectListIterator<O>& other)
    108108            {
    109                 this->element_ = (other.element_) ? static_cast<ObjectListBaseElement*>(other.element_) : 0;
     109                this->element_ = other.element_;
    110110                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
    111111                this->list_->registerIterator(this);
     
    162162                    this->list_->unregisterIterator(this);
    163163
    164                 this->element_ = (element) ? static_cast<ObjectListBaseElement*>(element) : 0;
     164                this->element_ = element;
    165165                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
    166166                this->list_->registerIterator(this);
     
    179179                    this->list_->unregisterIterator(this);
    180180
    181                 this->element_ = (other.element_) ? static_cast<ObjectListBaseElement*>(other.element_) : 0;
     181                this->element_ = other.element_;
    182182                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
    183183                this->list_->registerIterator(this);
  • code/trunk/src/libraries/core/ObjectList.h

    r5738 r7271  
    6161            /** @brief Returns an Iterator to the first element in the list. @return The Iterator */
    6262            inline static ObjectListElement<T>* begin()
    63                 { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->begin().element_); }
     63            {
     64                ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects();
     65                return static_cast<ObjectListElement<T>*>(list->begin().element_);
     66            }
    6467
    6568            /** @brief Returns an Iterator to the element after the last element in the list. @return The Iterator */
    6669            inline static ObjectListElement<T>* end()
    67                 { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->end().element_); }
     70            {
     71                ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects();
     72                return static_cast<ObjectListElement<T>*>(list->end().element_);
     73            }
    6874
    6975            /** @brief Returns an Iterator to the last element in the list. @return The Iterator */
    7076            inline static ObjectListElement<T>* rbegin()
    71                 { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->rbegin().element_); }
     77            {
     78                ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects();
     79                return static_cast<ObjectListElement<T>*>(list->rbegin().element_);
     80            }
    7281
    7382            /** @brief Returns an Iterator to the element before the first element in the list. @return The Iterator */
    7483            inline static ObjectListElement<T>* rend()
    75                 { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->rend().element_); }
     84            {
     85                ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects();
     86                return static_cast<ObjectListElement<T>*>(list->rend().element_);
     87            }
    7688    };
    7789}
  • code/trunk/src/libraries/core/XMLPort.h

    r7163 r7271  
    541541            void callLoadExecutor(BaseObject* object, BaseObject* newObject)
    542542            {
    543                 T* castedObject = orxonox_cast<T*>(object);
    544                 assert(castedObject);
    545                 O* castedNewObject = orxonox_cast<O*>(newObject);
    546                 assert(castedNewObject);
    547 
    548                 (*this->loadexecutor_)(castedObject, castedNewObject);
     543                T* castObject = orxonox_cast<T*>(object);
     544                assert(castObject);
     545                O* castNewObject = orxonox_cast<O*>(newObject);
     546                assert(castNewObject);
     547
     548                (*this->loadexecutor_)(castObject, castNewObject);
    549549            }
    550550
  • code/trunk/src/libraries/core/input/InputDevice.h

    r7174 r7271  
    132132        {
    133133            oisDevice_ = static_cast<OISDeviceClass*>(oisInputManager_->createInputObject(OISDeviceValue, true));
    134             // Note: after the static_cast here, the casted this pointer becomes
     134            // Note: after the static_cast here, the cast this pointer becomes
    135135            //       invalid right until the subclass has been constructed!
    136136            oisDevice_->setEventCallback(static_cast<DeviceClass*>(this));
  • code/trunk/src/modules/objects/triggers/MultiTrigger.h

    r7163 r7271  
    8282            'simultaniousTriggerers':   The number of simultanious triggerers limits the number of object that are allowed to trigger the MultiTrigger at the same time. Or a little more precisely, the number of distinct objects the MultiTrigger has 'triggered' states for, at each point in time.
    8383            'mode':                     The mode describes how the MultiTrigger acts in relation to all the MultiTriggers, that are appended to it. There are 3 modes: 'and', meaning that the MultiTrigger can only be triggered if all the appended MultiTriggers are active. 'or', meaning that the MultiTrigger can only triggered if at least one of the appendend MultiTriggers is active. And 'xor', meaning that the MultiTrigger can only be triggered if one and only one appended MultiTrigger is active. Notice, that I wrote 'can only be active', that implies, that there is an addtitional condition to the activity of the MultiTrigger and that is the fulfillment of the triggering condition (the MultiTrigger itself doesn't have one, but all derived classes should). Also bear in mind, that the activity of a MultiTrigger is still coupled to the object that triggered it. The default is 'and'.
    84             'broadcast'                 Broadcast is a bool, if true the MutliTrigger is in broadcast-mode, meaining, that all trigger events that are caused by no originator (originator is NULL) are broadcasted as having come from every possible originator, or more precisely as having come from all objects that are specified targets of this MultiTrigger.
     84            'broadcast'                 Broadcast is a bool, if true the MutliTrigger is in broadcast-mode, meaining, that all trigger events that are caused by no originator (originator is NULL) are broadcast as having come from every possible originator, or more precisely as having come from all objects that are specified targets of this MultiTrigger.
    8585            'target':                   The target describes the kind of objects that are allowed to trigger this MultiTrigger. The default is 'Pawn'.
    8686            Also there is the possibility of appending MultiTriggers to the MultiTrigger just by adding them as subobjects in the XML description of your MultiTrigger.
Note: See TracChangeset for help on using the changeset viewer.