summaryrefslogtreecommitdiffstats
path: root/src/logger.h
blob: 943f022e2dd6e86359dec8fadf3f7f8d7de8e234 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101


#ifndef LOGGER_H
#define LOGGER_H

#include <tqobject.h>
#include <tqstringlist.h>
#include <tqdatetime.h>
#include <tqfile.h>
#include <tqtextstream.h>


/**
 * @short An item for every process that is logged
 * @author Daniel Faust <hessijames@gmail.com>
 * @version 0.3
 */
class LoggerItem
{
public:
    /**
     * Constructor
     */
    LoggerItem();

    /**
     * Destructor
     */
    virtual ~LoggerItem();

    TQString filename;
    int id;
    TQStringList data;
    bool completed;
    int state; // 0 = ok, -1 = failed, 1 = other (soundKonverter)
    TQTime time;
    TQFile file;
    TQTextStream textStream;

};


/**
 * @short All data about the processes are collected here
 * @author Daniel Faust <hessijames@gmail.com>
 * @version 0.3
 */
class Logger : public TQObject
{
    Q_OBJECT
  
public:
    /**
     * Constructor
     */
    Logger();

    /**
     * Destructor
     */
    virtual ~Logger();

    void cleanUp();

    /**
     * Creates a new logger item and returns the id of it, @p filename is added to the new logger item
     */
    int registerProcess( const TQString& filename );

    /**
     * Adds the string @p data to the data of the logger item with id @p id
     */
    void log( int id, const TQString& data );

    /**
     * Returns the logger item with id @p id
     */
    LoggerItem* getLog( int id );

    /**
     * Returns a list of all logger items
     */
    TQValueList<LoggerItem*> getLogs();

private:
    /** the list of all logger items */
    TQValueList<LoggerItem*> processes;

    /** returns an unused random id */
    int getNewID();

public slots:
    void processCompleted( int id, int state );

signals:
    void removedProcess( int id );
    void updateProcess( int id );

};

#endif // LOGGER_H