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