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

TItem Class Reference

TItem represents an basic item you can put onto a ship. More...

#include <item.h>

Inheritance diagram for TItem:

Inheritance graph
[legend]
Collaboration diagram for TItem:

Collaboration graph
[legend]
List of all members.

Public Types

typedef int2 tWeaponType
enum  tItemType {
  STL_ENGINE = 0x00000001, FTL_ENGINE = 0x00000002, FUELTANK = 0x00000004, FUELSCOOP = 0x00000008,
  CARGOBAY = 0x00000010, COLONIZER = 0x00000020, REPAIRBOT = 0x00000040, ARMOR = 0x00000080,
  SHIELD = 0x00000100, KWEAPON = 0x00000200, EWEAPON = 0x00000400, TARGETINGCOMPUTER = 0x00000800,
  SCANNER = 0x00001000, JAMMER = 0x00002000, MINELAYER = 0x00004000, MININGBOT = 0x00008000,
  FIGHTERLAUNCHER = 0x00010000, SPWEAPONLAUNCHER = 0x00020000
}

Public Methods

 TItem ()
 TItem (const TItem &OldItem)
virtual ~TItem ()
virtual int2 getType () const
virtual const string & getTypeName () const
virtual bool load (TDataPackageList *in)
virtual bool save (TDataPackageList *out) const
virtual TItem::tItemType getItemType () const=0
virtual void setItemName (const string &Name)
virtual const string & getItemName () const
virtual void setTechLevel (const int2 TechLevel)
virtual int2 getTechLevel () const
virtual void setMass (const int2 Mass)
virtual int2 getMass () const
virtual void setVolume (const int2 Volume)
virtual int2 getVolume () const
virtual void setSurface (const int2 Surface)
virtual int2 getSurface () const
virtual void setCost (const TSubstanceSet &Cost)
virtual void getCost (TSubstanceSet *Cost) const
virtual bool operator== (const TItem &Item) const

Protected Methods

virtual TItem & operator= (const TItem &Item)

Protected Attributes

string fItemName
int2 fTechLevel
int2 fItemMass
int2 fItemVolume
int2 fItemSurface
TSubstanceSet fItemCost

Detailed Description

TItem represents an basic item you can put onto a ship.

Author:
Ralf Laue , Marco Krohn, <marco.krohn@gmx.de>
Version:
Id:
item.h,v 1.34 2002/04/02 22:33:08 prolator Exp
See also:
TShipDesign
The class TItem represents an basic item you can put on a ship design: name, type, mass, volume, surface area and cost (amount of substances needed to build this item). In general this class will be used to derive "real" items like scanners, armors etc. Since all these items are unique, this base class is derived form TLinkable and provides thus an unique ID and can be linked as known.

General concept of TItem and derived classes

There is one base list which belongs to TUniverse. All items which are accessible within the game are stored in this list. Also each race has its own list of pointers to items which are accessible for this race. When a race develops a new item a pointer to this item is added to the list of items for this race.

Note that TItem is a pure virtual class, so making instances of this class is not possible. TItem just provides the general interface for all items. Derived from this class are the interfaces for the different item types, for example a TSTLEngine. These classes also provide only the interface for this item type, the real implementation is done in different classes which have an additional suffix, e.g. TSTLEngineBasic, TSTLEngineStars etc.


Member Typedef Documentation

typedef int2 TItem::tWeaponType
 

This is the variable type for the weapon type. In future it could be necessary to change it into a class of its own or even two classes, one for kinetic weapons and one for energy weapons. It is defined here because this is the only place in the hierarchy above the classes were it is needed. As long as it is only an integer, the rule set/game start up class is responsible that there is no energy weapon with the same number a kinetic weapon already has.


Member Enumeration Documentation

enum TItem::tItemType
 

Each from TItem derived class (i.e. TSTLEngine) will return one of these constants, if it shall indentify itself. This is especially important in connection with TShipDesign


Constructor & Destructor Documentation

TItem::TItem  
 

This constructor doesn't work, because TItem is a pure virtual class. It's only implemented to be used by the sub classes of TItems.

TItem::TItem const TItem &    OldItem
 

This constructor doesn't work either and is implemented to provide a copy constructor for the sub classes.

Parameters:
OldItem  the item which shall be copied.

virtual TItem::~TItem   [virtual]
 

Destructs the object. Has nothing else to do, because no memory has to be freed or similar stuff. Doesn't work, because TItem is a pure virtual class and you wont be able to construct an object.


Member Function Documentation

virtual void TItem::getCost TSubstanceSet   Cost const [virtual]
 

With the method getCost you can get the cost (from type TSubstanceSet) for the item.

Returns:
the cost of the item

virtual const string& TItem::getItemName   const [virtual]
 

With the method getItemName you can read out the name of the item.

Returns:
the name of the item

virtual TItem::tItemType TItem::getItemType   const [pure virtual]
 

With the method getItemType you can get the type of the item, that means whether it is armor, engine or something else. This method has to be reimplemented in all the derived classes.

Returns:
nothing

