summaryrefslogtreecommitdiffstats
path: root/lib/base/configobject.ti
blob: 19b7cde83ba691ba4de0ddcfa3194c734325c007 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */

#include "base/debuginfo.hpp"
#include "base/configtype.hpp"

library base;

namespace icinga
{

code {{{
enum HAMode
{
	HARunOnce,
	HARunEverywhere
};

class NameComposer
{
public:
	virtual ~NameComposer();

	virtual String MakeName(const String& shortName, const Object::Ptr& context) const = 0;
	virtual Dictionary::Ptr ParseName(const String& name) const = 0;
};
}}}

abstract class ConfigObjectBase
{ };

code {{{
class ConfigObjectBase : public ObjectImpl<ConfigObjectBase>
{
public:
	inline DebugInfo GetDebugInfo() const
	{
		return m_DebugInfo;
	}

	void SetDebugInfo(const DebugInfo& di)
	{
		m_DebugInfo = di;
	}

	inline virtual void Start(bool /* runtimeCreated */)
	{ }

	inline virtual void Stop(bool /* runtimeRemoved */)
	{ }

private:
	DebugInfo m_DebugInfo;
};

}}}

abstract class ConfigObject : ConfigObjectBase < ConfigType
{
	[config, no_user_modify] String __name (Name);
	[config, no_user_modify] String "name" (ShortName) {
		get {{{
			String shortName = m_ShortName.load();
			if (shortName.IsEmpty())
				return GetName();
			else
				return shortName;
		}}}
	};
	[config, no_user_modify] name(Zone) zone (ZoneName);
	[config, no_user_modify] String package;
	[config, get_protected, no_user_modify] Array::Ptr templates;
	[config, no_storage, no_user_modify] Dictionary::Ptr source_location {
		get;
	};
	[get_protected, no_user_modify] bool active;
	[get_protected, no_user_modify] bool paused {
		default {{{ return true; }}}
	};
	[get_protected, no_user_view, no_user_modify] bool start_called;
	[get_protected, no_user_view, no_user_modify] bool stop_called;
	[get_protected, no_user_view, no_user_modify] bool pause_called;
	[get_protected, no_user_view, no_user_modify] bool resume_called;
	[enum] HAMode ha_mode (HAMode);
	[protected, no_user_view, no_user_modify] Dictionary::Ptr extensions;

	[protected, no_user_view, no_user_modify] bool state_loaded;
	[no_user_modify] Dictionary::Ptr original_attributes;
	[state, no_user_modify] double version {
		default {{{ return 0; }}}
	};
};

}