Arxx::Reference Class Reference

#include <Reference.h>

Collaboration diagram for Arxx::Reference:

Collaboration graph
[legend]
List of all members.

Detailed Description

Instances of this class represent items either by unique ID or if known by pointer.

All in all this is a cache for Arxx::Item pointers. Generally, you would identify Arxx::Item instances by their unique IDs and retrieve the appropriate Arxx::Item pointer via the associated library. However, returning the Item corresponding to a certain unique ID is costy and should only be done very seldom. Therefore this class provides an abstraction for references to Items.

When created via the copy constructor Reference objects share a reference counted ReferenceImplementation object that holds the actual reference. This means that, once a unique ID is resolved into the appropriate Item pointer it is done so everywhere.


Public Member Functions

 Reference (Arxx::Item &Item)
 Constructs a Arxx::Reference from a Arxx::Item.
 Reference (Arxx::u4byte u4UniqueID, Arxx::Archive *pArchive=0)
 Constructs a Arxx::Reference from a unique ID.
 Reference (const Arxx::Reference &Reference)
 Constructs a Arxx::Reference from another Reference object.
virtual ~Reference (void)
 Destroys a Arxx::Reference object.
Arxx::u4byte u4GetUniqueID (void) const
 Returns the unique ID of the reference.
Arxx::ItempGetItem (void)
 Returns the Arxx::Item pointer of the reference.
const Arxx::ItempGetItem (void) const
 Returns the Arxx::Item pointer of the reference.
Arxx::u4byte u4GetReferenceCount (void) const
 Returns m_u4ReferenceCounter, the number of Arxx::Reference objects that hold this ReferenceImplementation object.
void vResolve (Arxx::Item &Item)
 Resolves an unresolved reference with a given item.
void vUnresolve (void)
 Unresolves the resolved reference.
bool bAttach (Arxx::Reference &Reference)
 This function will attach another Reference object representing the same Item.
bool bDetach (void)
 This function will detach the Reference object from the Reference set.
void vDecoupleFromArchive (void)
 This function will reset the Archive pointer to `0`.
bool operator< (const Arxx::Reference &Reference) const

Private Member Functions

void vChangeReference (Arxx::ReferenceImplementation *pReference)
 Small helper function.

Private Attributes

Arxx::ReferenceImplementationm_pReference


Constructor & Destructor Documentation

Arxx::Reference::Reference ( Arxx::Item Item  ) 

Constructs a Arxx::Reference from a Arxx::Item.

Parameters:
Item The Arxx::Item that this Reference should refer to.
This constructor will of course create a new ReferenceImplementation object so it can store its resolved reference.

Arxx::Reference::Reference ( Arxx::u4byte  u4UniqueID,
Arxx::Archive pArchive = 0 
)

Constructs a Arxx::Reference from a unique ID.

Parameters:
u4UniqueID The unique ID that this Reference should refer to.
pArchive Optional Archive that this reference belongs to.
This constructor will of course create a new ReferenceImplementation object so it can store its unresolved reference.

Arxx::Reference::Reference ( const Arxx::Reference Reference  ) 

Constructs a Arxx::Reference from another Reference object.

Parameters:
Reference The other Reference object that this Reference should copy.
This constructor will only reference the ReferenceImplementation object hosted by Reference.

Arxx::Reference::~Reference ( void   )  [virtual]

Destroys a Arxx::Reference object.

This mainly releases the underlying Arxx::ReferenceImplementation object.


Member Function Documentation

bool Arxx::Reference::bAttach ( Arxx::Reference Reference  ) 

This function will attach another Reference object representing the same Item.

Parameters:
Reference A Reference that is to be attached to this Reference set.
A Reference set is a number of Reference objects that use the same ReferenceImplementation.

This function will call Reference.vDetach if u4GetReferenceCount() is greater than 1.

This function will return with false if either the unique IDs don't match or Reference is resolved.

bool Arxx::Reference::bDetach ( void   ) 

This function will detach the Reference object from the Reference set.

A Reference set is a number of Reference objects that use the same ReferenceImplementation.

This function will create a ReferenceImplementation object that is used only by this Reference and will release the m_pReference ReferenceImplementation.

This Reference and its ReferenceImplementation will be unresolved after this, and decoupled from any Archive that it may have been connected to prior to this call.

bool Arxx::Reference::operator< ( const Arxx::Reference Reference  )  const [inline]

Here is the call graph for this function:

const Arxx::Item * Arxx::Reference::pGetItem ( void   )  const

Returns the Arxx::Item pointer of the reference.

If the reference is resolved this correctly returns the Arxx::Item's pointer. In case of an unresolved reference the returned pointer is 0.

This function only calls Arxx::ReferenceImplementation::pGetItem().

See also:
Arxx::ReferenceImplementation::pGetItem().

Arxx::Item * Arxx::Reference::pGetItem ( void   ) 

Returns the Arxx::Item pointer of the reference.

If the reference is resolved this correctly returns the Arxx::Item's pointer. In case of an unresolved reference the returned pointer is 0.

This function only calls Arxx::ReferenceImplementation::pGetItem().

See also:
Arxx::ReferenceImplementation::pGetItem().

Arxx::u4byte Arxx::Reference::u4GetReferenceCount ( void   )  const

Returns m_u4ReferenceCounter, the number of Arxx::Reference objects that hold this ReferenceImplementation object.

This function only calls Arxx::ReferenceImplementation::u4GetReferenceCount().

See also:
Arxx::ReferenceImplementation::u4GetReferenceCount().

Arxx::u4byte Arxx::Reference::u4GetUniqueID ( void   )  const

Returns the unique ID of the reference.

It does not matter if the reference is resolved or unresolved, the unique ID is certain to be returned.

void Arxx::Reference::vChangeReference ( Arxx::ReferenceImplementation pReference  )  [private]

Small helper function.

void Arxx::Reference::vDecoupleFromArchive ( void   ) 

This function will reset the Archive pointer to `0`.

It is only used by the Arxx::Archive and should not be used elsewhere. Probably it should be private.

void Arxx::Reference::vResolve ( Arxx::Item Item  ) 

Resolves an unresolved reference with a given item.

Parameters:
Item The Arxx::Item that will be used to resolve the reference.
This function only calls Arxx::ReferenceImplementation::vResolve(Item).

See also:
Arxx::ReferenceImplementation::vResolve().

void Arxx::Reference::vUnresolve ( void   ) 

Unresolves the resolved reference.

This function only calls Arxx::ReferenceImplementation::vUnresolve().

See also:
Arxx::ReferenceImplementation::vUnresolve().


Member Data Documentation

Arxx::ReferenceImplementation* Arxx::Reference::m_pReference [private]


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