2019-02-25 14:48:22 +01:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2013-02-24 08:27:00 +01:00
|
|
|
|
|
|
|
#ifndef OBJECTLOCK_H
|
|
|
|
#define OBJECTLOCK_H
|
|
|
|
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "base/object.hpp"
|
2013-03-16 21:18:53 +01:00
|
|
|
|
2013-02-24 08:27:00 +01:00
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A scoped lock for Objects.
|
|
|
|
*/
|
2017-12-31 07:22:16 +01:00
|
|
|
struct ObjectLock
|
2016-08-16 13:25:36 +02:00
|
|
|
{
|
2013-02-24 08:27:00 +01:00
|
|
|
public:
|
2018-01-03 06:01:02 +01:00
|
|
|
ObjectLock(const Object::Ptr& object);
|
|
|
|
ObjectLock(const Object *object);
|
2016-01-19 15:25:44 +01:00
|
|
|
|
2022-12-08 12:06:59 +01:00
|
|
|
ObjectLock(const ObjectLock&) = delete;
|
|
|
|
ObjectLock& operator=(const ObjectLock&) = delete;
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
~ObjectLock();
|
2014-11-12 06:33:20 +01:00
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
void Lock();
|
|
|
|
void Unlock();
|
2013-02-24 08:27:00 +01:00
|
|
|
|
|
|
|
private:
|
2018-01-04 09:43:49 +01:00
|
|
|
const Object *m_Object{nullptr};
|
|
|
|
bool m_Locked{false};
|
2013-02-24 08:27:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* OBJECTLOCK_H */
|