#ifndef OTLPMETRICSWRITER_TI
#define OTLPMETRICSWRITER_TI

#include "base/object.hpp"
#include "base/type.hpp"
#include "base/value.hpp"
#include "base/array.hpp"
#include "base/atomic.hpp"
#include "base/dictionary.hpp"
#include <boost/signals2.hpp>

#include "base/configobject.hpp"

namespace icinga
{

class OTLPMetricsWriter;

template<>
class TypeImpl<OTLPMetricsWriter> : public TypeImpl<ConfigObject>
{
public:
	DECLARE_PTR_TYPEDEFS(TypeImpl<OTLPMetricsWriter>);

	TypeImpl();
	~TypeImpl() override;

	String GetName() const override;
	int GetAttributes() const override;
	Type::Ptr GetBaseType() const override;
	int GetFieldId(const String& name) const override;
	Field GetFieldInfo(int id) const override;
	int GetFieldCount() const override;
	ObjectFactory GetFactory() const override;
	int GetActivationPriority() const override;
public:
	void RegisterAttributeHandler(int fieldId, const Type::AttributeHandler& callback) override;
};


template<>
class ObjectImpl<OTLPMetricsWriter> : public ConfigObject
{
public:
	DECLARE_PTR_TYPEDEFS(ObjectImpl<OTLPMetricsWriter>);

