Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

TLinkable Class Reference

Stores the ID and a list of links which point to this object. More...

#include <link.h>

Inheritance diagram for TLinkable:

Inheritance graph
[legend]
Collaboration diagram for TLinkable:

Collaboration graph
[legend]
List of all members.

Public Methods

const TObjectIDgetID () const
const TLinkBaseListgetLinkedByList () const
int4 getNumberOfLinks () const
virtual int2 getType () const
virtual const string & getTypeName () const
virtual bool load (TDataPackageList *in)
virtual bool save (TDataPackageList *out) const

Protected Methods

 TLinkable ()
virtual ~TLinkable ()
virtual void reset ()

Private Methods

 TLinkable (const TLinkable &Src)
void addInverseLink (TLinkBase *p)
TLinkable & operator= (const TLinkable &Src)
void removeInverseLink (TLinkBase *p)

Private Attributes

TObjectID ID
TLinkBaseList LinkedBy

Static Private Attributes

TObjectID UniqueID

Friends

class TLinkBase
class TLinkUpdate

Detailed Description

Stores the ID and a list of links which point to this object.

Author:
Marco Krohn <marco.krohn@gmx.de>
Version:
Id:
link.h,v 1.38 2002/05/15 08:30:55 ishark Exp
See also:
TLinkBase, TLinkList, TLinkBaseList, TLinkUpdate, TObjectID
All objects which need to be linked (like TRace, TFleet, ...) must be derived from TLinkable. TLinkable has its own unique ID and also stores a list of all links which are pointing to the object. The real advantage of this class over a pointer is that it is possible to save all objects and the links to disk and also restore this information. See TLinkUpdate for more information.

If the object is deleted all links pointing to the object are automatically resetted.

FIXME: add example / usage


Constructor & Destructor Documentation

TLinkable::TLinkable   [protected]
 

Generates a unique ID for the object. Making the constructor protected forbids creating objects of the type TLinkable.

virtual TLinkable::~TLinkable   [protected, virtual]
 

Resets all links pointing to this object. This of course needs the LinkedBy list.

See also:
Reset

TLinkable::TLinkable const TLinkable &    Src [private]
 

The copy constructor is not implemented since it is forbidden to copy a TLinkable object. IDs have to be unique. This is also the reason for making the copy constructor private: to make it impossible to copy this object.


Member Function Documentation

void TLinkable::addInverseLink TLinkBase   p [private]
 

Adds a link to the LinkedBy list.

Parameters:
p  FIXME

const TObjectID& TLinkable::getID   const
 

Returns:
The ID of this object.

const TLinkBaseList& TLinkable::getLinkedByList   const
 

Returns:
List of links pointing to this object.

int4 TLinkable::getNumberOfLinks   const
 

Returns:
The number of links pointing to this object.
See also:
getLinkedByList

virtual int2 TLinkable::getType   const [virtual]
 

Returns:
The type of the object (TType::TLinkable)

Reimplemented from TType.

Reimplemented in TAction, TFleet, TGalaxy, TItem, TShipDesign, TStellarObject, TSubFleet, and TSystem.

virtual const string& TLinkable::getTypeName   const [virtual]
 

Returns:
"TLinkable".

Reimplemented from TType.

Reimplemented in TAction, TFleet, TGalaxy, TItem, TShipDesign, TStellarObject, TSubFleet, and TSystem.

virtual bool TLinkable::load TDataPackageList   in [virtual]
 

Loads a TLinkable. Note that classes that are derived from this class must call TLinkable::Load explicitly to load the data correctly.

Parameters:
in  The list of data packages.
Returns:
true means that everything was loaded correctly, otherwise this method will return false.

Reimplemented in TAction, TActionObject, TFleet, TGalaxy, TItem, TSTLEngine, TFTLEngine, TFuelTank, TFuelScoop, TCargoBay, TColonizer, TRepairBot, TDefenseType, TArmorType, TShieldType, TArmor, TShield, TWeapon, TKWeapon, TEWeapon, TTargetingComputer, TScanner, TScannerNormalActive, TScannerNormalPassive, TScannerAntiDisguiseActive, TScannerAntiDisguisePassive, TScannerAntiCloakActive, TScannerAntiCloakPassive, TScannerPenetrateActive, TScannerPenetratePassive, TJammer, TJammerNormal, TJammerDisguise, TJammerCloak, TJammerAntiPenetrate, TMineLayer, TMiningBot, TFighterLauncher, TSPWeaponLauncher, TProperty, TRace, TShipDesign, TStellarObject, TSubFleet, TSubstanceType, TSystem, and TSubFleetBasic.

TLinkable& TLinkable::operator= const TLinkable &    Src [private]
 

Copying a TLinkable object is forbidden since all objects have to have different IDs. That's why this method is private and is doing nothing.

void TLinkable::removeInverseLink TLinkBase   p [private]
 

Removes a link from the LinkedBy list.

Parameters:
p  is the pointer which should be removed from the LinkedBy list.

virtual void TLinkable::reset   [protected, virtual]
 

Resets all values (this will also reset all links pointing to this object).

Reimplemented in TUniverse.

virtual bool TLinkable::save TDataPackageList   out const [virtual]
 

Saves a TLinkable object by adding the data packages to the list. Note that classes that are derived from this class must call TLinkable::Save explicitly to save the data correctly.

Parameters:
out  The output stream of data packages.
Returns:
true means that everything was saved correctly, otherwise this method will return false.

Reimplemented in TAction, TActionObject, TFleet, TGalaxy, TItem, TSTLEngine, TFTLEngine, TFuelTank, TFuelScoop, TCargoBay, TColonizer, TRepairBot, TDefenseType, TArmorType, TShieldType, TArmor, TShield, TWeapon, TKWeapon, TEWeapon, TTargetingComputer, TScanner, TScannerNormalActive, TScannerNormalPassive, TScannerAntiDisguiseActive, TScannerAntiDisguisePassive, TScannerAntiCloakActive, TScannerAntiCloakPassive, TScannerPenetrateActive, TScannerPenetratePassive, TJammer, TJammerNormal, TJammerDisguise, TJammerCloak, TJammerAntiPenetrate, TMineLayer, TMiningBot, TFighterLauncher, TSPWeaponLauncher, TProperty, TRace, TShipDesign, TStellarObject, TSubFleet, TSubstanceType, TSystem, and TSubFleetBasic.


Member Data Documentation

TObjectID TLinkable::ID [private]
 

The ID of this object.

TLinkBaseList TLinkable::LinkedBy [private]
 

List of links to TLinkable objects linking this object.

TObjectID TLinkable::UniqueID [static, private]
 

This counter always points to the next unique ID.


The documentation for this class was generated from the following file:
Generated on Thu Jun 20 18:13:26 2002 for Stellar Legacy by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001