]> granicus.if.org Git - icinga2/blob - lib/base/objectlock.hpp
Merge pull request #7185 from Icinga/bugfix/gelfwriter-wrong-log-facility
[icinga2] / lib / base / objectlock.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef OBJECTLOCK_H
4 #define OBJECTLOCK_H
5
6 #include "base/object.hpp"
7
8 namespace icinga
9 {
10
11 /**
12  * A scoped lock for Objects.
13  */
14 struct ObjectLock
15 {
16 public:
17         ObjectLock(const Object::Ptr& object);
18         ObjectLock(const Object *object);
19
20         ~ObjectLock();
21
22         void Lock();
23         void Unlock();
24
25 private:
26         const Object *m_Object{nullptr};
27         bool m_Locked{false};
28 };
29
30 }
31
32 #endif /* OBJECTLOCK_H */