2026-01-27 09:06:40 -05:00
|
|
|
// SPDX-FileCopyrightText: 2012 Icinga GmbH <https://icinga.com>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2013-02-05 07:06:42 -05:00
|
|
|
|
|
|
|
|
#ifndef CONFIGCOMPILERCONTEXT_H
|
|
|
|
|
#define CONFIGCOMPILERCONTEXT_H
|
|
|
|
|
|
2014-05-25 10:23:35 -04:00
|
|
|
#include "config/i2-config.hpp"
|
2022-08-01 11:44:05 -04:00
|
|
|
#include "base/atomic-file.hpp"
|
2014-11-06 13:35:47 -05:00
|
|
|
#include "base/dictionary.hpp"
|
2016-08-20 17:46:44 -04:00
|
|
|
#include <fstream>
|
2022-08-01 11:44:05 -04:00
|
|
|
#include <memory>
|
2021-02-02 04:16:04 -05:00
|
|
|
#include <mutex>
|
2013-03-17 15:19:29 -04:00
|
|
|
|
2013-02-05 07:06:42 -05:00
|
|
|
namespace icinga
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @ingroup config
|
|
|
|
|
*/
|
2017-12-31 01:22:16 -05:00
|
|
|
class ConfigCompilerContext
|
2013-02-05 07:06:42 -05:00
|
|
|
{
|
|
|
|
|
public:
|
2014-11-06 13:35:47 -05:00
|
|
|
void OpenObjectsFile(const String& filename);
|
|
|
|
|
void WriteObject(const Dictionary::Ptr& object);
|
2018-01-03 22:25:35 -05:00
|
|
|
void CancelObjectsFile();
|
|
|
|
|
void FinishObjectsFile();
|
2014-11-06 13:35:47 -05:00
|
|
|
|
2022-11-21 06:37:07 -05:00
|
|
|
inline bool IsOpen() const noexcept
|
|
|
|
|
{
|
2022-08-01 11:44:05 -04:00
|
|
|
return (bool)m_ObjectsFP;
|
2022-11-21 06:37:07 -05:00
|
|
|
}
|
|
|
|
|
|
2018-01-03 22:25:35 -05:00
|
|
|
static ConfigCompilerContext *GetInstance();
|
2013-02-05 07:06:42 -05:00
|
|
|
|
|
|
|
|
private:
|
2022-08-01 11:44:05 -04:00
|
|
|
std::unique_ptr<AtomicFile> m_ObjectsFP;
|
2014-02-05 03:24:26 -05:00
|
|
|
|
2021-02-02 04:16:04 -05:00
|
|
|
mutable std::mutex m_Mutex;
|
2013-02-05 07:06:42 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* CONFIGCOMPILERCONTEXT_H */
|