#include <Reference.h>
Collaboration diagram for Arxx::Reference:
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::Item * | pGetItem (void) |
Returns the Arxx::Item pointer of the reference. | |
const Arxx::Item * | pGetItem (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::ReferenceImplementation * | m_pReference |
Arxx::Reference::Reference | ( | Arxx::Item & | Item | ) |
Constructs a Arxx::Reference from a Arxx::Item.
Item | The Arxx::Item that this Reference should refer to. |
Arxx::Reference::Reference | ( | Arxx::u4byte | u4UniqueID, | |
Arxx::Archive * | pArchive = 0 | |||
) |
Constructs a Arxx::Reference from a unique ID.
u4UniqueID | The unique ID that this Reference should refer to. | |
pArchive | Optional Archive that this reference belongs to. |
Arxx::Reference::Reference | ( | const Arxx::Reference & | Reference | ) |
Constructs a Arxx::Reference from another Reference object.
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.
bool Arxx::Reference::bAttach | ( | Arxx::Reference & | Reference | ) |
This function will attach another Reference object representing the same Item.
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().
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().
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().
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.
Item | The Arxx::Item that will be used to resolve the reference. |
void Arxx::Reference::vUnresolve | ( | void | ) |
Unresolves the resolved reference.
This function only calls Arxx::ReferenceImplementation::vUnresolve().