BVB Source Codes

CRYENGINE Show ChunkFile.h Source code

Return Download CRYENGINE: download ChunkFile.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. //
  4. //      File:ChunkFile.h
  5. //  Declaration of class CChunkFile
  6. //
  7. //      History:
  8. //
  9. //////////////////////////////////////////////////////////////////////
  10. #ifndef _CHUNK_FILE_READER_HDR_
  11. #define _CHUNK_FILE_READER_HDR_
  12.  
  13. #include <Cry3DEngine/CGF/CryHeaders.h>
  14. #include <CryCore/smartptr.h>
  15. #include <Cry3DEngine/CGF/IChunkFile.h>
  16.  
  17. ////////////////////////////////////////////////////////////////////////
  18. // Chunk file reader.
  19. // Accesses a chunked file structure through file mapping object.
  20. // Opens a chunk file and checks for its validity.
  21. // If it's invalid, closes it as if there was no open operation.
  22. // Error handling is performed through the return value of Read():
  23. // it must be true for successfully open files
  24. ////////////////////////////////////////////////////////////////////////
  25.  
  26. class CChunkFile : public IChunkFile
  27. {
  28. public:
  29.         //////////////////////////////////////////////////////////////////////////
  30.         CChunkFile();
  31.         virtual ~CChunkFile();
  32.  
  33.         // interface IChunkFile --------------------------------------------------
  34.  
  35.         virtual void             Release() { delete this; }
  36.  
  37.         void                     Clear();
  38.  
  39.         virtual bool             IsReadOnly() const { return false; }
  40.         virtual bool             IsLoaded() const   { return m_bLoaded; }
  41.  
  42.         virtual bool             Read(const char* filename);
  43.         virtual bool             ReadFromMemory(const void* pData, int nDataSize) { return false; }
  44.  
  45.         virtual bool             Write(const char* filename);
  46.         virtual bool             WriteToMemoryBuffer(void** pData, int* nSize);
  47.         virtual void             ReleaseMemoryBuffer();
  48.  
  49.         virtual int              AddChunk(ChunkTypes chunkType, int chunkVersion, EEndianness eEndianness, const void* chunkData, int chunkSize);
  50.         virtual void             DeleteChunkById(int nChunkId);
  51.         virtual void             DeleteChunksByType(ChunkTypes nChunkType);
  52.  
  53.         virtual ChunkDesc*       FindChunkByType(ChunkTypes nChunkType);
  54.         virtual ChunkDesc*       FindChunkById(int nChunkId);
  55.  
  56.         virtual int              NumChunks() const;
  57.  
  58.         virtual ChunkDesc*       GetChunk(int nIndex);
  59.         virtual const ChunkDesc* GetChunk(int nIndex) const;
  60.  
  61.         virtual const char*      GetLastError() const { return m_LastError; }
  62.  
  63.         // -----------------------------------------------------------------------
  64.  
  65.         virtual void GetMemoryUsage(ICrySizer* pSizer) const
  66.         {
  67.                 pSizer->AddObject(this, sizeof(*this));
  68.                 pSizer->AddObject(m_LastError);
  69.                 pSizer->AddObject(m_chunks);
  70.                 pSizer->AddObject(m_chunkIdMap);
  71.         }
  72.  
  73. private:
  74.         void ReleaseChunks();
  75.  
  76. private:
  77.         // this variable contains the last error occurred in this class
  78.         string                  m_LastError;
  79.  
  80.         int                     m_nLastChunkId;
  81.         std::vector<ChunkDesc*> m_chunks;
  82.         typedef std::map<int, ChunkDesc*> ChunkIdMap;
  83.         ChunkIdMap              m_chunkIdMap;
  84.         char*                   m_pInternalData;
  85.         bool                    m_bLoaded;
  86. };
  87.  
  88. TYPEDEF_AUTOPTR(CChunkFile);
  89.  
  90. #endif
  91.  
downloadChunkFile.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top