Reimplemented in TSTLEngine, TFTLEngine, TFuelTank, TFuelScoop, TCargoBay, TColonizer, TRepairBot, TArmor, TShield, TWeapon, TKWeapon, TEWeapon, TTargetingComputer, TScanner, TJammer, TMineLayer, TMiningBot, TFighterLauncher, and TSPWeaponLauncher.

virtual int2 TItem::getMass   const [virtual]
 

With the method getMass you can get the mass of the item.

Returns:
the mass of the item

virtual int2 TItem::getSurface   const [virtual]
 

With the method getSurface you can get the surface area the item needs.

Returns:
the surface area the item needs

virtual int2 TItem::getTechLevel   const [virtual]
 

With the method getTechLevel you can get the tech level the item has. This will be important i.e. if you want to sort items after tech level.

Returns:
the tech level of the item

virtual int2 TItem::getType   const [virtual]
 

This method is inherited from TType and reimplemented here. I returns TType::ITEM.

Returns:
the type of the class, here: TType::ITEM
See also:
TType

Reimplemented from TLinkable.

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

This method is inherited from TType and reimplemented here. I returns "TItem".

Returns:
the name of the class, here "TItem"
See also:
TType

Reimplemented from TLinkable.

virtual int2 TItem::getVolume   const [virtual]
 

With the method getVolume you can get the volume the item needs.

Returns:
the volume the item needs

virtual bool TItem::load TDataPackageList   in [virtual]
 

The method Load loads a TItem object from the data packages in the list. All sub classes of TItem have to reimplement the Load method and they must call TItem::Load explicitly in their Load method to load the data correctly. For more information look in the documentation of the ancestors of TItem from where this method is inherited.

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

Reimplemented from TLinkable.

Reimplemented in TSTLEngine, TFTLEngine, TFuelTank, TFuelScoop, TCargoBay, TColonizer, TRepairBot, TArmor, TShield, TWeapon, TKWeapon, TEWeapon, TTargetingComputer, TScanner, TScannerNormalActive, TScannerNormalPassive, TScannerAntiDisguiseActive, TScannerAntiDisguisePassive, TScannerAntiCloakActive, TScannerAntiCloakPassive, TScannerPenetrateActive, TScannerPenetratePassive, TJammer, TJammerNormal, TJammerDisguise, TJammerCloak, TJammerAntiPenetrate, TMineLayer, TMiningBot, TFighterLauncher, and TSPWeaponLauncher.

virtual TItem& TItem::operator= const TItem &    Item [protected, virtual]
 

This is the assignment operator for TItem.

virtual bool TItem::operator== const TItem &    Item const [virtual]
 

This is the compare operator for TItem. It is only used in the sub classes of TItem to compare the fields of TItem, because TItem is abstract.

Parameters:
Item  the item which shall be compared with "*this"
Returns:
true if items are equal, false if not

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

The method Save saves a TItem by adding the data packages to the list. All sub classes of TItem have to reimplement the Save method and they must call TItem::Save explicitly in their Save method to save the data correctly. For more information look in the documentation of the ancestors of TItem, because the method Save is inherited from there.

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

Reimplemented from TLinkable.

Reimplemented in TSTLEngine, TFTLEngine, TFuelTank, TFuelScoop, TCargoBay, TColonizer, TRepairBot, TArmor, TShield, TWeapon, TKWeapon, TEWeapon, TTargetingComputer, TScanner, TScannerNormalActive, TScannerNormalPassive, TScannerAntiDisguiseActive, TScannerAntiDisguisePassive, TScannerAntiCloakActive, TScannerAntiCloakPassive, TScannerPenetrateActive, TScannerPenetratePassive, TJammer, TJammerNormal, TJammerDisguise, TJammerCloak, TJammerAntiPenetrate, TMineLayer, TMiningBot, TFighterLauncher, and TSPWeaponLauncher.

virtual void TItem::setCost const TSubstanceSet   Cost [virtual]
 

With the method setCost you can set the cost (from type TSubstanceSet) for the item.

Parameters:
Cost  the new cost for the item

virtual void TItem::setItemName const string &    Name [virtual]
 

With the method setItemName you can give the item its name.

Parameters:
Name  the new name for the item

virtual void TItem::setMass const int2    Mass [virtual]
 

With the method setMass you can set the mass of the item.

amter Mass the new mass of the item

virtual void TItem::setSurface const int2    Surface [virtual]
 

With the method setSurface you can set the surface area the item needs.

Parameters:
Surface  the new surface area the item needs

virtual void TItem::setTechLevel const int2    TechLevel [virtual]
 

With the method setTechLevel you can set the tech level the item has.

Parameters:
TechLevel  the new tech level for the item

virtual void TItem::setVolume const int2    Volume [virtual]
 

With the method setVolume you can set the volume the item needs.

Parameters:
Volume  the new volume the item needs


Member Data Documentation

TSubstanceSet TItem::fItemCost [protected]
 

the cost (from type TSubstanceSet) for this item

int2 TItem::fItemMass [protected]
 

the mass if the item

string TItem::fItemName [protected]
 

the name of the item.

int2 TItem::fItemSurface [protected]
 

the surface area the item needs on the outside of the hull

int2 TItem::fItemVolume [protected]
 

the volume the item needs

int2 TItem::fTechLevel [protected]
 

the tech level of the item


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