Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 10, 2016, 1:54:11 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v2 into cpp11_v3

Location:
code/branches/cpp11_v3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v3

  • code/branches/cpp11_v3/src/libraries/core/input/InputDevice.h

    r8858 r11054  
    6060        //! Only resets the members
    6161        InputDevice(unsigned int id) : bCalibrating_(false), deviceID_(id) { }
    62         virtual ~InputDevice() { }
     62        virtual ~InputDevice() = default;
    6363        //! Returns the device class (derived) name as string
    6464        virtual std::string getClassName() const = 0;
     
    9999
    100100    private:
    101         InputDevice(const InputDevice& rhs); //!< Don't use!
     101        // non-copyable:
     102        InputDevice(const InputDevice&) = delete;
     103        InputDevice& operator=(const InputDevice&) = delete;
    102104
    103105        bool bCalibrating_;                  //!< Whether the device is in calibration mode
     
    153155
    154156        //! Captures OIS events (which then get distributed to the derived class) and creates the button held events
    155         void update(const Clock& time)
     157        virtual void update(const Clock& time) override
    156158        {
    157159            oisDevice_->capture();
    158160
    159161            // Call all the states with the held button event
    160             for (unsigned int iB = 0; iB < pressedButtons_.size(); ++iB)
    161                 for (unsigned int iS = 0; iS < inputStates_.size(); ++iS)
    162                     inputStates_[iS]->buttonEvent<ButtonEvent::THold, typename Traits::ButtonTypeParam>(
    163                         this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(pressedButtons_[iB]));
     162            for (ButtonType& button : pressedButtons_)
     163                for (InputState* state : inputStates_)
     164                    state->template buttonEvent<ButtonEvent::THold, typename Traits::ButtonTypeParam>(
     165                        this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
    164166
    165167            // Call states with device update events
    166             for (unsigned int i = 0; i < inputStates_.size(); ++i)
    167                 inputStates_[i]->update(time.getDeltaTime(), this->getDeviceID());
     168            for (InputState* state : inputStates_)
     169                state->update(time.getDeltaTime(), this->getDeviceID());
    168170
    169171            static_cast<DeviceClass*>(this)->updateImpl(time);
     
    171173
    172174        //! Clears the list of pressed buttons and calls the derived class's method
    173         void clearBuffers()
     175        virtual void clearBuffers() override
    174176        {
    175177            pressedButtons_.clear();
     
    180182        OISDeviceClass* getOISDevice()   { return this->oisDevice_; }
    181183        // Returns the name of the derived class as string
    182         std::string getClassName() const { return DeviceClass::getClassNameImpl(); }
     184        virtual std::string getClassName() const override { return DeviceClass::getClassNameImpl(); }
    183185
    184186    protected:
     
    196198
    197199            // Call states
    198             for (unsigned int i = 0; i < inputStates_.size(); ++i)
    199                 inputStates_[i]->buttonEvent<ButtonEvent::TPress, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
     200            for (InputState* state : inputStates_)
     201                state->template buttonEvent<ButtonEvent::TPress, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
    200202        }
    201203
     
    218220
    219221            // Call states
    220             for (unsigned int i = 0; i < inputStates_.size(); ++i)
    221                 inputStates_[i]->buttonEvent<ButtonEvent::TRelease, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
     222            for (InputState* state : inputStates_)
     223                state->template buttonEvent<ButtonEvent::TRelease, typename Traits::ButtonTypeParam>(this->getDeviceID(), static_cast<DeviceClass*>(this)->getButtonEventArg(button));
    222224        }
    223225
Note: See TracChangeset for help on using the changeset viewer.