1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     io_IOStream.cpp
4 
5   Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Revision: 13145 $
14  *---------------------------------------------------------------------------*/
15 
16 #include "precompiled.h"
17 
18 #include <nw/io/io_IOStream.h>
19 
20 #include <nw/types.h>
21 #include <nw/assert.h>
22 #include <nw/ut/ut_RuntimeTypeInfo.h>
23 
24 
25 namespace nw {
26 namespace io   {
27 
28 NW_UT_RUNTIME_TYPEINFO_ROOT_DEFINITION( IOStream );
29 
30 
31 s32
Read(void *,u32)32 IOStream::Read(void* /*buf*/, u32 /*length*/)
33 {
34     NW_ASSERTMSG( CanRead(), "Stream don't support READ function\n" );
35     return 0;
36 }
37 
38 
39 bool
ReadAsync(void *,u32,IOStreamCallback,void *)40 IOStream::ReadAsync(
41         void* /*buf*/,
42         u32 /*length*/,
43         IOStreamCallback /*callback*/,
44         void* /*arg*/)
45 {
46     NW_ASSERTMSG( CanRead(), "Stream don't support READ function\n" );
47     NW_ASSERTMSG( CanAsync(), "Stream don't support ASYNC function\n" );
48     return false;
49 }
50 
51 
52 s32
Write(const void *,u32)53 IOStream::Write(const void* /*buf*/, u32 /*length*/)
54 {
55     NW_ASSERTMSG( CanWrite(), "Stream don't support WRITE function\n" );
56     return 0;
57 }
58 
59 
60 bool
WriteAsync(const void *,u32,IOStreamCallback,void *)61 IOStream::WriteAsync(
62         const void* /*buf*/,
63         u32 /*length*/,
64         IOStreamCallback /*callback*/,
65         void* /*arg*/)
66 {
67     NW_ASSERTMSG( CanWrite(), "Stream don't support WRITE function\n" );
68     NW_ASSERTMSG( CanAsync(), "Stream don't support ASYNC function\n" );
69     return false;
70 }
71 
72 s32
WaitAsync() const73 IOStream::WaitAsync() const
74 {
75     NW_ASSERTMSG( CanAsync(), "Stream don't support ASYNC function\n" );
76 
77     while ( IsBusy() ) {}
78     return mAsyncResult;
79 }
80 
81 bool
IsBusy() const82 IOStream::IsBusy() const
83 {
84     NW_ASSERTMSG( CanAsync(), "Stream don't support ASYNC function\n" );
85     return false;
86 }
87 
88 
89 }   /* namespace io */
90 }   /* namespace nw */
91 
92