]> granicus.if.org Git - icinga2/blob - lib/icinga/dependency.hpp
Replace Copyright header with a short version, part I
[icinga2] / lib / icinga / dependency.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef DEPENDENCY_H
4 #define DEPENDENCY_H
5
6 #include "icinga/i2-icinga.hpp"
7 #include "icinga/dependency-ti.hpp"
8
9 namespace icinga
10 {
11
12 class ApplyRule;
13 struct ScriptFrame;
14 class Host;
15 class Service;
16
17 /**
18  * A service dependency..
19  *
20  * @ingroup icinga
21  */
22 class Dependency final : public ObjectImpl<Dependency>
23 {
24 public:
25         DECLARE_OBJECT(Dependency);
26         DECLARE_OBJECTNAME(Dependency);
27
28         intrusive_ptr<Checkable> GetParent() const;
29         intrusive_ptr<Checkable> GetChild() const;
30
31         TimePeriod::Ptr GetPeriod() const;
32
33         bool IsAvailable(DependencyType dt) const;
34
35         void ValidateStates(const Lazy<Array::Ptr>& lvalue, const ValidationUtils& utils) override;
36
37         static void EvaluateApplyRules(const intrusive_ptr<Host>& host);
38         static void EvaluateApplyRules(const intrusive_ptr<Service>& service);
39
40 protected:
41         void OnConfigLoaded() override;
42         void OnAllConfigLoaded() override;
43         void Stop(bool runtimeRemoved) override;
44
45 private:
46         Checkable::Ptr m_Parent;
47         Checkable::Ptr m_Child;
48
49         static bool EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule);
50         static bool EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule);
51 };
52
53 }
54
55 #endif /* DEPENDENCY_H */