]> granicus.if.org Git - icinga2/blob - lib/icinga/comment.hpp
Merge pull request #6727 from Icinga/feature/cluster-config-sync-stage
[icinga2] / lib / icinga / comment.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef COMMENT_H
4 #define COMMENT_H
5
6 #include "icinga/i2-icinga.hpp"
7 #include "icinga/comment-ti.hpp"
8 #include "icinga/checkable-ti.hpp"
9 #include "remote/messageorigin.hpp"
10
11 namespace icinga
12 {
13
14 /**
15  * A comment.
16  *
17  * @ingroup icinga
18  */
19 class Comment final : public ObjectImpl<Comment>
20 {
21 public:
22         DECLARE_OBJECT(Comment);
23         DECLARE_OBJECTNAME(Comment);
24
25         static boost::signals2::signal<void (const Comment::Ptr&)> OnCommentAdded;
26         static boost::signals2::signal<void (const Comment::Ptr&)> OnCommentRemoved;
27
28         intrusive_ptr<Checkable> GetCheckable() const;
29
30         bool IsExpired() const;
31
32         static int GetNextCommentID();
33
34         static String AddComment(const intrusive_ptr<Checkable>& checkable, CommentType entryType,
35                 const String& author, const String& text, bool persistent, double expireTime,
36                 const String& id = String(), const MessageOrigin::Ptr& origin = nullptr);
37
38         static void RemoveComment(const String& id, const MessageOrigin::Ptr& origin = nullptr);
39
40         static String GetCommentIDFromLegacyID(int id);
41
42 protected:
43         void OnAllConfigLoaded() override;
44         void Start(bool runtimeCreated) override;
45         void Stop(bool runtimeRemoved) override;
46
47 private:
48         ObjectImpl<Checkable>::Ptr m_Checkable;
49
50         static void CommentsExpireTimerHandler();
51 };
52
53 }
54
55 #endif /* COMMENT_H */