True Axis Physics SDK 1.2.0.1 Beta Documentation
www.trueaxis.com

IOStream.h

00001 //---------------------------------------------------------------------------------
00002 // File Name: IOStream.h
00003 // Description:
00004 //
00005 // Copyright (C) 2004 - 2006 True Axis Pty Ltd, Australia. 
00006 // All Rights Reserved.
00007 //
00008 // History:
00009 //      Created File.
00010 //---------------------------------------------------------------------------------
00011 
00012 #ifndef TA_IOSTREAM_H
00013 #define TA_IOSTREAM_H
00014 
00015 #ifndef TA_STRING_H
00016 #include "String.h"
00017 #endif // TA_STRING_H
00018 
00019 namespace TA
00020 {
00021 
00022 class TACOMMON_CLASS IOStream
00023 {
00024 public:
00025     virtual ~IOStream() {}
00026     virtual bool IsInput() = 0;
00027     virtual bool IsOutput() = 0;    
00028     virtual void StreamData(void* pData, int nSize) = 0;
00029 private:
00030 
00031 };
00032 
00033 class TACOMMON_CLASS IOStreamOutput : public IOStream
00034 {
00035 public:
00036     bool IsInput() { return false; }
00037     bool IsOutput() { return true; }
00038     virtual void StreamData(void* pData, int nSize) = 0;
00039     virtual void WriteData(const void* pData, int nSize) { StreamData((void*)pData, nSize); }
00040 
00041 private:
00042 };
00043 
00044 class TACOMMON_CLASS IOStreamOutputFile : public IOStreamOutput
00045 {
00046 public:
00047     IOStreamOutputFile();
00048     ~IOStreamOutputFile();
00049 
00050     bool Initialise(const Char* szFileName);
00051     void Finalise();
00052 
00053     void StreamData(void* pData, int nSize);
00054 
00055 private:
00056     uSize m_nFileHandle;
00057     String m_strName;
00058 };
00059 
00060 class TACOMMON_CLASS IOStreamOutputMemory : public IOStreamOutput
00061 {
00062 public:
00063     IOStreamOutputMemory();
00064     ~IOStreamOutputMemory();
00065 
00066     void Initialise(void* pData, int nSize);
00067     void Finalise();
00068 
00069     void StreamData(void* pData, int nSize);
00070 
00071     bool OverFlowed() const { return m_nPos > m_nSize; }
00072 
00073 private:
00074     u8* m_pu8Data;
00075     int m_nPos;
00076     int m_nSize;
00077 };
00078 
00079 class TACOMMON_CLASS IOStreamInput : public IOStream
00080 {
00081 public:
00082     bool IsInput() { return true; }
00083     bool IsOutput() { return false; }
00084     virtual int GetPos() = 0;
00085     virtual int GetSize() = 0;
00086 
00087 private:
00088 };
00089 
00090 class TACOMMON_CLASS IOStreamInputFile : public IOStreamInput
00091 {
00092 public:
00093     IOStreamInputFile();
00094     ~IOStreamInputFile();
00095 
00096     bool Initialise(const Char* szFileName);
00097     void Finalise();
00098 
00099     void StreamData(void* pData, int nSize);
00100 
00101     int GetPos();
00102     int GetSize();
00103 
00104 private:
00105     uSize m_nFileHandle;
00106     String m_strName;
00107 };
00108 
00109 class TACOMMON_CLASS IOStreamInputMemory : public IOStreamInput
00110 {
00111 public:
00112     IOStreamInputMemory();
00113     ~IOStreamInputMemory();
00114 
00115     void Initialise(void* pData, int nSize);
00116     void Finalise();
00117 
00118     void StreamData(void* pData, int nSize);
00119 
00120     int GetPos() { return m_nPos; }
00121     int GetSize() { return m_nSize; }
00122 
00123     bool OverFlowed() const { return m_nPos > m_nSize; }
00124 
00125 private:
00126     u8* m_pu8Data;
00127     int m_nPos;
00128     int m_nSize;
00129 };
00130 
00131 
00132 class TACOMMON_CLASS IOStreamCalculateSize : public IOStreamOutput
00133 {
00134 public:
00135     IOStreamCalculateSize();
00136     ~IOStreamCalculateSize();
00137 
00138     void Initialise();
00139     void Finalise();
00140 
00141     void StreamData(void* pData, int nSize);
00142 
00143     int GetSize() const { return m_nSize; }
00144 
00145 private:
00146     int m_nSize;
00147 };
00148 
00149 };
00150 
00151 #endif // TA_IOSTREAM_H


© Copyright 2004-2006 TRUE AXIS PTY LTD Australia. All rights reserved.