]> granicus.if.org Git - icinga2/blob - lib/base/configobject.ti
Merge pull request #7185 from Icinga/bugfix/gelfwriter-wrong-log-facility
[icinga2] / lib / base / configobject.ti
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #include "base/debuginfo.hpp"
4 #include "base/configtype.hpp"
5
6 library base;
7
8 namespace icinga
9 {
10
11 code {{{
12 enum HAMode
13 {
14         HARunOnce,
15         HARunEverywhere
16 };
17
18 class NameComposer
19 {
20 public:
21         virtual ~NameComposer();
22
23         virtual String MakeName(const String& shortName, const Object::Ptr& context) const = 0;
24         virtual Dictionary::Ptr ParseName(const String& name) const = 0;
25 };
26 }}}
27
28 abstract class ConfigObjectBase
29 { };
30
31 code {{{
32 class ConfigObjectBase : public ObjectImpl<ConfigObjectBase>
33 {
34 public:
35         inline DebugInfo GetDebugInfo() const
36         {
37                 return m_DebugInfo;
38         }
39
40         void SetDebugInfo(const DebugInfo& di)
41         {
42                 m_DebugInfo = di;
43         }
44
45         inline virtual void Start(bool /* runtimeCreated */)
46         { }
47
48         inline virtual void Stop(bool /* runtimeRemoved */)
49         { }
50
51 private:
52         DebugInfo m_DebugInfo;
53 };
54
55 }}}
56
57 abstract class ConfigObject : ConfigObjectBase < ConfigType
58 {
59         [config, no_user_modify] String __name (Name);
60         [config, no_user_modify] String "name" (ShortName) {
61                 get {{{
62                         if (m_ShortName.IsEmpty())
63                                 return GetName();
64                         else
65                                 return m_ShortName;
66                 }}}
67         };
68         [config, no_user_modify] name(Zone) zone (ZoneName);
69         [config, no_user_modify] String package;
70         [config, get_protected, no_user_modify] Array::Ptr templates;
71         [config, no_storage, no_user_modify] Dictionary::Ptr source_location {
72                 get;
73         };
74         [get_protected, no_user_modify] bool active;
75         [get_protected, no_user_modify] bool paused {
76                 default {{{ return true; }}}
77         };
78         [get_protected, no_user_view, no_user_modify] bool start_called;
79         [get_protected, no_user_view, no_user_modify] bool stop_called;
80         [get_protected, no_user_view, no_user_modify] bool pause_called;
81         [get_protected, no_user_view, no_user_modify] bool resume_called;
82         [enum] HAMode ha_mode (HAMode);
83         [protected, no_user_view, no_user_modify] Dictionary::Ptr extensions;
84
85         [protected, no_user_view, no_user_modify] bool state_loaded;
86         [no_user_modify] Dictionary::Ptr original_attributes;
87         [state, no_user_modify] double version {
88                 default {{{ return 0; }}}
89         };
90 };
91
92 }