Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (9 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/input/InputManager.cc

    r10624 r11071  
    3939#include <ois/OISException.h>
    4040#include <ois/OISInputManager.h>
    41 #include <boost/foreach.hpp>
    4241#include <loki/ScopeGuard.h>
    4342
     
    7271    InputHandler InputHandler::EMPTY;
    7372
    74     InputManager* InputManager::singletonPtr_s = 0;
     73    InputManager* InputManager::singletonPtr_s = nullptr;
    7574
    7675    //! Defines the |= operator for easier use.
     
    9493    InputManager::InputManager()
    9594        : internalState_(Bad)
    96         , oisInputManager_(0)
     95        , oisInputManager_(nullptr)
    9796        , devices_(2)
    9897        , exclusiveMouse_(false)
    99         , emptyState_(0)
    100         , calibratorCallbackHandler_(0)
     98        , emptyState_(nullptr)
     99        , calibratorCallbackHandler_(nullptr)
    101100    {
    102101        RegisterObject(InputManager);
     
    149148        // When loading the devices they should not already be loaded
    150149        assert(internalState_ & Bad);
    151         assert(devices_[InputDeviceEnumerator::Mouse] == 0);
    152         assert(devices_[InputDeviceEnumerator::Keyboard] == 0);
     150        assert(devices_[InputDeviceEnumerator::Mouse] == nullptr);
     151        assert(devices_[InputDeviceEnumerator::Keyboard] == nullptr);
    153152        assert(devices_.size() == InputDeviceEnumerator::FirstJoyStick);
    154153
     
    210209        catch (const std::exception& ex)
    211210        {
    212             oisInputManager_ = NULL;
     211            oisInputManager_ = nullptr;
    213212            internalState_ |= Bad;
    214213            ThrowException(InitialisationFailed, "Could not initialise the input system: " << ex.what());
     
    294293
    295294        // Reset console commands
    296         ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(0);
    297         ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(0);
     295        ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(nullptr);
     296        ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(nullptr);
    298297
    299298        orxout(internal_status, context::input) << "InputManager: Destruction complete." << endl;
     
    310309        orxout(verbose, context::input) << "InputManager: Destroying devices..." << endl;
    311310
    312         BOOST_FOREACH(InputDevice*& device, devices_)
    313         {
    314             if (device == NULL)
     311        for (InputDevice*& device : devices_)
     312        {
     313            if (device == nullptr)
    315314                continue;
    316315            const std::string& className = device->getClassName();
    317316            delete device;
    318             device = 0;
     317            device = nullptr;
    319318            orxout(verbose, context::input) << className << " destroyed." << endl;
    320319        }
    321320        devices_.resize(InputDeviceEnumerator::FirstJoyStick);
    322321
    323         assert(oisInputManager_ != NULL);
     322        assert(oisInputManager_ != nullptr);
    324323        try
    325324        {
     
    331330                                                   << "Potential resource leak!" << endl;
    332331        }
    333         oisInputManager_ = NULL;
     332        oisInputManager_ = nullptr;
    334333
    335334        internalState_ |= Bad;
     
    374373        // check whether a state has changed its EMPTY situation
    375374        bool bUpdateRequired = false;
    376         for (std::map<int, InputState*>::iterator it = activeStates_.begin(); it != activeStates_.end(); ++it)
    377         {
    378             if (it->second->hasExpired())
    379             {
    380                 it->second->resetExpiration();
     375        for (const auto& mapEntry : activeStates_)
     376        {
     377            if (mapEntry.second->hasExpired())
     378            {
     379                mapEntry.second->resetExpiration();
    381380                bUpdateRequired = true;
    382381            }
     
    387386        // Capture all the input and collect the function calls
    388387        // No event gets triggered here yet!
    389         BOOST_FOREACH(InputDevice* device, devices_)
    390             if (device != NULL)
     388        for  (InputDevice* device : devices_)
     389            if (device != nullptr)
    391390                device->update(time);
    392391
    393392        // Collect function calls for the update
    394         for (unsigned int i = 0; i < activeStatesTicked_.size(); ++i)
    395             activeStatesTicked_[i]->update(time.getDeltaTime());
     393        for (InputState* state : activeStatesTicked_)
     394            state->update(time.getDeltaTime());
    396395
    397396        // Execute all cached function calls in order
     
    402401        // If we delay the calls, then OIS and and the InputStates are not anymore
    403402        // in the call stack and can therefore be edited.
    404         for (size_t i = 0; i < this->callBuffer_.size(); ++i)
    405             this->callBuffer_[i]();
     403        for (auto& function : this->callBuffer_)
     404            function();
    406405
    407406        this->callBuffer_.clear();
     
    419418        for (unsigned int i = 0; i < devices_.size(); ++i)
    420419        {
    421             if (devices_[i] == NULL)
     420            if (devices_[i] == nullptr)
    422421                continue;
    423422            std::vector<InputState*>& states = devices_[i]->getStateListRef();
     
    438437        // Using an std::set to avoid duplicates
    439438        std::set<InputState*> tempSet;
    440         for (unsigned int i = 0; i < devices_.size(); ++i)
    441             if (devices_[i] != NULL)
    442                 for (unsigned int iState = 0; iState < devices_[i]->getStateListRef().size(); ++iState)
    443                     tempSet.insert(devices_[i]->getStateListRef()[iState]);
     439        for (InputDevice* device : devices_)
     440            if (device != nullptr)
     441                for (unsigned int iState = 0; iState < device->getStateListRef().size(); ++iState)
     442                    tempSet.insert(device->getStateListRef()[iState]);
    444443
    445444        // Copy the content of the std::set back to the actual vector
    446445        activeStatesTicked_.clear();
    447         for (std::set<InputState*>::const_iterator it = tempSet.begin();it != tempSet.end(); ++it)
    448             activeStatesTicked_.push_back(*it);
     446        for (InputState* state : tempSet)
     447            activeStatesTicked_.push_back(state);
    449448
    450449        // Check whether we have to change the mouse mode
     
    466465    void InputManager::clearBuffers()
    467466    {
    468         BOOST_FOREACH(InputDevice* device, devices_)
    469             if (device != NULL)
     467        for (InputDevice* device : devices_)
     468            if (device != nullptr)
    470469                device->clearBuffers();
    471470    }
     
    476475                        << "When done, put the axex in the middle position and press enter." << endl;
    477476
    478         BOOST_FOREACH(InputDevice* device, devices_)
    479             if (device != NULL)
     477        for (InputDevice* device : devices_)
     478            if (device != nullptr)
    480479                device->startCalibration();
    481480
     
    487486    void InputManager::stopCalibration()
    488487    {
    489         BOOST_FOREACH(InputDevice* device, devices_)
    490             if (device != NULL)
     488        for (InputDevice* device : devices_)
     489            if (device != nullptr)
    491490                device->stopCalibration();
    492491
     
    509508    {
    510509        Mouse* mouse = static_cast<Mouse*>(devices_[InputDeviceEnumerator::Mouse]);
    511         if (mouse != NULL)
     510        if (mouse != nullptr)
    512511        {
    513512            const OIS::MouseState state = mouse->getOISDevice()->getMouseState();
     
    526525    {
    527526        if (name.empty())
    528             return 0;
     527            return nullptr;
    529528        if (statesByName_.find(name) == statesByName_.end())
    530529        {
     
    532531            {
    533532                // Make sure we don't add two high priority states with the same priority
    534                 for (std::map<std::string, InputState*>::const_iterator it = this->statesByName_.begin();
    535                     it != this->statesByName_.end(); ++it)
     533                for (const auto& mapEntry : this->statesByName_)
    536534                {
    537                     if (it->second->getPriority() == priority)
     535                    if (mapEntry.second->getPriority() == priority)
    538536                    {
    539537                        orxout(internal_warning, context::input) << "Could not add an InputState with the same priority '"
    540538                            << static_cast<int>(priority) << "' != 0." << endl;
    541                         return 0;
     539                        return nullptr;
    542540                    }
    543541                }
     
    551549        {
    552550            orxout(internal_warning, context::input) << "Could not add an InputState with the same name '" << name << "'." << endl;
    553             return 0;
     551            return nullptr;
    554552        }
    555553    }
     
    561559            return it->second;
    562560        else
    563             return 0;
     561            return nullptr;
    564562    }
    565563
Note: See TracChangeset for help on using the changeset viewer.