]> granicus.if.org Git - icinga2/blob - lib/base/configobject.ti
lib->compat->statusdatawriter: fix notifications_enabled
[icinga2] / lib / base / configobject.ti
1 /******************************************************************************
2  * Icinga 2                                                                   *
3  * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/)  *
4  *                                                                            *
5  * This program is free software; you can redistribute it and/or              *
6  * modify it under the terms of the GNU General Public License                *
7  * as published by the Free Software Foundation; either version 2             *
8  * of the License, or (at your option) any later version.                     *
9  *                                                                            *
10  * This program is distributed in the hope that it will be useful,            *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
13  * GNU General Public License for more details.                               *
14  *                                                                            *
15  * You should have received a copy of the GNU General Public License          *
16  * along with this program; if not, write to the Free Software Foundation     *
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
18  ******************************************************************************/
19
20 #include "base/debuginfo.hpp"
21 #include "base/configtype.hpp"
22
23 library base;
24
25 namespace icinga
26 {
27
28 code {{{
29 enum HAMode
30 {
31         HARunOnce,
32         HARunEverywhere
33 };
34
35 class NameComposer
36 {
37 public:
38         virtual ~NameComposer();
39
40         virtual String MakeName(const String& shortName, const Object::Ptr& context) const = 0;
41         virtual Dictionary::Ptr ParseName(const String& name) const = 0;
42 };
43 }}}
44
45 abstract class ConfigObjectBase
46 { };
47
48 code {{{
49 class ConfigObjectBase : public ObjectImpl<ConfigObjectBase>
50 {
51 public:
52         inline DebugInfo GetDebugInfo() const
53         {
54                 return m_DebugInfo;
55         }
56
57         void SetDebugInfo(const DebugInfo& di)
58         {
59                 m_DebugInfo = di;
60         }
61
62         inline virtual void Start(bool /* runtimeCreated */)
63         { }
64
65         inline virtual void Stop(bool /* runtimeRemoved */)
66         { }
67
68 private:
69         DebugInfo m_DebugInfo;
70 };
71
72 }}}
73
74 abstract class ConfigObject : ConfigObjectBase < ConfigType
75 {
76         [config, no_user_modify] String __name (Name);
77         [config, no_user_modify] String "name" (ShortName) {
78                 get {{{
79                         if (m_ShortName.IsEmpty())
80                                 return GetName();
81                         else
82                                 return m_ShortName;
83                 }}}
84         };
85         [config, no_user_modify] name(Zone) zone (ZoneName);
86         [config, no_user_modify] String package;
87         [config, get_protected, no_user_modify] Array::Ptr templates;
88         [config, no_storage, no_user_modify] Dictionary::Ptr source_location {
89                 get;
90         };
91         [get_protected, no_user_modify] bool active;
92         [get_protected, no_user_modify] bool paused {
93                 default {{{ return true; }}}
94         };
95         [get_protected, no_user_view, no_user_modify] bool start_called;
96         [get_protected, no_user_view, no_user_modify] bool stop_called;
97         [get_protected, no_user_view, no_user_modify] bool pause_called;
98         [get_protected, no_user_view, no_user_modify] bool resume_called;
99         [enum] HAMode ha_mode (HAMode);
100         [protected, no_user_view, no_user_modify] Dictionary::Ptr extensions;
101
102         [protected, no_user_view, no_user_modify] bool state_loaded;
103         [no_user_modify] Dictionary::Ptr original_attributes;
104         [state, no_user_modify] double version {
105                 default {{{ return 0; }}}
106         };
107 };
108
109 }