]> granicus.if.org Git - icinga2/blob - lib/icinga/comment.ti
Fix spelling errors.
[icinga2] / lib / icinga / comment.ti
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #include "base/configobject.hpp"
4 #include "base/utility.hpp"
5 #impl_include "icinga/service.hpp"
6
7 library icinga;
8
9 namespace icinga
10 {
11
12 code {{{
13 /**
14  * The type of a service comment.
15  *
16  * @ingroup icinga
17  */
18 enum CommentType
19 {
20         CommentUser = 1,
21         CommentDowntime = 2,
22         CommentFlapping = 3,
23         CommentAcknowledgement = 4
24 };
25
26 class CommentNameComposer : public NameComposer
27 {
28 public:
29         virtual String MakeName(const String& shortName, const Object::Ptr& context) const;
30         virtual Dictionary::Ptr ParseName(const String& name) const;
31 };
32 }}}
33
34 class Comment : ConfigObject < CommentNameComposer
35 {
36         load_after Host;
37         load_after Service;
38
39         [config, protected, required, navigation(host)] name(Host) host_name {
40                 navigate {{{
41                         return Host::GetByName(GetHostName());
42                 }}}
43         };
44         [config, protected, navigation(service)] String service_name {
45                 track {{{
46                         if (!oldValue.IsEmpty()) {
47                                 Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue);
48                                 DependencyGraph::RemoveDependency(this, service.get());
49                         }
50
51                         if (!newValue.IsEmpty()) {
52                                 Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
53                                 DependencyGraph::AddDependency(this, service.get());
54                         }
55                 }}}
56                 navigate {{{
57                         if (GetServiceName().IsEmpty())
58                                 return nullptr;
59
60                         Host::Ptr host = Host::GetByName(GetHostName());
61                         return host->GetServiceByShortName(GetServiceName());
62                 }}}
63         };
64
65         [config] Timestamp entry_time {
66                 default {{{ return Utility::GetTime(); }}}
67         };
68         [config, enum] CommentType entry_type {
69                 default {{{ return CommentUser; }}}
70         };
71         [config, required] String author;
72         [config, required] String text;
73         [config] bool persistent;
74         [config] Timestamp expire_time;
75         [state] int legacy_id;
76 };
77
78 }