summaryrefslogtreecommitdiffstats
path: root/lib/icinga/timeperiod.hpp
blob: a5a2f73fa0a359b08b10a00284447d7cabaa9a4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */

#ifndef TIMEPERIOD_H
#define TIMEPERIOD_H

#include "icinga/i2-icinga.hpp"
#include "icinga/timeperiod-ti.hpp"

namespace icinga
{

/**
 * A time period.
 *
 * @ingroup icinga
 */
class TimePeriod final : public ObjectImpl<TimePeriod>
{
public:
	DECLARE_OBJECT(TimePeriod);
	DECLARE_OBJECTNAME(TimePeriod);

	void Start(bool runtimeCreated) override;

	void UpdateRegion(double begin, double end, bool clearExisting);

	bool GetIsInside() const override;

	bool IsInside(double ts) const;
	double FindNextTransition(double begin);

	void ValidateRanges(const Lazy<Dictionary::Ptr>& lvalue, const ValidationUtils& utils) override;

private:
	void AddSegment(double s, double end);
	void AddSegment(const Dictionary::Ptr& segment);
	void RemoveSegment(double begin, double end);
	void RemoveSegment(const Dictionary::Ptr& segment);
	void PurgeSegments(double end);

	void Merge(const TimePeriod::Ptr& timeperiod, bool include = true);

	void Dump();

	static void UpdateTimerHandler();
};

}

#endif /* TIMEPERIOD_H */