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

TStellarObject Class Reference

Base class for all stellar objects. More...

#include <stobj.h>

Inheritance diagram for TStellarObject:

Inheritance graph
[legend]
Collaboration diagram for TStellarObject:

Collaboration graph
[legend]
List of all members.

Public Methods

 TStellarObject ()
 TStellarObject (const TPoint &Point)
virtual ~TStellarObject ()
void addWaypoint (const TWaypoint &waypoint)
void Attach (TStellarObject *pDest)
virtual bool canPerformAction (const TAction &action)
virtual bool canBeObjectInAction (const TAction &action)
void Detach ()
TGalaxygetGalaxy () const
const string & getName () const
const TPointgetPos () const
virtual int2 getType () const
virtual const string & getTypeName () const
const TWaypointListgetWaypointList () const
bool hasWaypoint () const
bool insertWaypoint (const TWaypoint &waypoint, int2 insertPosition)
virtual bool load (TDataPackageList *in)
bool operator== (const TStellarObject &Src) const
bool operator< (const TStellarObject &Src) const
bool removeWaypoint (int2 waypointNumber)
bool replaceWaypoint (const TWaypoint &Waypoint, int2 waypointNumber)
virtual bool save (TDataPackageList *out) const
void setName (const string &sName)
void setPos (const TPoint &Pos)
ostream & Write (ostream &Stream) const

Private Methods

void setParent (TGalaxy *pGalaxy)

Private Attributes

TLink< TGalaxyGalaxy
TWaypoint WP
TWaypointList fWaypointList
double dSpeed
string sName

Friends

class TGalaxy

Detailed Description

Base class for all stellar objects.

Author:
Jai Shaw <Jai@towersoft.com.au>, Marco Krohn <marco.krohn@gmx.de>
Version:
Id:
stobj.h,v 1.28 2002/06/07 00:39:55 mkrohn5 Exp
See also:
TStellarObjectList, TActionObject
TStellarObject is a base class for all kinds of stellar objects, such as fleets, planets and minefields. All stellar objects have a name, a position in space and belong to a galaxy. A stellar object is derived from TActionObject and therefore can execute actions.


Constructor & Destructor Documentation

virtual TStellarObject::~TStellarObject   [virtual]
 

At the moment this method sends only a message to the log file.


Member Function Documentation

void TStellarObject::addWaypoint const TWaypoint   waypoint
 

Adds a waypoint to the waypoint list fWaypointList.

Parameters:
The  new waypoint.

void TStellarObject::Attach TStellarObject *    pDest
 

Attaches the stellar object A to another one B. This means that A will move together with object B. To be more precise: stellar object B determines the position of the object A. Note: the method will attach the object to Dest without looking at the current state of the object (e.g. if it is already attached). Also this means that the object is at once at the same position as pDest.

Parameters:
Dest  The stellar object B.
See also:
Detach

virtual bool TStellarObject::canBeObjectInAction const TAction   action [virtual]
 

Overload of TActionObject method to filter action types.

Reimplemented from TActionObject.

Reimplemented in TFleet.

virtual bool TStellarObject::canPerformAction const TAction   action [virtual]
 

Overload of TActionObject method to filter action types.

Reimplemented from TActionObject.

Reimplemented in TFleet.

void TStellarObject::Detach  
 

Detaches the stellar object from another object.

See also:
Attach

TGalaxy* TStellarObject::getGalaxy   const
 

Returns:
The galaxy the stellar object belongs to.

const string& TStellarObject::getName   const
 

Returns:
The name of the stellar object.

const TPoint& TStellarObject::getPos   const
 

Returns:
The position of the stellar object.

virtual int2 TStellarObject::getType   const [virtual]
 

Returns:
The type of the stellar object--e.g. TType::TFleet.
See also:
TType

Reimplemented from TLinkable.

Reimplemented in TFleet, and TSystem.

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

Returns:
The name of the class: "TStellarObject".

Reimplemented from TLinkable.

Reimplemented in TFleet, and TSystem.

const TWaypointList* TStellarObject::getWaypointList   const
 

FIXME, do we need a method like TWaypoint& getWaypoint( int2 waypointNumber ) const?

Returns:
The waypoint list fWaypointList.

bool TStellarObject::hasWaypoint   const
 

Returns:
true if there are waypoints left, false if the list of waypoints (fWaypointList) is empty.

bool TStellarObject::insertWaypoint const TWaypoint   waypoint,
int2    insertPosition
 

