Table of Contents

include/AK/SoundEngine/Common/AkBytesCount.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
00003 released in source code form as part of the SDK installer package.
00004 
00005 Commercial License Usage
00006 
00007 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
00008 may use this file in accordance with the end user license agreement provided 
00009 with the software or, alternatively, in accordance with the terms contained in a
00010 written agreement between you and Audiokinetic Inc.
00011 
00012 Apache License Usage
00013 
00014 Alternatively, this file may be used under the Apache License, Version 2.0 (the 
00015 "Apache License"); you may not use this file except in compliance with the 
00016 Apache License. You may obtain a copy of the Apache License at 
00017 http://www.apache.org/licenses/LICENSE-2.0.
00018 
00019 Unless required by applicable law or agreed to in writing, software distributed
00020 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
00021 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
00022 the specific language governing permissions and limitations under the License.
00023 
00024   Version: <VERSION>  Build: <BUILDNUMBER>
00025   Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
00026 *******************************************************************************/
00027 
00028 // AkBytesCount.h
00029 
00030 /// \file 
00031 /// IReadBytes / IWriteBytes implementation on a growing memory buffer. This
00032 /// version uses the AK::MemoryMgr memory pools.
00033 
00034 #pragma once
00035 
00036 #include <AK/IBytes.h>
00037 #include <AK/SoundEngine/Common/AkSoundEngineExport.h>
00038 #include <AK/Tools/Common/AkBankReadHelpers.h>
00039 
00040 namespace AK
00041 {
00042     class ReadBytesSkip
00043         : public AK::IReadBytes
00044     {
00045     public:
00046 
00047         AKSOUNDENGINE_API ReadBytesSkip();
00048         AKSOUNDENGINE_API ReadBytesSkip(
00049             const void * in_pBytes, 
00050             AkInt32 in_cBytes
00051             );
00052         AKSOUNDENGINE_API virtual ~ReadBytesSkip();
00053 
00054         // IReadBytes implementation
00055 
00056         AKSOUNDENGINE_API virtual bool ReadBytes(
00057             void * in_pData, 
00058             AkInt32 in_cBytes, 
00059             AkInt32 & out_cRead
00060             );
00061 
00062         // Public methods
00063 
00064         AKSOUNDENGINE_API void Attach(
00065             const void * in_pBytes, 
00066             AkInt32 in_cBytes
00067             );
00068 
00069         AKSOUNDENGINE_API AkInt32 Count();
00070 
00071     private:
00072         AkInt32   m_cBytes;
00073         const AkUInt8 * m_pBytes;
00074         AkInt32   m_cPos;
00075     };
00076 
00077     class WriteBytesCount
00078         : public AK::IWriteBuffer
00079     {
00080     public:
00081     
00082         AKSOUNDENGINE_API WriteBytesCount();
00083         AKSOUNDENGINE_API virtual ~WriteBytesCount();
00084     
00085         // IWriteBytes implementation
00086 
00087         AKSOUNDENGINE_API virtual bool WriteBytes(
00088             const void * in_pData, 
00089             AkInt32 in_cBytes, 
00090             AkInt32& out_cWritten);
00091     
00092         // IWriteBuffer implementation
00093 
00094         AKSOUNDENGINE_API virtual bool Reserve(
00095             AkInt32 in_cBytes
00096             );
00097 
00098         AKSOUNDENGINE_API virtual AkInt32 Count() const;
00099 
00100         AKSOUNDENGINE_API virtual void SetCount(
00101             AkInt32 in_cBytes
00102             );
00103 
00104         AKSOUNDENGINE_API virtual AkUInt8 * Bytes() const;
00105 
00106         AKSOUNDENGINE_API virtual AkUInt8 * Detach();
00107     
00108         AKSOUNDENGINE_API virtual void Clear();
00109     
00110         // Public methods
00111 
00112         AKSOUNDENGINE_API void SetMemPool( AkMemPoolId in_pool );
00113 
00114         template<class T>
00115         bool Write(const T & in_data)
00116         {
00117             m_cPos += sizeof(T);
00118             return true;
00119         }
00120     
00121     private:
00122         bool Grow(
00123             AkInt32 in_cBytes
00124         );
00125     
00126         AkInt32 m_cPos;
00127     };
00128 }