2019-02-25 08:48:22 -05:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2014-02-27 05:05:55 -05:00
|
|
|
|
|
|
|
|
#ifndef DEPENDENCY_H
|
|
|
|
|
#define DEPENDENCY_H
|
|
|
|
|
|
2014-05-25 10:23:35 -04:00
|
|
|
#include "icinga/i2-icinga.hpp"
|
2018-01-18 07:50:38 -05:00
|
|
|
#include "icinga/dependency-ti.hpp"
|
2014-02-27 05:05:55 -05:00
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
|
{
|
|
|
|
|
|
2014-05-11 11:14:35 -04:00
|
|
|
class ApplyRule;
|
2014-12-12 09:33:02 -05:00
|
|
|
struct ScriptFrame;
|
2014-11-16 10:20:39 -05:00
|
|
|
class Host;
|
|
|
|
|
class Service;
|
2014-05-11 11:14:35 -04:00
|
|
|
|
2014-02-27 05:05:55 -05:00
|
|
|
/**
|
|
|
|
|
* A service dependency..
|
|
|
|
|
*
|
|
|
|
|
* @ingroup icinga
|
|
|
|
|
*/
|
2018-01-04 00:11:04 -05:00
|
|
|
class Dependency final : public ObjectImpl<Dependency>
|
2014-02-27 05:05:55 -05:00
|
|
|
{
|
|
|
|
|
public:
|
2014-11-02 18:44:04 -05:00
|
|
|
DECLARE_OBJECT(Dependency);
|
|
|
|
|
DECLARE_OBJECTNAME(Dependency);
|
2014-02-27 05:05:55 -05:00
|
|
|
|
2018-01-03 22:25:35 -05:00
|
|
|
intrusive_ptr<Checkable> GetParent() const;
|
|
|
|
|
intrusive_ptr<Checkable> GetChild() const;
|
2014-02-27 05:05:55 -05:00
|
|
|
|
2018-01-03 22:25:35 -05:00
|
|
|
TimePeriod::Ptr GetPeriod() const;
|
2014-02-27 05:05:55 -05:00
|
|
|
|
|
|
|
|
bool IsAvailable(DependencyType dt) const;
|
|
|
|
|
|
2018-01-11 01:08:09 -05:00
|
|
|
void ValidateStates(const Lazy<Array::Ptr>& lvalue, const ValidationUtils& utils) override;
|
2014-04-07 07:59:41 -04:00
|
|
|
|
2014-11-16 10:20:39 -05:00
|
|
|
static void EvaluateApplyRules(const intrusive_ptr<Host>& host);
|
|
|
|
|
static void EvaluateApplyRules(const intrusive_ptr<Service>& service);
|
|
|
|
|
|
2020-02-11 09:02:57 -05:00
|
|
|
/* Note: Only use them for unit test mocks. Prefer OnConfigLoaded(). */
|
|
|
|
|
void SetParent(intrusive_ptr<Checkable> parent);
|
|
|
|
|
void SetChild(intrusive_ptr<Checkable> child);
|
|
|
|
|
|
2014-02-27 05:05:55 -05:00
|
|
|
protected:
|
2018-01-03 23:12:56 -05:00
|
|
|
void OnConfigLoaded() override;
|
|
|
|
|
void OnAllConfigLoaded() override;
|
|
|
|
|
void Stop(bool runtimeRemoved) override;
|
2014-04-05 06:56:56 -04:00
|
|
|
|
|
|
|
|
private:
|
2014-06-24 05:46:53 -04:00
|
|
|
Checkable::Ptr m_Parent;
|
|
|
|
|
Checkable::Ptr m_Child;
|
|
|
|
|
|
2015-01-29 06:38:25 -05:00
|
|
|
static bool EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule);
|
2014-11-16 10:20:39 -05:00
|
|
|
static bool EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule);
|
2014-02-27 05:05:55 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* DEPENDENCY_H */
|