Arxx::Structure Class Reference

#include <Structure.h>

Collaboration diagram for Arxx::Structure:

Collaboration graph
[legend]
List of all members.

Detailed Description

The structure of a ARX archive is saved inside these objects.

This Structure class provides a general but standarized way to structure the items in an archive.


Public Types

typedef std::map< std::string,
Arxx::Structure::Relation
>::size_type 
size_type

Public Member Functions

 Structure (Arxx::Item &Item)
 This constructor binds the structure to a specific Arxx::Item.
bool bAdd (Arxx::u4byte u4UniqueID, const std::string &sRelation="child")
 Adds an unresolved item reference to a relation.
bool bDelete (Arxx::u4byte u4UniqueID, const std::string &sRelation="child")
 Deletes an unresolved item reference from a relation.
const Arxx::Structure::RelationGetRelation (const std::string &sRelation) const
 The const accessor for constant relations.
Arxx::Structure::RelationGetRelation (const std::string &sRelation)
 The accessor for relations.
bool bHasRelation (const std::string &sRelation) const
 Query whether a paricular relation exists.
size_type size (void) const
 Returns the number of Relations in the Structure.
Arxx::Structure::iterator begin (void)
 Returns the first Relation iterator of the Structure.
Arxx::Structure::iterator end (void)
 Returns the end Relation iterator of the Structure.
Arxx::Structure::const_iterator begin (void) const
 Returns the first const Relation iterator of the Structure.
Arxx::Structure::const_iterator end (void) const
 Returns the end const Relation iterator of the Structure.

Private Member Functions

void vWriteToBuffer (Arxx::Buffer &Buffer) const
 Writes the Structure information to a Buffer.
void vReadFromStream (Arxx::u4byte u4StructureDataLength, std::istream &IStream)
void vRemoveRelation (Arxx::Structure::Relation *pRelation)

Private Attributes

Arxx::Itemm_Item
std::map< std::string, Arxx::Structure::Relationm_Relations

Friends

class Arxx::Archive
class Arxx::Structure::Relation
Arxx::Bufferoperator<< (Arxx::Buffer &Buffer, const Arxx::Structure &Structure)
 Convenience function that streams the structural information into a Arxx::Buffer.

Classes

class  const_iterator
 An iterator class defining basic operations to iterate the Relation objects in a Structure. More...
class  iterator
 An iterator class defining basic operations to iterate the Relation objects in a Structure. More...
class  Relation
 The object that holds references to other items. More...


Member Typedef Documentation

typedef std::map< std::string, Arxx::Structure::Relation >::size_type Arxx::Structure::size_type


Constructor & Destructor Documentation

Arxx::Structure::Structure ( Arxx::Item Item  ) 

This constructor binds the structure to a specific Arxx::Item.

Parameters:
Item The Arxx::Item that this structure is linked to.


Member Function Documentation

bool Arxx::Structure::bAdd ( Arxx::u4byte  u4UniqueID,
const std::string &  sRelation = "child" 
)

Adds an unresolved item reference to a relation.

Parameters:
sRelation The relation that is changed with this call.
u4UniqueID A unique ID that is to be added to the relation.
Returns:
A boolean value indicating whether the operation has been performed successfully.
This function will add the unique ID u4UniqueID to the relation identified by sRelation.

There are two things to consider:

Violating one of these conditions will abort the call and return without having done anything.

This function will create the relation if it does not exist yet and the unresolved reference with the unique ID u4UniqueID will be the only member of this new relation.

bool Arxx::Structure::bDelete ( Arxx::u4byte  u4UniqueID,
const std::string &  sRelation = "child" 
)

Deletes an unresolved item reference from a relation.

Parameters:
sRelation The relation that is changed with this call.
u4UniqueID The unique item id that is tried to be deleted from the relation.
Returns:
A boolean value indicating whether the operation has been performed successfully.
This function will delete the unresolved item reference referring to an item with unique id u4UniqueID from the relation indicated by sRelation.

If the unresolved item reference is not found in the relation the function may issue a second search.

  1. Given the item that this Structure belongs to is registered at a library, the function will try to resolve the unique ID with Arxx::Library::pGetItem() (complexity in O(log(n))). If a resolved item reference to an item with this unique id is in the relation it is also found via pGetItem() and can and will be deleted from the relation. If pGetItem does not find the item there will be no such reference in the relation.
  2. Given the item that this Structure belongs to is not registered at a library, the function will iterate through the resolved item references in the relation trying to find one that refers to an item with this unique id.

There are two things to consider:

Any atempt to do so as well as deleting from a non-existent relation will be silently ignored.

If the deleted item reference was the last one in the relation so that the relation sRelation is now empty it is deleted from the relations container.

Arxx::Structure::const_iterator Arxx::Structure::begin ( void   )  const

Returns the first const Relation iterator of the Structure.

Arxx::Structure::iterator Arxx::Structure::begin ( void   ) 

Returns the first Relation iterator of the Structure.

bool Arxx::Structure::bHasRelation ( const std::string &  sRelation  )  const

Query whether a paricular relation exists.

Parameters:
sRelation The name of the relation.

Arxx::Structure::const_iterator Arxx::Structure::end ( void   )  const

Returns the end const Relation iterator of the Structure.

Arxx::Structure::iterator Arxx::Structure::end ( void   ) 

Returns the end Relation iterator of the Structure.

Arxx::Structure::Relation & Arxx::Structure::GetRelation ( const std::string &  sRelation  ) 

The accessor for relations.

Parameters:
sRelation The relation's name.
Exceptions:
std::out_of_range If a relation with the name sRelation does not exist in the structure.
This function returns a reference to a Arxx::Structure::Relation object which you can use to query and modify the content of this relation.

const Arxx::Structure::Relation & Arxx::Structure::GetRelation ( const std::string &  sRelation  )  const

The const accessor for constant relations.

Parameters:
sRelation The relation's name.
Exceptions:
std::out_of_range If a relation with the name sRelation does not exist in the structure.
This function returns a reference to a Arxx::Structure::Relation object which you can use to query the content of this relation.

Arxx::Structure::size_type Arxx::Structure::size ( void   )  const

Returns the number of Relations in the Structure.

void Arxx::Structure::vReadFromStream ( Arxx::u4byte  u4StructureDataLength,
std::istream &  IStream 
) [private]

void Arxx::Structure::vRemoveRelation ( Arxx::Structure::Relation pRelation  )  [private]

void Arxx::Structure::vWriteToBuffer ( Arxx::Buffer Buffer  )  const [private]

Writes the Structure information to a Buffer.

Parameters:
Buffer The Buffer that will receive the structural information.
This function simply appends the structure information to the Buffer.


Friends And Related Function Documentation

friend class Arxx::Archive [friend]

friend class Arxx::Structure::Relation [friend]

Arxx::Buffer& operator<< ( Arxx::Buffer Buffer,
const Arxx::Structure Structure 
) [friend]

Convenience function that streams the structural information into a Arxx::Buffer.


Member Data Documentation

Arxx::Item& Arxx::Structure::m_Item [private]

std::map< std::string, Arxx::Structure::Relation > Arxx::Structure::m_Relations [private]


The documentation for this class was generated from the following files:
Generated on Tue Oct 10 11:34:55 2006 for libarxx by  doxygen 1.4.7