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

TSubstanceType Class Reference

Substance handling classes: substance Type. More...

#include <substance.h>

Inheritance diagram for TSubstanceType:

Inheritance graph
[legend]
Collaboration diagram for TSubstanceType:

Collaboration graph
[legend]
List of all members.

Public Methods

 TSubstanceType (const string &name, const string &abbrev, const uint2 cclass, const int2 usize, const int2 umass, const bool update=false)
virtual ~TSubstanceType (void)
const string & Name (void) const
const string & Abbrev (void) const
const uint2 Id (void) const
const uint2 CargoClass (void) const
const int2 UnitSize (void) const
const int2 UnitMass (void) const
const bool Updatable (void) const
virtual TSubstanceCreate (const TOSVal &iAmount=1)
virtual TOSVal Update (TSubstance *substance, const TOSVal &available_space)
virtual bool load (TDataPackageList *in)
virtual bool save (TDataPackageList *out) const

Static Public Methods

const uint4 NumberSubstances (void)
const uint2 NumberCargoClasses (void)
TSubstanceType * FindById (const SubstanceId Id)
TSubstanceType * FindByName (const string &Name)

Private Methods

 TSubstanceType (const TSubstanceType &)
TSubstanceType & operator= (const TSubstanceType &)

Private Attributes

string fName
string fAbbrev
SubstanceId fId
uint2 fCargoClass
int2 fUnitSize
int2 fUnitMass
bool fUpdatable

Static Private Attributes

vector< TSubstanceType *> fSubstanceTable
uint2 fCargoClasses

Detailed Description

Substance handling classes: substance Type.

Substance type class. Instances of this class represent substances with the same set of properties. Every substance type is automatically assigned an id which can be used in place of the name for faster operation. Substance parameters such as size, mass, etc. are stored here. The class can be used as a base class for the introduction of types which require more parameters than the one currently available.

Please check TSubstance for an overview of the substance classes.

Version:
Id:
substance.h,v 1.10 2002/06/03 11:48:24 mkrohn5 Exp
See also:
TSubstance,TSubstanceSet,TSubstanceHold


Constructor & Destructor Documentation

TSubstanceType::TSubstanceType const string &    name,
const string &    abbrev,
const uint2    cclass,
const int2    usize,
const int2    umass,
const bool    update = false
 

The TSubstanceType constructor is used to define a new type of substance to be used. All properties must be specified at creation and are *constant*.

Parameters:
name  Name of the substance (localizable).
abbrev  Abbreviation of the name (fixed, used in files).
cclass  Cargo class used by thie substance.
usize  Size taken by a single unit of substance.
umass  Mass of a single unit of substance.
update  Specifies if the substance needs periodic updates or not (e.g. growing population).

virtual TSubstanceType::~TSubstanceType void    [virtual]
 

Destructor, virtual to allow derivation.


Member Function Documentation

const string& TSubstanceType::Abbrev void    const
 

Read-accessor to Substance abbreviated name.

Returns:
abbreviation of the substance type.

const uint2 TSubstanceType::CargoClass void    const
 

Read-accessor to Substance cargo class.

Returns:
cargo class of the substance type.

virtual TSubstance* TSubstanceType::Create const TOSVal   iAmount = 1 [virtual]
 

Substance creator. This function is used to create a specified amount of the substance. It replaces the TSubstance class constructor.

Returns:
allocates and returns a new TSubstance object containing the specified amount. THE CALLER IS IN CHARGE OF DEALLOCATION.
Parameters:
iAmount  the amount of substance to be created.

TSubstanceType* TSubstanceType::FindById const SubstanceId    Id [static]
 

Class-wide member to obtain a pointer to the SubstanceType corresponding to a specified ID number.

Returns:
pointer to a TSubstanceType.
Parameters:
Id  the id of the requested substance type.

TSubstanceType* TSubstanceType::FindByName const string &    Name [static]
 

Class-wide member to obtain a pointer to the SubstanceType corresponding to a specified substance name.

Returns:
pointer to a TSubstanceType.
Parameters:
Name  the name of the requested substance type.

const uint2 TSubstanceType::Id void    const
 

Read-accessor to Substance ID number.

Returns:
ID number of the substance type.

virtual bool TSubstanceType::load TDataPackageList   in [virtual]
 

The method Load loads a TSubstanceType object from the data packages in the list. For more information look in the documentation of the ancestors of TSubstanceType 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.

const string& TSubstanceType::Name void    const
 

Read-accessor to Substance name.

Returns:
name of the substance type.

const uint2 TSubstanceType::NumberCargoClasses void    [static]
 

Class-wide member to return the total number of different cargo classes defined.

Returns:
number of defined cargo classes.

const uint4 TSubstanceType::NumberSubstances void    [static]
 

Class-wide member to return the total number of Substances currently defined.

Returns:
number of defined substance types.

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

The method Save saves a TSubstanceType by adding the data packages to the list. For more information look in the documentation of the ancestors of TSubstanceType, 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.

const int2 TSubstanceType::UnitMass void    const
 

Read-accessor to Substance mass / unit.

Returns:
mass/unit ration of the substance type.

const int2 TSubstanceType::UnitSize void    const
 

Read-accessor to Substance size / unit.

Returns:
size/unit ration of the substance type.

const bool TSubstanceType::Updatable void    const
 

Determine if the Substance Type requires updates of substance objects.

Returns:
true if substance has time evolution, false otherwise.

virtual TOSVal TSubstanceType::Update TSubstance   substance,
const TOSVal   available_space
[virtual]
 

Default update method for the substance. If a group of substance types share the same time-evolution properties then one can put the update function here and have all the objects call this function for update (default behaviour). If the update depends on some weird, substance object-dependent value then one should consider deriving from TSubstance and replacing the Update function down there.

Returns:
the amount of substance that must be added/removed which results from the time evolution.
Parameters:
substance  pointer to the TSubstance object to evolve.
available_space  indication of the available cargo space (note that the return value may be greater than this value, it's up to the caller to ensure it fits).


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