Implement bool operator for ObjectLock

This commit is contained in:
Yonas Habteab 2025-07-08 17:23:34 +02:00
parent 4c0628c24d
commit 8ef921aa5e
2 changed files with 14 additions and 0 deletions

View File

@ -65,3 +65,15 @@ void ObjectLock::Unlock()
m_Locked = false;
}
}
/**
* Returns true if the object is locked, false otherwise.
*
* This operator allows using ObjectLock in boolean contexts.
*
* @returns true if the object is locked, false otherwise.
*/
ObjectLock::operator bool() const
{
return m_Locked;
}

View File

@ -26,6 +26,8 @@ public:
void Lock();
void Unlock();
operator bool() const;
private:
const Object *m_Object{nullptr};
bool m_Locked{false};