ACF $AcfVersion:0$
CTextFileLogStreamerComp.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/QFile>
7#include <QtCore/QTextStream>
8
9// ACF includes
13
14
15namespace ifile
16{
17
18
25{
26public:
28
29 I_BEGIN_COMPONENT(CTextFileLogStreamerComp);
30 I_REGISTER_INTERFACE(ifile::IFilePersistence);
31 I_ASSIGN(m_isAppendAttrPtr, "AppendToExisting", "Don't overwrite existing log file", true, false);
32 I_END_COMPONENT;
33
35
36 // reimplemented (ifile::IFilePersistence)
38 const istd::IChangeable* dataObjectPtr,
39 const QString* filePathPtr = NULL,
40 int flags = -1,
41 bool beQuiet = true) const override;
44 const QString& filePath = QString(),
45 ibase::IProgressManager* progressManagerPtr = NULL) const override;
47 const istd::IChangeable& data,
48 const QString& filePath = QString(),
49 ibase::IProgressManager* progressManagerPtr = NULL) const override;
50
51 // reimplemented (ifile::IFileTypeInfo)
52 virtual bool GetFileExtensions(QStringList& result, const istd::IChangeable* dataObjectPtr = NULL, int flags = -1, bool doAppend = false) const override;
53 virtual QString GetTypeDescription(const QString* extensionPtr = NULL) const override;
54
55protected:
56 // reimplemented (CStreamLogCompBase)
57 virtual void WriteText(const QString& text, istd::IInformationProvider::InformationCategory category) override;
58
59 // reimplemented (icomp::CComponentBase)
60 virtual void OnComponentCreated() override;
61 virtual void OnComponentDestroyed() override;
62
63private:
64 bool OpenFileStream(const QString& filePath);
65 void CloseFileStream();
66
67private:
68 I_ATTR(bool, m_isAppendAttrPtr);
69
70 mutable QFile m_outputFile;
71 mutable QTextStream m_outputFileStream;
72};
73
74
75} // namespace ifile
76
77
Consume information about progress of some process.
Message container displaying messages as log list.
virtual void OnComponentCreated() override
virtual QString GetTypeDescription(const QString *extensionPtr=NULL) const override
Get description of object type associated with single extension.
virtual ifile::IFilePersistence::OperationState LoadFromFile(istd::IChangeable &data, const QString &filePath=QString(), ibase::IProgressManager *progressManagerPtr=NULL) const override
This function loads data data from file filePath.
virtual bool GetFileExtensions(QStringList &result, const istd::IChangeable *dataObjectPtr=NULL, int flags=-1, bool doAppend=false) const override
Get file extensions supported by this loader.
virtual bool IsOperationSupported(const istd::IChangeable *dataObjectPtr, const QString *filePathPtr=NULL, int flags=-1, bool beQuiet=true) const override
Returns true if object dataObject can be loaded/saved.
virtual void OnComponentDestroyed() override
virtual void WriteText(const QString &text, istd::IInformationProvider::InformationCategory category) override
Write a text line to the output stream.
virtual ifile::IFilePersistence::OperationState SaveToFile(const istd::IChangeable &data, const QString &filePath=QString(), ibase::IProgressManager *progressManagerPtr=NULL) const override
This function saves data data to file filePath.
Interface providing loading and saving of data objects.
OperationState
Result of operation.
Base class for stream-based logging components.
Common interface for data model objects, which can be changed.
Definition IChangeable.h:28
InformationCategory
Category of information.
#define NULL
Definition istd.h:74
Contains interfaces and implementations of file system related components.