From 91fc09e3e92ecba0eb18f37df7808cfb900307a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 30 Dec 2019 16:55:07 +0100 Subject: [PATCH] Prefix internal Resource members with an underscore. --- src/Magnum/Resource.h | 66 +++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/Magnum/Resource.h b/src/Magnum/Resource.h index c44c9019d..2af10328d 100644 --- a/src/Magnum/Resource.h +++ b/src/Magnum/Resource.h @@ -127,11 +127,11 @@ class Resource { * Creates empty resource. Resources are acquired from the manager by * calling @ref ResourceManager::get(). */ - explicit Resource(): manager(nullptr), lastCheck(0), _state(ResourceState::Final), data(nullptr) {} + explicit Resource(): _manager{nullptr}, _lastCheck{0}, _state{ResourceState::Final}, _data{nullptr} {} /** @brief Copy constructor */ - Resource(const Resource& other): manager(other.manager), _key(other._key), lastCheck(other.lastCheck), _state(other._state), data(other.data) { - if(manager) manager->incrementReferenceCount(_key); + Resource(const Resource& other): _manager{other._manager}, _key{other._key}, _lastCheck{other._lastCheck}, _state{other._state}, _data{other._data} { + if(_manager) _manager->incrementReferenceCount(_key); } /** @brief Move constructor */ @@ -139,7 +139,7 @@ class Resource { /** @brief Destructor */ ~Resource() { - if(manager) manager->decrementReferenceCount(_key); + if(_manager) _manager->decrementReferenceCount(_key); } /** @brief Copy assignment */ @@ -150,7 +150,7 @@ class Resource { /** @brief Equality comparison */ bool operator==(const Resource& other) const { - return manager == other.manager && _key == other._key; + return _manager == other._manager && _key == other._key; } /** @brief Equality comparison with other types is explicitly disallowed */ @@ -187,7 +187,7 @@ class Resource { */ operator bool() { acquire(); - return data; + return _data; } /** @@ -197,7 +197,7 @@ class Resource { */ operator U*() { acquire(); - return static_cast(data); + return static_cast(_data); } /** @@ -209,8 +209,8 @@ class Resource { */ U& operator*() { acquire(); - CORRADE_ASSERT(data, "Resource: accessing not loaded data with key" << key(), *static_cast(data)); - return *static_cast(data); + CORRADE_ASSERT(_data, "Resource: accessing not loaded data with key" << _key, *static_cast(_data)); + return *static_cast(_data); } /** @@ -222,8 +222,8 @@ class Resource { */ U* operator->() { acquire(); - CORRADE_ASSERT(data, "Resource: accessing not loaded data with key" << key(), nullptr); - return static_cast(data); + CORRADE_ASSERT(_data, "Resource: accessing not loaded data with key" << _key, nullptr); + return static_cast(_data); } private: @@ -231,47 +231,47 @@ class Resource { friend Implementation::ResourceManagerData; #endif - Resource(Implementation::ResourceManagerData* manager, ResourceKey key): manager(manager), _key(key), lastCheck(0), _state(ResourceState::NotLoaded), data(nullptr) { + Resource(Implementation::ResourceManagerData* manager, ResourceKey key): _manager{manager}, _key{key}, _lastCheck{0}, _state{ResourceState::NotLoaded}, _data{nullptr} { manager->incrementReferenceCount(key); } void acquire(); - Implementation::ResourceManagerData* manager; + Implementation::ResourceManagerData* _manager; ResourceKey _key; - std::size_t lastCheck; + std::size_t _lastCheck; ResourceState _state; - T* data; + T* _data; }; template Resource& Resource::operator=(const Resource& other) { - if(manager) manager->decrementReferenceCount(_key); + if(_manager) _manager->decrementReferenceCount(_key); - manager = other.manager; + _manager = other._manager; _key = other._key; - lastCheck = other.lastCheck; + _lastCheck = other._lastCheck; _state = other._state; - data = other.data; + _data = other._data; - if(manager) manager->incrementReferenceCount(_key); + if(_manager) _manager->incrementReferenceCount(_key); return *this; } -template Resource::Resource(Resource&& other) noexcept: manager(other.manager), _key(other._key), lastCheck(other.lastCheck), _state(other._state), data(other.data) { - other.manager = nullptr; +template Resource::Resource(Resource&& other) noexcept: _manager(other._manager), _key(other._key), _lastCheck(other._lastCheck), _state(other._state), _data(other._data) { + other._manager = nullptr; other._key = {}; - other.lastCheck = 0; + other._lastCheck = 0; other._state = ResourceState::Final; - other.data = nullptr; + other._data = nullptr; } template Resource& Resource::operator=(Resource&& other) noexcept { using std::swap; - swap(manager, other.manager); + swap(_manager, other._manager); swap(_key, other._key); - swap(lastCheck, other.lastCheck); + swap(_lastCheck, other._lastCheck); swap(_state, other._state); - swap(data, other.data); + swap(_data, other._data); return *this; } @@ -280,20 +280,20 @@ template void Resource::acquire() { if(_state == ResourceState::Final) return; /* Nothing changed since last check */ - if(manager->lastChange() < lastCheck) return; + if(_manager->lastChange() < _lastCheck) return; /* Acquire new data and save last check time */ - const typename Implementation::ResourceManagerData::Data& d = manager->data(_key); - lastCheck = manager->lastChange(); + const typename Implementation::ResourceManagerData::Data& d = _manager->data(_key); + _lastCheck = _manager->lastChange(); /* Try to get the data */ - data = d.data; + _data = d.data; _state = static_cast(d.state); /* Data are not available */ - if(!data) { + if(!_data) { /* Fallback found, add *Fallback to state */ - if((data = manager->fallback())) { + if((_data = _manager->fallback())) { if(_state == ResourceState::Loading) _state = ResourceState::LoadingFallback; else if(_state == ResourceState::NotFound)