#include <link.h>
Inheritance diagram for TLinkBase:
Public Types | |
enum | { LINK_BASE = 0, LINK, DOUBLE_LINK } |
Public Methods | |
TLinkBase () | |
TLinkBase (TLinkable *p) | |
TLinkBase (const TObjectID &DestID) | |
TLinkBase (const TLinkBase &link) | |
virtual | ~TLinkBase () |
TLinkable * | getDest () const |
const TObjectID & | getDestID () const |
int2 | getDestType () const |
virtual int2 | getType () const |
const string & | getDestTypeName () const |
bool | isNull () const |
bool | isUpdated () const |
bool | isValid () const |
bool | load (TDataPackageList *in, const string &sIdentifier, bool bUnique=true) |
TLinkBase & | operator= (const TLinkBase &src) |
bool | operator== (const TLinkBase &Two) const |
bool | save (TDataPackageList *out, const string &sIdentifier, bool bUnique=true) const |
virtual void | setDest (TLinkable *p) |
virtual void | setNull () |
void | Write (ostream &out) const |
Protected Methods | |
void | removeUpdateRequest () |
void | requestUpdate () |
void | reset () |
void | setDest (const TObjectID &DestID) |
Protected Attributes | |
bool | bNeedUpdate |
TLinkable * | pDest |
TObjectID | DestID |
Static Protected Attributes | |
TObjectID | NullID |
Friends | |
class | TLinkUpdate |
class | TLinkable |
While loading the game the link receives only the dest ID and not the pointer to the object (see setDest(const TObjectID&) ). There is no way around this because the dest object might be loaded after the object which sets the link. The bNeedUpdate flag shows if the link is complete or needs an update. The information if the link needs an update (to become a "real" link) is also stored in the TLinkUpdate class (see TLinkUpdate for details about the update process).
A link is always in one of the three following states:
true)
. The dest ID has a value and the pointer is set to 0 so in this case the link is also a null link. The method isUpdated shows if the link is waiting for an update or not.
|
see getType for details. |
|
Creates an empty link by calling the method reset. |
|
Initializes the object with the destination object. The ID of the destination object is copied to this object.
|
|
Initializes the object with the destination ID. The pointer will be updated when the link/object couple is committed.
|
|
Copy constructor.
|
|
Removes the link. If the link needs an update it is also removes the update request from TLinkUpdate. |
|
|
|
|
|
|
|
|
|
Note: there are three different link types possible: TLinkBase, TLink and TDoubleLink. In some cases it is useful to know whether the object is a double link or not (this is the main reason for this method). Also note that using RTTI might be unhandy since TLink, TDoubleLink are template classes and therefore decideing if the object is a TDoubleLink object might be difficult.
Reimplemented in TLink, TDoubleLink, TLink< TArmorType >, TLink< TActionObject >, TLink< TShipDesign >, TLink< TStellarObject >, TLink< TItem >, TLink< TFleet >, TLink< TGalaxy >, TLink< TPlayer >, TLink< TShieldType >, TLink< TSubstanceType >, and TLink< TRace >. |
|
Checks if the link is a null object (that means that the destination pointer and the dest ID is 0). Note: a null link never needs an update.
|
|
|
|
|
|
Loads a TLinkBase object from a list of data packages. Note that a successful load will delete the datapackage from the data package list as well as the datapackage itself.
|
|
The standard operator= copies all components. It also takes care that if src needs an update that the copy also gets an update.
|
|
Two links are equal if they need no update and if their destination object is the same. |
|
If bNeedUpdate is set to
|
|
Sets bNeedUpdate to |
|
Resets the link to the default values, that means bNeedUpdate to |
|
Creates the data package of TLinkBase object and adds it to the data package list.
|
|
Sets an incomplete link, since only the dest ID is known. This will automatically set the bUpdateFlag to |
|
Sets a link to an object type of TLinkable.
Reimplemented in TLink, TLink< TArmorType >, TLink< TActionObject >, TLink< TShipDesign >, TLink< TStellarObject >, TLink< TItem >, TLink< TFleet >, TLink< TGalaxy >, TLink< TPlayer >, TLink< TShieldType >, TLink< TSubstanceType >, and TLink< TRace >. |
|
Changes the link to a null link (that means that the destination pointer and the dest ID is 0). Note: Identical to call setDest(0).
Reimplemented in TLink, TLink< TArmorType >, TLink< TActionObject >, TLink< TShipDesign >, TLink< TStellarObject >, TLink< TItem >, TLink< TFleet >, TLink< TGalaxy >, TLink< TPlayer >, TLink< TShieldType >, TLink< TSubstanceType >, and TLink< TRace >. |
|
Writes the dest ID to a stream.
|
|
Shows if the link needs an update or not. This flag is only useful while loading the game. |
|
The ID of the dest object. |
|
ID which is null. |
|
The dest object. |