mirror of https://github.com/Icinga/icinga2.git
Introduce Checkable#GetLastComment()
This commit is contained in:
parent
9169c805a8
commit
2818245e01
|
@ -7,6 +7,7 @@
|
||||||
#include "base/timer.hpp"
|
#include "base/timer.hpp"
|
||||||
#include "base/utility.hpp"
|
#include "base/utility.hpp"
|
||||||
#include "base/logger.hpp"
|
#include "base/logger.hpp"
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
|
@ -42,6 +43,20 @@ std::set<Comment::Ptr> Checkable::GetComments() const
|
||||||
return m_Comments;
|
return m_Comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Comment::Ptr Checkable::GetLastComment() const
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock (m_CommentMutex);
|
||||||
|
Comment::Ptr lastComment;
|
||||||
|
|
||||||
|
for (auto& comment : m_Comments) {
|
||||||
|
if (!lastComment || comment->GetEntryTime() > lastComment->GetEntryTime()) {
|
||||||
|
lastComment = comment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::move(lastComment);
|
||||||
|
}
|
||||||
|
|
||||||
void Checkable::RegisterComment(const Comment::Ptr& comment)
|
void Checkable::RegisterComment(const Comment::Ptr& comment)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(m_CommentMutex);
|
std::unique_lock<std::mutex> lock(m_CommentMutex);
|
||||||
|
|
|
@ -152,6 +152,7 @@ public:
|
||||||
void RemoveCommentsByType(int type, const String& removedBy = String());
|
void RemoveCommentsByType(int type, const String& removedBy = String());
|
||||||
|
|
||||||
std::set<Comment::Ptr> GetComments() const;
|
std::set<Comment::Ptr> GetComments() const;
|
||||||
|
Comment::Ptr GetLastComment() const;
|
||||||
void RegisterComment(const Comment::Ptr& comment);
|
void RegisterComment(const Comment::Ptr& comment);
|
||||||
void UnregisterComment(const Comment::Ptr& comment);
|
void UnregisterComment(const Comment::Ptr& comment);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue