1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #include "icinga/service.hpp"
4 #include "remote/configobjectutility.hpp"
5 #include "base/configtype.hpp"
6 #include "base/objectlock.hpp"
7 #include "base/timer.hpp"
8 #include "base/utility.hpp"
9 #include "base/logger.hpp"
11 using namespace icinga;
14 void Checkable::RemoveAllComments()
16 for (const Comment::Ptr& comment : GetComments()) {
17 Comment::RemoveComment(comment->GetName());
21 void Checkable::RemoveCommentsByType(int type)
23 for (const Comment::Ptr& comment : GetComments()) {
24 /* Do not remove persistent comments from an acknowledgement */
25 if (comment->GetEntryType() == CommentAcknowledgement && comment->GetPersistent())
28 if (comment->GetEntryType() == type)
29 Comment::RemoveComment(comment->GetName());
33 std::set<Comment::Ptr> Checkable::GetComments() const
35 boost::mutex::scoped_lock lock(m_CommentMutex);
39 void Checkable::RegisterComment(const Comment::Ptr& comment)
41 boost::mutex::scoped_lock lock(m_CommentMutex);
42 m_Comments.insert(comment);
45 void Checkable::UnregisterComment(const Comment::Ptr& comment)
47 boost::mutex::scoped_lock lock(m_CommentMutex);
48 m_Comments.erase(comment);