#include <Archive.h>
Collaboration diagram for Arxx::Archive:
The main purpose of Arxx::Archive is to handle input and output from and to ARX archives. But it also is responsible for the management of unique IDs and lets you access items you only know by ID.
In order to be able to manage input and output Arxx::Archive provides two functions: Arxx::Archive::bLoad() and Arxx::Archive::vSave().
Public Types | |
typedef std::map< Arxx::u4byte, Arxx::Item * >::size_type | size_type |
Public Member Functions | |
Archive (void) | |
The default constructor. | |
Archive (Arxx::ItemFactory &ItemFactory) | |
The default constructor with the ability to define an Item factory for this archive. | |
virtual | ~Archive (void) |
The destructor for a Arxx::Archive. | |
bool | bLoad (Arxx::URI URI) |
Load the content of an ARX archive into this Arxx::Archive. | |
bool | bMerge (Arxx::Archive &Archive, std::vector< Arxx::Rule * > &Rules) |
Merge the content of another Arxx::Archive into this Arxx::Archive. | |
void | vSave (Arxx::URI URI, bool bAutoCompress=false) |
Saves the content to an ARX archive. | |
void | vClose (void) |
Closes the Archive. | |
void | vRegisterItem (Arxx::Item &Item) |
Registers an Item to be a part of an Archive. | |
void | vUnregisterItem (Arxx::Item &Item) |
Unregisters an Item. | |
void | vSetRootItem (Item *pItem) |
Sets a root Item. | |
Arxx::ItemFactory * | pGetItemFactory (void) |
This function returns the m_pItemFactory member. | |
Arxx::Item * | pGetItem (Arxx::u4byte u4UniqueID) |
This function finds the Item associated with a given unique ID. | |
const Arxx::Item * | pGetItem (Arxx::u4byte u4UniqueID) const |
This function finds the Item associated with a given unique ID. | |
Arxx::Item * | pGetRootItem (void) |
Provides access to the root Item. | |
const Arxx::Item * | pGetRootItem (void) const |
Provides const access to the root Item. | |
Arxx::Reference | GetReference (Arxx::u4byte u4UniqueID) |
Returns a Arxx::Reference for a given unique ID. | |
Arxx::Archive::iterator | begin (void) |
Returns a Arxx::Archive::iterator to the first Item. | |
Arxx::Archive::iterator | end (void) |
Returns a Arxx::Archive::iterator behind the last Item. | |
Arxx::Archive::const_iterator | begin (void) const |
Returns a Arxx::Archive::const_iterator to the first Item. | |
Arxx::Archive::const_iterator | end (void) const |
Returns a Arxx::Archive::const_iterator behind the last Item. | |
Arxx::Archive::size_type | size (void) const |
Returns the number of Item objects. | |
Arxx::u4byte | u4GetNumberOfReferences (void) const |
Returns the number of resolved and unresolved references in the Archive. | |
void | vReleaseReference (Arxx::ReferenceImplementation *pReference) |
This function releases a Reference inside the Archive. | |
Private Member Functions | |
Archive (const Archive &Archive) | |
No copy semantic. | |
Archive & | operator= (const Archive &Archive) |
No assignment semantic. | |
void | vRead (Arxx::LocalArchiveChannel *pLocalArchiveChannel, Arxx::u4byte u4ItemCount) |
The reader function that retrieves Item header information from a channel. | |
Private Attributes | |
std::map< Arxx::u4byte, Arxx::Item * > | m_Items |
std::map< Arxx::u4byte, Arxx::Reference > | m_References |
Arxx::Item * | m_pRootItem |
Arxx::ItemFactory * | m_pItemFactory |
Classes | |
class | const_iterator |
An iterator class defining basic operations to iterate the Arxx::Item objects in an Arxx::Archive. More... | |
class | iterator |
An iterator class defining basic operations to iterate the Arxx::Item objects in an archive. More... |
typedef std::map< Arxx::u4byte, Arxx::Item * >::size_type Arxx::Archive::size_type |
Arxx::Archive::Archive | ( | void | ) |
The default constructor.
This constructor creates and initializes a Arxx::Archive. It will set the m_pItemFactory to the global default Item factory which is of type Arxx::DefaultItemFactory.
Arxx::Archive::Archive | ( | Arxx::ItemFactory & | ItemFactory | ) |
The default constructor with the ability to define an Item factory for this archive.
ItemFactory | A reference to the Item factory that should be used for this archive. |
Arxx::Archive::~Archive | ( | void | ) | [virtual] |
The destructor for a Arxx::Archive.
The destructor will call Arxx::Archive::vClose().
Arxx::Archive::Archive | ( | const Archive & | Archive | ) | [private] |
No copy semantic.
Arxx::Archive::const_iterator Arxx::Archive::begin | ( | void | ) | const |
Returns a Arxx::Archive::const_iterator to the first Item.
This function is provided so you can iterate through all the Item objects registered in a const Archive. It follows STL standards.
Arxx::Archive::iterator Arxx::Archive::begin | ( | void | ) |
Returns a Arxx::Archive::iterator to the first Item.
This function is provided so you can iterate through all the Item objects registered in an Archive. It follows STL standards.
bool Arxx::Archive::bLoad | ( | Arxx::URI | URI | ) |
Load the content of an ARX archive into this Arxx::Archive.
bool Arxx::Archive::bMerge | ( | Arxx::Archive & | Archive, | |
std::vector< Arxx::Rule * > & | Rules | |||
) |
Merge the content of another Arxx::Archive into this Arxx::Archive.
Archive | The other archive that is to be merge into this one. | |
Rules | A vector of Arxx::Rule objects which constitute the constraints for the merging process. |
Arxx::Archive::const_iterator Arxx::Archive::end | ( | void | ) | const |
Returns a Arxx::Archive::const_iterator behind the last Item.
This function is provided so you can iterate through all the Item objects registered in a const Archive. It follows STL standards.
Arxx::Archive::iterator Arxx::Archive::end | ( | void | ) |
Returns a Arxx::Archive::iterator behind the last Item.
This function is provided so you can iterate through all the Item objects registered in an Archive. It follows STL standards.
Arxx::Reference Arxx::Archive::GetReference | ( | Arxx::u4byte | u4UniqueID | ) |
Returns a Arxx::Reference for a given unique ID.
u4UniqueID | The unique ID which you will get a Arxx::Reference for. |
const Arxx::Item * Arxx::Archive::pGetItem | ( | Arxx::u4byte | u4UniqueID | ) | const |
Arxx::Item * Arxx::Archive::pGetItem | ( | Arxx::u4byte | u4UniqueID | ) |
Arxx::ItemFactory * Arxx::Archive::pGetItemFactory | ( | void | ) |
This function returns the m_pItemFactory member.
const Arxx::Item * Arxx::Archive::pGetRootItem | ( | void | ) | const |
Arxx::Item * Arxx::Archive::pGetRootItem | ( | void | ) |
Arxx::Archive::size_type Arxx::Archive::size | ( | void | ) | const |
Returns the number of Item objects.
This function returns the number of Arxx::Item objects registered in the Archive. It is designed to be STL compatible.
Arxx::u4byte Arxx::Archive::u4GetNumberOfReferences | ( | void | ) | const |
Returns the number of resolved and unresolved references in the Archive.
void Arxx::Archive::vClose | ( | void | ) |
Closes the Archive.
Closing an Archive means purging it of all Arxx::Item objects. All Item objects in the Archive will be deleted by their respective Arxx::ItemFactory objects. If an Item has no associated Arxx::ItemFactory set it won't get deleted since the Archive does not know how. In most cases this will be true for Items on the stack but may also be true for wrongly done ItemFactory derivates.
void Arxx::Archive::vRead | ( | Arxx::LocalArchiveChannel * | pLocalArchiveChannel, | |
Arxx::u4byte | u4ItemCount | |||
) | [private] |
The reader function that retrieves Item header information from a channel.
void Arxx::Archive::vRegisterItem | ( | Arxx::Item & | Item | ) |
Registers an Item to be a part of an Archive.
First of all this function will check whether the item is already assigned to an Archive and will throw an exception of type std::invalid_argument.
If the Item is not yet registered at another Archive, this function will set Arxx::Item::m_pArchive to point to this Archive.
If the Item is not yet associated to any Arxx::Archive this function will decide on one of the following behavior, depending on whether the unique ID of Item is equal to g_u4InvalidID or not.
void Arxx::Archive::vReleaseReference | ( | Arxx::ReferenceImplementation * | pReference | ) |
This function releases a Reference inside the Archive.
This is an internal function, but as the API user will never lay hands on a Arxx::ReferenceImplementation object it is still public to avoid friend declarations.
This function is called whenever the reference count of an unresolved Arxx::ReferenceImplementation object reaches `1`, because in that case the associated Archive object is the only reference holder of the ReferenceImplementation object. Since unresolved References serve no purpose other than to be resolved magically there is no sense in keeping it only inside the Archive.
This function will retrieve the associated Reference object and will remove it from the m_References map thus releasing the ReferenceImplementation object which then is deleted.
void Arxx::Archive::vSave | ( | Arxx::URI | URI, | |
bool | bAutoCompress = false | |||
) |
Saves the content to an ARX archive.
URI | The URI you want the ARX archive saved to. | |
bAutoCompress | Whether all Arxx::Item objects should be auto-compressed. |
Arxx::invalid_argument | If the given URI is non-valid. | |
Arxx::file_error | If the temporary archive in /tmp cannot be created for writing. |
void Arxx::Archive::vSetRootItem | ( | Item * | pItem | ) |
Sets a root Item.
pItem | A pointer to a Arxx::Item that is to be set as the Archive's root Item or 0. |
std::invalid_argument | If the Item that pItem points to is not registered in the Archive. |
You may pass pItem `0` to unset the root Item of the Archive.
void Arxx::Archive::vUnregisterItem | ( | Arxx::Item & | Item | ) |
Unregisters an Item.
This function will remove Item from an Archive by erasing the appropriate iterator from the Item object container owned by the Archive.
If Item is not correctly registered in the Archive an std::invalid_argument exception is thrown.
std::map< Arxx::u4byte, Arxx::Item * > Arxx::Archive::m_Items [private] |
Arxx::ItemFactory* Arxx::Archive::m_pItemFactory [private] |
Arxx::Item* Arxx::Archive::m_pRootItem [private] |
std::map< Arxx::u4byte, Arxx::Reference > Arxx::Archive::m_References [private] |