icinga2/lib/config/configitembuilder.hpp

59 lines
1.6 KiB
C++
Raw Normal View History

/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2012-07-06 14:33:10 +02:00
#ifndef CONFIGITEMBUILDER_H
#define CONFIGITEMBUILDER_H
2014-10-16 17:44:06 +02:00
#include "config/expression.hpp"
2014-05-25 16:23:35 +02:00
#include "config/configitem.hpp"
#include "base/debuginfo.hpp"
2014-05-25 16:23:35 +02:00
#include "base/object.hpp"
2013-03-17 20:19:29 +01:00
2012-07-06 14:33:10 +02:00
namespace icinga
{
2012-09-17 14:47:43 +02:00
/**
* Config item builder. Used to dynamically build configuration objects
* at runtime.
*
* @ingroup config
*/
class ConfigItemBuilder final
2012-07-06 14:33:10 +02:00
{
public:
2014-11-07 12:32:25 +01:00
DECLARE_PTR_TYPEDEFS(ConfigItemBuilder);
2012-07-06 14:33:10 +02:00
ConfigItemBuilder() = default;
2013-03-14 23:52:52 +01:00
explicit ConfigItemBuilder(const DebugInfo& debugInfo);
2012-07-06 14:33:10 +02:00
void SetType(const Type::Ptr& type);
void SetName(const String& name);
2012-07-06 14:33:10 +02:00
void SetAbstract(bool abstract);
void SetScope(const Dictionary::Ptr& scope);
void SetZone(const String& zone);
void SetPackage(const String& package);
void SetDefaultTemplate(bool defaultTmpl);
void SetIgnoreOnError(bool ignoreOnError);
2012-07-06 14:33:10 +02:00
2014-11-09 19:48:28 +01:00
void AddExpression(Expression *expr);
void SetFilter(const Expression::Ptr& filter);
2012-07-06 14:33:10 +02:00
ConfigItem::Ptr Compile();
2012-07-06 14:33:10 +02:00
private:
Type::Ptr m_Type; /**< The object type. */
2012-09-19 12:32:39 +02:00
String m_Name; /**< The name. */
bool m_Abstract{false}; /**< Whether the item is abstract. */
std::vector<std::unique_ptr<Expression> > m_Expressions; /**< Expressions for this item. */
Expression::Ptr m_Filter; /**< Filter expression. */
2012-09-19 12:32:39 +02:00
DebugInfo m_DebugInfo; /**< Debug information. */
Dictionary::Ptr m_Scope; /**< variable scope. */
String m_Zone; /**< The zone. */
String m_Package; /**< The package name. */
bool m_DefaultTmpl{false};
bool m_IgnoreOnError{false}; /**< Whether the object should be ignored when an error occurs in one of the expressions. */
2012-07-06 14:33:10 +02:00
};
}
#endif /* CONFIGITEMBUILDER */