CTextFileLogStreamerComp.h
Go to the documentation of this file.
1 #ifndef ifile_CTextFileLogStreamerComp_included
2 #define ifile_CTextFileLogStreamerComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QFile>
7 #include <QtCore/QTextStream>
8 
9 // ACF includes
10 #include <ifile/IFileNameParam.h>
11 #include <ifile/IFilePersistence.h>
13 
14 
15 namespace ifile
16 {
17 
18 
25 {
26 public:
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)
37  virtual bool IsOperationSupported(
38  const istd::IChangeable* dataObjectPtr,
39  const QString* filePathPtr = NULL,
40  int flags = -1,
41  bool beQuiet = true) const;
42  virtual int LoadFromFile(
43  istd::IChangeable& data,
44  const QString& filePath = QString(),
45  ibase::IProgressManager* progressManagerPtr = NULL) const;
46  virtual int SaveToFile(
47  const istd::IChangeable& data,
48  const QString& filePath = QString(),
49  ibase::IProgressManager* progressManagerPtr = NULL) const;
50 
51  // reimplemented (ifile::IFileTypeInfo)
52  virtual bool GetFileExtensions(QStringList& result, const istd::IChangeable* dataObjectPtr = NULL, int flags = -1, bool doAppend = false) const;
53  virtual QString GetTypeDescription(const QString* extensionPtr = NULL) const;
54 
55 protected:
56  // reimplemented (CStreamLogCompBase)
57  virtual void WriteText(const QString& text, istd::IInformationProvider::InformationCategory category);
58 
59  // reimplemented (icomp::CComponentBase)
60  virtual void OnComponentCreated();
61  virtual void OnComponentDestroyed();
62 
63 private:
64  bool OpenFileStream(const QString& filePath);
65  void CloseFileStream();
66 
67 private:
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 
78 #endif // !ifile_CTextFileLogStreamerComp_included
79 
80 
virtual int SaveToFile(const istd::IChangeable &data, const QString &filePath=QString(), ibase::IProgressManager *progressManagerPtr=NULL) const
This function saves data data to file filePath.
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
Basic implementation for a log written to an output stream.
virtual void WriteText(const QString &text, istd::IInformationProvider::InformationCategory category)
Write a text line to the output stream.
InformationCategory
Category of information.
#define NULL
Definition: istd.h:64
virtual QString GetTypeDescription(const QString *extensionPtr=NULL) const
Get description of object type associated with single extension.
virtual int LoadFromFile(istd::IChangeable &data, const QString &filePath=QString(), ibase::IProgressManager *progressManagerPtr=NULL) const
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
Get file extensions supported by this loader.
Message container displaying messages as log list.
Interface providing loading and saving of data objects.
virtual bool IsOperationSupported(const istd::IChangeable *dataObjectPtr, const QString *filePathPtr=NULL, int flags=-1, bool beQuiet=true) const
Returns true if object dataObject can be loaded/saved.
Consume information about progress of some process.

© 2007-2017 Witold Gantzke and Kirill Lepskiy