With the method insertWaypoint you can insert a waypoint in the waypoint list. The posistion in the waypoint list is identified with the number of the waypoint in the list, behind which the new waypoint shall be inserted.

Example: A waypoint to be inserted at posistion 0 is always inserted at the head of the list, A waypoint to be inserted at position 1, is inserted after the head of the list, if there is already a head. Else the waypoint isn't inserted. If a list contains 3 waypoints, and you want to add a waypoint at position 3, the waypoint is inserted as tail and the list contains then 4 waypoints.

Parameters:
waypoint  the waypoint to be inserted
insertPosistion  the posistion, after which the waypoint is to be inserted
Returns:
true, if the waypoint is inserted successfully, false, if the list is to short to have the wanted posistion

virtual bool TStellarObject::load TDataPackageList   in [virtual]
 

Loads a TStellarObject. Note that classes that are derived from this class must call TStellarObject::Load explicitly to load the data correctly. After loading the stellar object it will automatically inform TGalaxy (so that TGalaxy adds this object to its list).

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

Reimplemented from TActionObject.

Reimplemented in TFleet, and TSystem.

bool TStellarObject::operator< const TStellarObject &    Src const
 

To compare values for sorting.

Parameters:
src  Stellar Object to compare against.
Returns:
true if object ID is less than source objectID otherwise false.

bool TStellarObject::operator== const TStellarObject &    Src const
 

Compare stellar objects.

Parameters:
src  Stellar Object to compare against.
Returns:
true if object ID match otherwise false.

bool TStellarObject::removeWaypoint int2    waypointNumber
 

With removeWaypoint you can remove a waypoint from the waypoint list of the stellar object. The waypoint is identified with its number in the list. The first waypoint has the number 0. If the there is no waypoint with this number, the method returns false, else it returns true after removing the waypoint from the list.

Parameters:
waypointNumber  the number of the waypoint to be removed
Returns:
@true, if the waypoint was removed successfully, false, if there wasn't any waypoint with this number

bool TStellarObject::replaceWaypoint const TWaypoint   Waypoint,
int2    waypointNumber
 

With replaceWaypoint you can replace a waypoint in the waypoint list of the stellar object with another waypoint. The waypoint to be replaced is identified with its number in the list. The first waypoint has the number 0. If the there is no waypoint with this number, the method returns false, else it returns true after replacing the waypoint in the list withe one given as parameter.

Parameters:
waypoint  the waypoint to be inserted
waypointNumber  the number of the waypoint to be repaced
Returns:
true, if the waypoint was replaced successfully, false, if there wasn't any waypoint with this number

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

Saves a TStellarObject by adding the data packages to the list. Note that classes that are derived from this class must call TStellarObject::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 from TActionObject.

Reimplemented in TFleet, and TSystem.

void TStellarObject::setName const string &    sName
 

Sets the name of the stellar object.

Parameters:
sName  The new name of the object.

void TStellarObject::setParent TGalaxy   pGalaxy [private]
 

Sets the Galaxy variable and transforms the point so that it is guranteed that the point is within the boundaries of the new galaxy. Note that this method will not (apart from the above) trigger any further actions in TGalaxy for example this will not inform the old galaxy that the parent changed. This method is called by TGalaxy::Add.

Parameters:
pGalaxy  The new parent of this object.
See also:
TGalaxy::Transform

void TStellarObject::setPos const TPoint   Pos
 

Sets the position of the stellar object in space. Note: the method calls TGalaxy::Transform to ensure that the position is within the galaxy.

Parameters:
Pos  The position in space.

ostream& TStellarObject::Write ostream &    Stream const
 

Writes the class TStellarObject to a stream using the following format: "ID, Name, Pos".

Parameters:
Stream  The (old) output stream.
Returns:
The (new) stream.


Member Data Documentation

double TStellarObject::dSpeed [private]
 

The speed of the stellar object.

TWaypointList TStellarObject::fWaypointList [private]
 

The list of waypoints. The auto delete mode is set to true in the constructor.

TLink<TGalaxy> TStellarObject::Galaxy [private]
 

All stellar objects must belong to a galaxy. This link points to the current galaxy. Only jumps between galaxies may change this link.

string TStellarObject::sName [private]
 

The name of the stellar object

TWaypoint TStellarObject::WP [private]
 

The current "waypoint" of the fleet (this may be another stellar object).


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