summaryrefslogtreecommitdiff
path: root/include/nw4r/ut/ut_IOStream.h
blob: 835b41559b4f547c75416f08b24745d3a59a6ce4 (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
#ifndef NW4R_UT_IO_STREAM_H
#define NW4R_UT_IO_STREAM_H
#include "nw4r/types_nw4r.h"
#include "nw4r/ut/ut_RuntimeTypeInfo.h"

namespace nw4r {
namespace ut {

class IOStream {
public:
    NW4R_UT_RTTI_DECL(IOStream);

    typedef void StreamCallback(s32 result, IOStream *stream, void *arg);
    typedef void (*AsyncCallback)(s32 result, IOStream *stream, void *arg);

    IOStream() : mIsOpen(false), mCallback(NULL), mCallbackArg(NULL) {}
    virtual ~IOStream() {} // at 0xC

    virtual void Close() = 0;                  // at 0x10
    virtual s32 Read(void *dst, u32 size) = 0; // at 0x14
    virtual bool ReadAsync(void *dst, u32 size, AsyncCallback callback,
                           void *arg);            // at 0x18
    virtual s32 Write(const void *src, u32 size); // at 0x1C
    virtual bool WriteAsync(const void *src, u32 size, AsyncCallback callback,
                            void *arg); // at 0x20
    virtual bool IsBusy() const;        // at 0x24
    virtual bool CanAsync() const = 0;  // at 0x28
    virtual bool CanRead() const = 0;   // at 0x2C
    virtual bool CanWrite() const = 0;  // at 0x30
    virtual u32 GetOffsetAlign() const {
        return 1;
    } // at 0x34
    virtual u32 GetSizeAlign() const {
        return 1;
    } // at 0x38
    virtual u32 GetBufferAlign() const {
        return 1;
    } // at 0x3C

    bool IsAvailable() const {
        return mIsOpen;
    }

protected:
    bool mIsOpen;            // at 0x4
    s32 mResult;             // at 0x8
    AsyncCallback mCallback; // at 0xC
    void *mCallbackArg;      // at 0x10
};

} // namespace ut
} // namespace nw4r

#endif