31 #ifndef WRAPPER_DATABASETRYLOCK_HPP_ 32 #define WRAPPER_DATABASETRYLOCK_HPP_ 76 : ref(db), name(lockName), locked(false) {
77 this->locked = this->ref.tryDatabaseLock(this->name);
89 this->ref.removeDatabaseLock(this->name);
131 : ref(other.ref), name(other.name), locked(other.locked) {
132 other.locked =
false;
157 this->ref.removeDatabaseLock(this->name);
159 this->locked =
false;
162 this->ref = std::move(other.ref);
163 this->name = std::move(other.name);
164 this->locked = other.locked;
DatabaseTryLock(DB &db, const std::string &lockName)
Constructor locking the database if it is not already locked.
Definition: DatabaseTryLock.hpp:75
bool isActive() const noexcept
Checks the status of the database lock.
Definition: DatabaseTryLock.hpp:104
DatabaseTryLock(DatabaseTryLock &&other) noexcept
Move constructor.
Definition: DatabaseTryLock.hpp:130
Template class for safe in-scope database locks.
Definition: DatabaseTryLock.hpp:51
Namespace for RAII wrappers and Wrapper::Database.
Definition: Database.hpp:109
virtual ~DatabaseTryLock()
Destructor unlocking the database if necessary.
Definition: DatabaseTryLock.hpp:87
DatabaseTryLock & operator=(DatabaseTryLock &)=delete
Deleted copy assignment operator.
DatabaseTryLock & operator=(DatabaseTryLock &&other) noexcept
Move assignment operator.
Definition: DatabaseTryLock.hpp:154