	void Validate(int types, const ValidationUtils& utils) override;
	void SimpleValidateHost(const Lazy<String>& value, const ValidationUtils& utils);
	void SimpleValidateMetricsEndpoint(const Lazy<String>& value, const ValidationUtils& utils);
	void SimpleValidateServiceNamespace(const Lazy<String>& value, const ValidationUtils& utils);
	void SimpleValidateTlsKeyFile(const Lazy<String>& value, const ValidationUtils& utils);
	void SimpleValidateTlsCertFile(const Lazy<String>& value, const ValidationUtils& utils);
	void SimpleValidateTlsCaFile(const Lazy<String>& value, const ValidationUtils& utils);
	void SimpleValidateBasicAuth(const Lazy<Dictionary::Ptr>& value, const ValidationUtils& utils);
	void SimpleValidateHostResourceAttributes(const Lazy<Dictionary::Ptr>& value, const ValidationUtils& utils);
	void SimpleValidateServiceResourceAttributes(const Lazy<Dictionary::Ptr>& value, const ValidationUtils& utils);
	void SimpleValidatePort(const Lazy<int>& value, const ValidationUtils& utils);
	void SimpleValidateDisconnectTimeout(const Lazy<int>& value, const ValidationUtils& utils);
	void SimpleValidateFlushInterval(const Lazy<int>& value, const ValidationUtils& utils);
	void SimpleValidateEnableHa(const Lazy<bool>& value, const ValidationUtils& utils);
	void SimpleValidateEnableSendThresholds(const Lazy<bool>& value, const ValidationUtils& utils);
	void SimpleValidateEnableTls(const Lazy<bool>& value, const ValidationUtils& utils);
	void SimpleValidateTlsInsecureNoverify(const Lazy<bool>& value, const ValidationUtils& utils);
	void SimpleValidateFlushThreshold(const Lazy<int64_t>& value, const ValidationUtils& utils);
public:
	ObjectImpl<OTLPMetricsWriter>();
public:
	~ObjectImpl<OTLPMetricsWriter>() override;
public:
	void SetField(int id, const Value& value, bool suppress_events = false, const Value& cookie = Empty) override;
public:
	Value GetField(int id) const override;
public:
	void ValidateField(int id, const Lazy<Value>& lvalue, const ValidationUtils& utils) override;
public:
	void NotifyField(int id, const Value& cookie = Empty) override;
public:
	Object::Ptr NavigateField(int id) const override;
public:
	String GetHost() const;
public:
	String GetMetricsEndpoint() const;
public:
	String GetServiceNamespace() const;
public:
	String GetTlsKeyFile() const;
public:
	String GetTlsCertFile() const;
public:
	String GetTlsCaFile() const;
public:
	Dictionary::Ptr GetBasicAuth() const;
public:
	Dictionary::Ptr GetHostResourceAttributes() const;
public:
	Dictionary::Ptr GetServiceResourceAttributes() const;
public:
	int GetPort() const;
public:
	int GetDisconnectTimeout() const;
public:
	int GetFlushInterval() const;
public:
	bool GetEnableHa() const;
public:
	bool GetEnableSendThresholds() const;
public:
	bool GetEnableTls() const;
public:
	bool GetTlsInsecureNoverify() const;
public:
	int64_t GetFlushThreshold() const;
public:
	void SetHost(const String& value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetMetricsEndpoint(const String& value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetServiceNamespace(const String& value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetTlsKeyFile(const String& value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetTlsCertFile(const String& value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetTlsCaFile(const String& value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetBasicAuth(const Dictionary::Ptr& value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetHostResourceAttributes(const Dictionary::Ptr& value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetServiceResourceAttributes(const Dictionary::Ptr& value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetPort(int value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetDisconnectTimeout(int value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetFlushInterval(int value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetEnableHa(bool value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetEnableSendThresholds(bool value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetEnableTls(bool value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetTlsInsecureNoverify(bool value, bool suppress_events = false, const Value& cookie = Empty);
public:
	void SetFlushThreshold(const int64_t& value, bool suppress_events = false, const Value& cookie = Empty);
protected:
public:
	virtual void NotifyHost(const Value& cookie = Empty);
public:
	virtual void NotifyMetricsEndpoint(const Value& cookie = Empty);
public:
	virtual void NotifyServiceNamespace(const Value& cookie = Empty);
public:
	virtual void NotifyTlsKeyFile(const Value& cookie = Empty);
public:
	virtual void NotifyTlsCertFile(const Value& cookie = Empty);
public:
	virtual void NotifyTlsCaFile(const Value& cookie = Empty);
public:
	virtual void NotifyBasicAuth(const Value& cookie = Empty);
public:
	virtual void NotifyHostResourceAttributes(const Value& cookie = Empty);
public:
	virtual void NotifyServiceResourceAttributes(const Value& cookie = Empty);
public:
	virtual void NotifyPort(const Value& cookie = Empty);
public:
	virtual void NotifyDisconnectTimeout(const Value& cookie = Empty);
public:
	virtual void NotifyFlushInterval(const Value& cookie = Empty);
public:
	virtual void NotifyEnableHa(const Value& cookie = Empty);
public:
	virtual void NotifyEnableSendThresholds(const Value& cookie = Empty);
public:
	virtual void NotifyEnableTls(const Value& cookie = Empty);
public:
	virtual void NotifyTlsInsecureNoverify(const Value& cookie = Empty);
public:
	virtual void NotifyFlushThreshold(const Value& cookie = Empty);
private:
	inline String GetDefaultHost() const;
private:
	inline String GetDefaultMetricsEndpoint() const;
private:
	inline String GetDefaultServiceNamespace() const;
private:
	inline String GetDefaultTlsKeyFile() const;
private:
	inline String GetDefaultTlsCertFile() const;
private:
	inline String GetDefaultTlsCaFile() const;
private:
	inline Dictionary::Ptr GetDefaultBasicAuth() const;
private:
	inline Dictionary::Ptr GetDefaultHostResourceAttributes() const;
private:
	inline Dictionary::Ptr GetDefaultServiceResourceAttributes() const;
private:
	inline int GetDefaultPort() const;
private:
	inline int GetDefaultDisconnectTimeout() const;
private:
	inline int GetDefaultFlushInterval() const;
private:
	inline bool GetDefaultEnableHa() const;
private:
	inline bool GetDefaultEnableSendThresholds() const;
private:
	inline bool GetDefaultEnableTls() const;
private:
	inline bool GetDefaultTlsInsecureNoverify() const;
private:
	inline int64_t GetDefaultFlushThreshold() const;
protected:
	virtual void ValidateHost(const Lazy<String>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateMetricsEndpoint(const Lazy<String>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateServiceNamespace(const Lazy<String>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateTlsKeyFile(const Lazy<String>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateTlsCertFile(const Lazy<String>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateTlsCaFile(const Lazy<String>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateBasicAuth(const Lazy<Dictionary::Ptr>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateHostResourceAttributes(const Lazy<Dictionary::Ptr>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateServiceResourceAttributes(const Lazy<Dictionary::Ptr>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidatePort(const Lazy<int>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateDisconnectTimeout(const Lazy<int>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateFlushInterval(const Lazy<int>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateEnableHa(const Lazy<bool>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateEnableSendThresholds(const Lazy<bool>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateEnableTls(const Lazy<bool>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateTlsInsecureNoverify(const Lazy<bool>& lvalue, const ValidationUtils& utils);
protected:
	virtual void ValidateFlushThreshold(const Lazy<int64_t>& lvalue, const ValidationUtils& utils);
private:
	AtomicOrLocked<String> m_Host;
	AtomicOrLocked<String> m_MetricsEndpoint;
	AtomicOrLocked<String> m_ServiceNamespace;
	AtomicOrLocked<String> m_TlsKeyFile;
	AtomicOrLocked<String> m_TlsCertFile;
	AtomicOrLocked<String> m_TlsCaFile;
	AtomicOrLocked<Dictionary::Ptr> m_BasicAuth;
	AtomicOrLocked<Dictionary::Ptr> m_HostResourceAttributes;
	AtomicOrLocked<Dictionary::Ptr> m_ServiceResourceAttributes;
	AtomicOrLocked<int> m_Port;
	AtomicOrLocked<int> m_DisconnectTimeout;
	AtomicOrLocked<int> m_FlushInterval;
	AtomicOrLocked<bool> m_EnableHa;
	AtomicOrLocked<bool> m_EnableSendThresholds;
	AtomicOrLocked<bool> m_EnableTls;
	AtomicOrLocked<bool> m_TlsInsecureNoverify;
	AtomicOrLocked<int64_t> m_FlushThreshold;
public:
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnHostChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnMetricsEndpointChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnServiceNamespaceChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnTlsKeyFileChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnTlsCertFileChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnTlsCaFileChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnBasicAuthChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnHostResourceAttributesChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnServiceResourceAttributesChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnPortChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnDisconnectTimeoutChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnFlushIntervalChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnEnableHaChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnEnableSendThresholdsChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnEnableTlsChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnTlsInsecureNoverifyChanged;
	static boost::signals2::signal<void (const intrusive_ptr<OTLPMetricsWriter>&, const Value&)> OnFlushThresholdChanged;
};

}
#endif /* OTLPMETRICSWRITER_TI */
