#ifndef DEBUG_READLOG_H_
#define DEBUG_READLOG_H_
/*---------------------------------------------------------------------------*/
/* debug_readlog.h                                                           */
/* copyright (c) innovaphone 2012                                            */
/*                                                                           */
/*---------------------------------------------------------------------------*/

NAMESPACE_BEGIN

class UDebugReadLog {
public:
    virtual void DebugReadLogAddFiles(class DebugReadLog * debugReadLog) = 0;
};

class IDebugReadLog : public ITask {
public:
    static class IDebugReadLog * Create(class UDebugReadLog * debugReadLogUser, class STaskContext * context, unsigned length, bool last, bool continuous);
    virtual ~IDebugReadLog() {};

    virtual void read(unsigned length, bool last) = 0;
    virtual unsigned getLength() = 0;
    virtual void getData(byte * buffer, unsigned length) = 0;
};

class DebugTaskFileRead : public TaskFileRead {
public:
    DebugTaskFileRead(class STaskContext * context, const char * workingPath, const char * fileName, unsigned length, bool last);
    ~DebugTaskFileRead();

    bool progress_pending;
};

class DebugReadLog : public IDebugReadLog, public UTask {

    void TaskComplete(class ITask * const task);
    void TaskFailed(class ITask * const task);
    void TaskProgress(class ITask * const task, dword progress);

    class UDebugReadLog * debugReadLogUser;
    class STaskContext * readContext;
    unsigned readLength;
    bool readLast;
    bool readContinuous;
    unsigned readCount;
    unsigned readAllocated;
    DebugTaskFileRead ** readList;

public:
    DebugReadLog(class UDebugReadLog * debugReadLogUser, class STaskContext * context, unsigned length, bool last, bool continuous);
    ~DebugReadLog();

    void Add(const char * workingPath, const char * fileName);
    void Start(class UTask * user);

    void read(unsigned length, bool last);
    unsigned getLength();
    void getData(byte * buffer, unsigned length);
};

NAMESPACE_END

/*---------------------------------------------------------------------------*/
#endif /* DEBUG_READLOG_H_ */
