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

TSubstanceSet Class Reference

Substance handling classes: substance Set. More...

#include <substance.h>

Inheritance diagram for TSubstanceSet:

Inheritance graph
[legend]
Collaboration diagram for TSubstanceSet:

Collaboration graph
[legend]
List of all members.

Public Methods

 TSubstanceSet (void)
 ~TSubstanceSet (void)
 TSubstanceSet (const TSubstanceSet &Set2)
bool operator== (const TSubstanceSet &Set2) const
bool operator!= (const TSubstanceSet &Set2) const
TSubstanceSet & operator= (const TSubstanceSet &Set2)
void Clear (void)
TOSVal TotalSpace (const uint2 uCClass) const
TOSVal AvailableSpace (const uint2 uCClass) const
TOSVal UsedSpace (const uint2 uCClass) const
bool HasEnough (const TSubstanceSet &Set2, const int4 iNum=1, const int4 iDenom=1) const
bool Add (const TSubstanceSet &Set2, const int4 iNum=1, const int4 iDenom=1)
bool Remove (const TSubstanceSet &Set, const int4 iNum=1, const int4 iDenom=1)
bool HasEnough (const TSubstance &Subst, const int4 iNum=1, const int4 iDenom=1) const
bool Add (const TSubstance &Subst, const int4 iNum=1, const int4 iDenom=1)
bool Remove (const TSubstance &Subst, const int4 iNum=1, const int4 iDenom=1)
const TSubstanceoperator[] (const TSubstanceType *Type) const
const TPEList< TSubstance > & Content (void) const
bool load (TDataPackageList *in, const string &sIdentifier, bool bUnique=true)
bool save (TDataPackageList *out, const string &sIdentifier, bool bUnique=true) const

Protected Methods

TSubstanceFindSubstance (const TSubstanceType *type) const
void DeleteSubstance (TSubstance *Subst)

Protected Attributes

TPEList< TSubstancefContains

Friends

ostream & operator<< (ostream &os, const TSubstanceSet &Set)

Detailed Description

Substance handling classes: substance Set.

Substance set class. Instances of this class represent groups of substances. Substances of the same type are automatically added, so you can't have two ironoum amounts: they'll be added.

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:
TSubstanceType,TSubstance,TSubstanceHold


Constructor & Destructor Documentation

TSubstanceSet::TSubstanceSet void   
 

Constructor: builds an empty set.

TSubstanceSet::~TSubstanceSet void   
 

Non-virtual destructor, TSubstanceSet is not meant for derivation (you can derive it but must not use TSubstanceSet* to point to a derived object).

TSubstanceSet::TSubstanceSet const TSubstanceSet &    Set2
 

Copy constructor: duplication of Sets is legal.


Member Function Documentation

bool TSubstanceSet::Add const TSubstance   Subst,
const int4    iNum = 1,
const int4    iDenom = 1
 

Adds to the Set the given substance set. Set2 is left untouched. The new set is added iNum/iDenom times. The default values for both iNum and iDenom are 1.

Returns:
always true.
Parameters:
Subst  the substance to be added to the Set.
iNum  (default 1) multiplies Subst
iDenom  (default 1) divides Subst

bool TSubstanceSet::Add const TSubstanceSet &    Set2,
const int4    iNum = 1,
const int4    iDenom = 1
 

Adds to the Set the amount specifies by Set2. Set2 is left untouched. The new set is added iNum/iDenom times. The default values for both iNum and iDenom are 1.

Returns:
always true.
Parameters:
Set2  the substances to be added to the Set.
iNum  (default 1) multiplies Set2.
iDenom  (default 1) divides Set2.

TOSVal TSubstanceSet::AvailableSpace const uint2    uCClass const
 

Determine the size offered/taken by all substances (acts like "remaining cargo space").

Returns:
the opposite of the total size (i.e. a positive number) of all substances.
Parameters:
uCClass  cargo class to be examined.

Reimplemented in TSubstanceHold.

void TSubstanceSet::Clear void   
 

Clear the set, eliminating all elements it contains.

Reimplemented in TSubstanceHold.

const TPEList<TSubstance>& TSubstanceSet::Content void    const
 

Provide access to the internal vector. This is dangerous and will either be eliminated or replaced with a safe implemetation.

void TSubstanceSet::DeleteSubstance TSubstance   Subst [protected]
 

Delete a TSubstance object from the internal vector.

TSubstance* TSubstanceSet::FindSubstance const TSubstanceType   type const [protected]
 

Locate a TSubstance in the internal vector.

