1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #ifndef CONFIGFRAGMENT_H
4 #define CONFIGFRAGMENT_H
6 #include "config/configcompiler.hpp"
7 #include "base/initialize.hpp"
8 #include "base/debug.hpp"
9 #include "base/exception.hpp"
10 #include "base/application.hpp"
12 /* Ensure that the priority is lower than the basic namespace initialization in scriptframe.cpp. */
13 #define REGISTER_CONFIG_FRAGMENT(name, fragment) \
14 INITIALIZE_ONCE_WITH_PRIORITY([]() { \
15 std::unique_ptr<icinga::Expression> expression = icinga::ConfigCompiler::CompileText(name, fragment); \
18 icinga::ScriptFrame frame(true); \
19 expression->Evaluate(frame); \
20 } catch (const std::exception& ex) { \
21 std::cerr << icinga::DiagnosticInformation(ex) << std::endl; \
22 icinga::Application::Exit(1); \
26 #endif /* CONFIGFRAGMENT_H */