00001 /* 00002 Copyright (C) 2005 The Pentagram team 00003 00004 This program is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU General Public License 00006 as published by the Free Software Foundation; either version 2 00007 of the License, or (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef ARCHIVE_H 00020 #define ARCHIVE_H 00021 00022 #include <vector> 00023 00024 class ArchiveFile; 00025 class IDataSource; 00026 00027 namespace Pentagram { 00028 00029 class Archive 00030 { 00031 public: 00032 ENABLE_RUNTIME_CLASSTYPE(); 00033 00035 Archive(); 00036 00038 explicit Archive(ArchiveFile* af); 00039 00042 explicit Archive(IDataSource* ids); 00043 00046 explicit Archive(const std::string& path); 00047 00048 virtual ~Archive(); 00049 00054 bool addSource(ArchiveFile* af); 00055 00057 bool addSource(IDataSource* ids); 00058 00060 bool addSource(const std::string& path); 00061 00062 00064 void cache(); 00065 00067 virtual void cache(uint32 index)=0; 00068 00072 void uncache(); 00073 00076 virtual void uncache(uint32 index)=0; 00077 00079 virtual bool isCached(uint32 index)=0; 00080 00081 uint32 getCount() const { return count; } 00082 00083 protected: 00084 uint32 count; 00085 00086 uint8* getRawObject(uint32 index, uint32* sizep=0); 00087 uint32 getRawSize(uint32 index); 00088 00089 private: 00090 std::vector<ArchiveFile*> sources; 00091 00092 ArchiveFile* findArchiveFile(uint32 index); 00093 }; 00094 00095 } 00096 00097 #endif