bool TSubstanceSet::HasEnough const TSubstance   Subst,
const int4    iNum = 1,
const int4    iDenom = 1
const
 

Check if the Set has enough of the specified substance. In any case the set is left untouched.

Returns:
false if there is not enough substance and true if there is enough.
Parameters:
Subst  specifies the substance type/amount amount against which to check.
iNum  (default 1) multiplies Subst.
iDenom  (default 1) divides Subst.

bool TSubstanceSet::HasEnough const TSubstanceSet &    Set2,
const int4    iNum = 1,
const int4    iDenom = 1
const
 

Check if the Set has enough substances to allow a removal of the amount specified by Set2 * iNum / iDenom. In any case the set is left untouched.

Returns:
false if there are not enough substances and true if there are enough.
Parameters:
Set2  specifies the amount against which to check.
iNum  (default 1) multiplies Set2.
iDenom  (default 1) divides Set2.

bool TSubstanceSet::load TDataPackageList   in,
const string &    sIdentifier,
bool    bUnique = true
 

With the method Load you can load a TSubstanceSet object from the data packages in the list. For more information look in the documentation of TLinkable.

Parameters:
in  the list of data packages
sIdentifier  the string this item pack is saved under
bUnique  bool value whether the indentifiers have to be unique
Returns:
true means that everything was loaded correctly, otherwise this method will return false.
See also:
TLinkable

Reimplemented in TSubstanceHold.

TSubstanceSet& TSubstanceSet::operator= const TSubstanceSet &    Set2
 

Assignment operator: duplication of Sets is legal.

bool TSubstanceSet::operator== const TSubstanceSet &    Set2 const
 

Compare operator

const TSubstance* TSubstanceSet::operator[] const TSubstanceType   Type const
 

Access a specified type of substance directly (read mode).

Returns:
a const pointer to the substance if found, NULL if not found.
Parameters:
Type  a pointer to the substance type object.

bool TSubstanceSet::Remove const TSubstance   Subst,
const int4    iNum = 1,
const int4    iDenom = 1
 

Remove a specified substance from the set. If the Set does not contain enough substances to allow the removal of the amount given by Subst * iNum / iDenom the function returns false and no action is taken. If the Set contains enough substance, then it is removed and the function returns true.

Returns:
true if removal was done, false otherwise.
Parameters:
Subst  substance to be removed.
iNum  (default 1) multiplies Subst
iDenom  (default 1) divides Subst

bool TSubstanceSet::Remove const TSubstanceSet &    Set,
const int4    iNum = 1,
const int4    iDenom = 1
 

Remove is used to subtract sets. If the Set does not contain enough substances to allow the removal of the amount given by Set2 * iNum / iDenom the function returns false and no action is taken. If the Set contains enough substances, then they are removed and the function returns true.

Returns:
true if removal was done, false otherwise.
Parameters:
Set2  amount of substances to be removed.
iNum  (default 1) multiplies Set2.
iDenom  (default 1) divides Set2.

bool TSubstanceSet::save TDataPackageList   out,
const string &    sIdentifier,
bool    bUnique = true
const
 

With the method Save you can save a TSubstanceSet object from the data packages in the list. For more information look in the documentation of TLinkable.

Parameters:
in  the list of data packages
sIdentifier  the string this item pack is to be saved under
bUnique  bool value whether the indentifiers have to be unique
Returns:
true means that everything was saved correctly, otherwise this method will return false.
See also:
TLinkable

Reimplemented in TSubstanceHold.

TOSVal TSubstanceSet::TotalSpace const uint2    uCClass const
 

Determine the size "offered" by negative-sized substances (positive-sized are ignored).

Returns:
the opposite of the total size (i.e. a positive number) of negative-sized substances.
Parameters:
uCClass  cargo class to be examined.

Reimplemented in TSubstanceHold.

TOSVal TSubstanceSet::UsedSpace const uint2    uCClass const
 

Determine the size taken by all positive-sized substances (acts like "how much stuff is stored").

Returns:
the the total size (i.e. a positive number) of all positive-sized substances.
Parameters:
uCClass  cargo class to be examined.

Reimplemented in TSubstanceHold.


Friends And Related Function Documentation

ostream& operator<< ostream &    os,
const TSubstanceSet &    Set
[friend]
 

TSubstanceSet output function, provides stream-compatible output for TSubstanceSet objects. It writes a human-readable string representation of the Set object to the stream.

Returns:
the given stream.
Parameters:
os  output stream where string is written
Set  the TSubstanceSet object.


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