00001
00020 #ifndef ARXX_ARCHIVE_H
00021 #define ARXX_ARCHIVE_H
00022
00023 #include <map>
00024 #include <vector>
00025
00026 #include "Common.h"
00027
00034 namespace Arxx
00035 {
00036 class Item;
00037
00038 class ItemFactory;
00039
00040 class LocalArchiveChannel;
00041
00042 class Reference;
00043
00044 class ReferenceImplementation;
00045
00046 class Rule;
00047
00048 class URI;
00049
00057 class Archive
00058 {
00059 public:
00065 class iterator
00066 {
00067 public:
00074 iterator(std::map< Arxx::u4byte, Arxx::Item * >::iterator iItem);
00075
00079 ~iterator(void);
00080
00086 iterator & operator++(void);
00087
00093 Arxx::Item & operator*(void);
00094
00100 const Arxx::Item & operator*(void) const;
00101
00105 Arxx::Item * operator->(void);
00106
00111 bool operator==(const Arxx::Archive::iterator & iItem) const;
00112
00117 bool operator!=(const Arxx::Archive::iterator & iItem) const;
00118 private:
00124 std::map< Arxx::u4byte, Arxx::Item * >::iterator m_iItem;
00125 };
00126
00132 class const_iterator
00133 {
00134 public:
00141 const_iterator(std::map< Arxx::u4byte, Arxx::Item * >::const_iterator iItem);
00142
00146 ~const_iterator(void);
00147
00153 const_iterator & operator++(void);
00154
00160 const Arxx::Item & operator*(void) const;
00161
00165 const Arxx::Item * operator->(void) const;
00166
00171 bool operator==(const Arxx::Archive::const_iterator & iItem) const;
00172
00177 bool operator!=(const Arxx::Archive::const_iterator & iItem) const;
00178 private:
00184 std::map< Arxx::u4byte, Arxx::Item * >::const_iterator m_iItem;
00185 };
00186
00187 typedef std::map< Arxx::u4byte, Arxx::Item * >::size_type size_type;
00188
00194 Archive(void);
00195
00202 Archive(Arxx::ItemFactory & ItemFactory);
00203
00209 virtual ~Archive(void);
00210
00222 bool bLoad(Arxx::URI URI);
00223
00233 bool bMerge(Arxx::Archive & Archive, std::vector< Arxx::Rule * > & Rules);
00234
00244 void vSave(Arxx::URI URI, bool bAutoCompress = false);
00245
00253 void vClose(void);
00254
00268 void vRegisterItem(Arxx::Item & Item);
00269
00281 void vUnregisterItem(Arxx::Item & Item);
00282
00292 void vSetRootItem(Item * pItem);
00293
00297 Arxx::ItemFactory * pGetItemFactory(void);
00298
00307 Arxx::Item * pGetItem(Arxx::u4byte u4UniqueID);
00308
00317 const Arxx::Item * pGetItem(Arxx::u4byte u4UniqueID) const;
00318
00324 Arxx::Item * pGetRootItem(void);
00325
00331 const Arxx::Item * pGetRootItem(void) const;
00332
00339 Arxx::Reference GetReference(Arxx::u4byte u4UniqueID);
00340
00346 Arxx::Archive::iterator begin(void);
00347
00353 Arxx::Archive::iterator end(void);
00354
00360 Arxx::Archive::const_iterator begin(void) const;
00361
00367 Arxx::Archive::const_iterator end(void) const;
00368
00374 Arxx::Archive::size_type size(void) const;
00375
00379 Arxx::u4byte u4GetNumberOfReferences(void) const;
00380
00390 void vReleaseReference(Arxx::ReferenceImplementation * pReference);
00391 private:
00395 Archive(const Archive & Archive);
00396
00400 Archive & operator=(const Archive & Archive);
00401
00405 void vRead(Arxx::LocalArchiveChannel * pLocalArchiveChannel, Arxx::u4byte u4ItemCount);
00406
00407 std::map< Arxx::u4byte, Arxx::Item * > m_Items;
00408 std::map< Arxx::u4byte, Arxx::Reference > m_References;
00409 Arxx::Item * m_pRootItem;
00410 Arxx::ItemFactory * m_pItemFactory;
00411 };
00412 }
00413
00414 #endif