ICF 3.1.1.10
Technical documentation of ICF Libraries
CTextFileLogComp.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#pragma once
7
8
9// Qt includes
10#include <QtCore/QFile>
11#include <QtCore/QReadWriteLock>
12#include <QtCore/QTextStream>
13
14// ICF includes
15#include <imod/IModel.h>
19
20
21namespace ifile
22{
23
24
31{
32public:
34
35 I_BEGIN_COMPONENT(CTextFileLogComp);
36 I_ASSIGN(m_fileNameCompPtr, "LogFile", "Name of the log file", true, "LogFile");
37 I_ASSIGN_TO(m_fileNameModelCompPtr, m_fileNameCompPtr, true);
38 I_ASSIGN(m_isAppendAttrPtr, "AppendToExisting", "Don't overwrite existing log file", true, false);
39 I_END_COMPONENT;
40
42
43protected:
44 // reimplemented (CStreamLogCompBase)
45 void WriteText(const QString& text, istd::IInformationProvider::InformationCategory category) override;
46
47 // reimplemented (icomp::CComponentBase)
48 void OnComponentCreated() override;
49 void OnComponentDestroyed() override;
50
51private:
52 void OpenFileStream();
53 void CloseFileStream();
54
55private:
56 I_REF(ifile::IFileNameParam, m_fileNameCompPtr);
57 I_REF(imod::IModel, m_fileNameModelCompPtr);
58 I_ATTR(bool, m_isAppendAttrPtr);
59
60 QFile m_outputFile;
61 QTextStream m_outputFileStream;
62
63 class FilePathObserver: public imod::CSingleModelObserverBase
64 {
65 public:
67
68 explicit FilePathObserver(CTextFileLogComp& parent);
69
70 protected:
71 // reimplemented (imod::CSingleModelObserverBase)
72 void OnUpdate(const istd::IChangeable::ChangeSet& changeSet) override;
73
74 private:
75 CTextFileLogComp& m_parent;
76 };
77
78 FilePathObserver m_filePathObserver;
79
80 QReadWriteLock m_mutex;
81};
82
83
84} // namespace ifile
85
86
Message container displaying messages as log list.
void OnComponentCreated() override
void OnComponentDestroyed() override
void WriteText(const QString &text, istd::IInformationProvider::InformationCategory category) override
Write a text line to the output stream.
ilog::CStreamLogCompBase BaseClass
Common interface for any file system item name (e.g directory, file or URL path)
Basic implementation for a log written to an output stream.
Basic implementation for a single model observer.
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:29
Set of change flags (its IDs).
Definition IChangeable.h:38
InformationCategory
Category of information.
Contains interfaces and implementations of file system related components.

© Witold Gantzke and Kirill Lepskiy