VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
DtFormation Class Reference

Instances of DtFormation are a list of DtFormationEntry objects which make up an aggregate formation.

Inheritance diagram for DtFormation:
Inheritance graph
[legend]

Public Types

typedef std::pair< DtVector, intPositionData
 
- Public Types inherited from DtReaderWriter
typedef std::vector
< DtSymbolString
aliasContainer
 
typedef std::vector
< DtSymbolString >::iterator 
aliasIter
 
typedef std::vector
< DtSymbolString >
::const_iterator 
aliasConstIter
 
typedef std::vector< DtFilename > SearchPaths
 
typedef std::pair
< DtSymbolString, DtString
DtVariableNameType
 
typedef DtReaderWriterFactory *(* DtReaderWriterFactoryCreatorFcn )()
 

Public Member Functions

 DtFormation ()
 
 DtFormation (const DtString &name, DtReaderWriterRegistry *const parentRegistry=0)
 
 DtFormation (const DtFormation &orig)
 
DtFormationoperator= (const DtFormation &orig)
 
virtual ~DtFormation ()
 
virtual void addPosition (int promotionId, int leaderPromotionId, const DtVector &positionOffset)
 
virtual void removeAndDeleteAll ()
 
virtual const DtFormationEntrygetFormationEntryForPromotionId (int) const
 
virtual DtFormationEntrygetFormationEntryForPromotionId (int)
 
virtual const DtFormationEntrygetFormationEntryForUnitIndex (int) const
 
virtual int promotionIdForIndex (const int index) const
 
virtual std::string subFormationForIndex (const int index) const
 
virtual std::list< DtVectorformationPositions (const int numPositions=0, int *leaderIndex=0) const
 
virtual std::list< DtVectorformationPositionsFromUnit (const int numPositions=0, int *leaderIndex=0) const
 
virtual std::vector< PositionDatapromotedPositions (const int numPositions=0) const
 
virtual std::vector< PositionDatapromotedPositionsFromUnit (const int numPositions=0) const
 
bool operator== (const DtFormation &) const
 
bool operator!= (const DtFormation &) const
 
virtual void addEntry (DtFormationEntry *entry)
 
virtual DtFormationEntrycreateAndAddFormationEntry ()
 
virtual bool isValid () const
 
virtual double standardSpacing () const
 
- Public Member Functions inherited from DtRwList
 DtRwList ()
 
 DtRwList (const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL)
 
 DtRwList (const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL)
 
virtual ~DtRwList ()
 
const DtRwListoperator= (const DtRwList &orig)
 
virtual DtListItem * add (DtReaderWriter *data)
 
virtual DtListItem * addWithAlternateName (DtReaderWriter *data, const DtString &name)
 
virtual DtListItem * addToStart (DtReaderWriter *data)
 
virtual DtListItem * addToEnd (DtReaderWriter *data)
 
virtual void * remove (DtReaderWriter *data, DtListItem *item)
 
virtual DtlObjPtr getLocalData (DtlObjPtr args)
 
virtual void getSelf (DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths=SearchPaths(), const DtVariableBindingsList &variableBindings=nullVariableReference())
 
virtual void getSelf (const DtEnvironmentSP, const DtEnvValueSP root, const SearchPaths &searchPaths=SearchPaths(), const DtVariableBindingsList &bindings=DtVariableBindingsList())
 
virtual DtListItem * addBefore (DtReaderWriter *data, DtReaderWriter *before)
 
virtual DtListItem * addAfter (DtReaderWriter *data, DtReaderWriter *after)
 
virtual void removeAll ()
 
virtual void reset ()
 
virtual const charreaderWriterType () const
 
bool operator== (const DtRwList &rhs) const
 
bool operator!= (const DtRwList &rhs) const
 
virtual void populateList (boost::function< void(DtReaderWriter *)> addFunction, DtEnvironmentSP env, DtEnvValueSP node, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &bindings)
 
virtual void populateListByType (boost::function< void(DtReaderWriter *)> addFunction, DtEnvironmentSP env, DtEnvValueSP node, const DtString &bindingType, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &bindings)
 
 DtRwList (const DtString &name, const DtRwList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
 
 DtRwList (const DtSymbolString &name, const DtRwList &orig, DtReaderWriterRegistry *parentRegistry=NULL)
 
virtual DtListItem * addBefore (DtReaderWriter *data, const DtString &before)
 
virtual DtListItem * addBefore (DtReaderWriter *data, const DtSymbolString &before)
 
virtual DtListItem * addAfter (DtReaderWriter *data, const DtString &after)
 
virtual DtListItem * addAfter (DtReaderWriter *data, const DtSymbolString &after)
 
virtual void putData (DtEnvironmentSP, DtEnvValueSP parent) const
 
virtual void getData (const DtEnvironmentSP, const DtEnvValueSP value, const DtReaderWriter::SearchPaths &searchPaths=DtReaderWriter::SearchPaths(), const DtVariableBindingsList &bindings=DtVariableBindingsList())
 
virtual const charxmlType () const
 
virtual std::set< DtStringsupportedXmlTypes () const
 
- Public Member Functions inherited from DtReaderWriter
 DtReaderWriter ()
 
 DtReaderWriter (const DtString &name, DtReaderWriterRegistry *parentRegistry=NULL, bool readonly=false)
 
 DtReaderWriter (const DtSymbolString &name, DtReaderWriterRegistry *parentRegistry=NULL, bool readonly=false)
 
 DtReaderWriter (const DtString &name, const DtReaderWriter &orig, DtReaderWriterRegistry *parentRegistry=NULL)
 
 DtReaderWriter (const DtSymbolString &name, const DtReaderWriter &orig, DtReaderWriterRegistry *parentRegistry=NULL)
 
 DtReaderWriter (const DtReaderWriter &, DtReaderWriterRegistry *parentRegistry=NULL)
 
const DtReaderWriteroperator= (const DtReaderWriter &orig)
 
bool operator== (const DtReaderWriter &) const
 
bool operator!= (const DtReaderWriter &rhs) const
 
virtual ~DtReaderWriter ()
 
virtual void putSelf (std::string &fp, int indentLevel=0, bool writeUnspecified=false, const DtFilename &path=DtFilename::nullFilename())
 
virtual void postPutSelf ()
 
virtual void prePutSelf ()
 
virtual void postGetSelf ()
 
virtual void preGetSelf ()
 
virtual void writeSelf (std::string &fp, int indentLevel=0, bool writeUnspecified=false, const DtFilename &path=DtFilename::nullFilename())
 
virtual DtSymbolString name () const
 
virtual void addAlias (const DtSymbolString &alias)
 
virtual void addAlias (const DtString &alias)
 
virtual bool hasAlias (const DtSymbolString &alias)
 
virtual const aliasContaineraliases () const
 
virtual void setReadonly (bool flag)
 
bool isReadonly () const
 
virtual int alignment () const
 
virtual bool variableIsBound () const
 
virtual void unbindVariable ()
 
virtual void setName (const DtString &)
 
virtual DtString prettyPrint () const
 
std::string debugText () const
 
virtual void bindVariables (DtVariableBindingsList variableBindings)
 
virtual std::list
< DtVariableNameType
unboundVariables () const
 
bool invalid () const
 
virtual bool hasChild (const DtReaderWriter *p) const
 
virtual bool hasVariableReference () const
 
virtual void bindLocalVariables (const DtVariableBindingsList &variableBindings)
 
virtual void recordUpdateTime () const
 
virtual bool changedSinceLastChecked ()
 
virtual bool peekChangedSinceLastChecked () const
 
virtual void putData (std::string &fp, int indentLevel=0)
 
virtual void setValueSpecified (bool specified, bool recurse=false)
 
virtual bool valueSpecified () const
 
virtual bool isVariableReference () const
 
virtual void setIsVariableReference (bool value)
 
virtual void clearAllVariableReferenceFlags ()
 
virtual DtSymbolString variableName () const
 
virtual void setVariableName (const DtSymbolString variableName)
 
virtual const DtReaderWriterdefaultRWValue () const
 
virtual DtReaderWriterdefaultRWValue ()
 
virtual void setDefaultRWValue (DtReaderWriter *)
 
virtual bool checkAndSetDefaultRWValue (DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths=SearchPaths(), const DtVariableBindingsList &variableBindings=nullVariableReference())
 
const DtReaderWriterRegistryregistry () const
 
DtReaderWriterRegistryregistry ()
 
virtual DtPropertyInterfaceproperty ()
 
virtual const DtPropertyInterfaceproperty () const
 
virtual DtString toXml () const
 
virtual DtRwVariableBindingsgenerateVariableBindings () const
 
virtual bool toXml (const DtFilename &) const
 
virtual bool fromXml (const DtString &)
 
virtual bool fromXmlFile (const DtFilename &)
 
virtual void putSelf (DtEnvironmentSP, DtEnvValueSP parent) const
 
virtual void putVariableReference (DtEnvironmentSP, DtEnvValueSP value) const
 
virtual void unrecognizedItem (const DtEnvironmentSP env, const DtEnvValueSP root, const SearchPaths &searchPaths, const DtVariableBindingsList &varBindings)
 
virtual void getVariableReference (DtEnvironmentSP, DtEnvValueSP value)
 

Protected Member Functions

virtual void computeAndSetStandardSpacing ()
 
virtual DtVector newFormationEntryOffset (const DtVector &lastOffset) const
 
virtual void removeEntry (DtFormationEntry *entry)
 
virtual void copyList (const DtFormation &orig)
 
virtual void emptyList ()
 
virtual DtlObjPtr getData (DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &variableBindings)
 
- Protected Member Functions inherited from DtRwList
virtual DtListItem * addBefore (DtReaderWriter *data, DtListItem *before)
 
virtual DtListItem * addAfter (DtReaderWriter *data, DtListItem *after)
 
- Protected Member Functions inherited from DtReaderWriter
virtual void bindToRwAsVariable (const DtReaderWriter *rw)
 

Protected Attributes

double myStandardSpacing
 
- Protected Attributes inherited from DtReaderWriter
const DtSymbolString myName
 
DtReaderWriterRegistry myRegistry
 
DtReaderWriterRegistrymyParentRegistry
 
bool myValueSpecified
 
bool myReadOnlyFlag
 
bool myIsVariableReference
 
DtSymbolString myVariableName
 
bool myVariableIsBound
 
DtReaderWritermyDefaultValue
 
aliasContainer myAliases
 
bool myInvalid
 
bool myChangedFlag
 

Additional Inherited Members

- Static Public Member Functions inherited from DtRwList
static const chartheXmlType ()
 
- Static Public Member Functions inherited from DtReaderWriter
static void putIndent (std::string &fp, int indentLevel)
 
static const
DtVariableBindingsList
nullVariableReference ()
 
static void setPostGetSelfCallback (DtGetSelfCallbackFcn fcn, void *usrData)
 
static void setPrePutSelfCallback (DtPutSelfCallbackFcn fcn, void *usrData)
 
static void setPutIndent (bool)
 
static bool putIndent ()
 
static const chartheXmlType ()
 
static const DtFilename & appPath ()
 
static void setFactoryCreatorFunction (DtReaderWriterFactoryCreatorFcn fcn)
 
static void createReaderWriterFactory ()
 
static void cleanupFactory ()
 
static DtReaderWriterFactoryfactory ()
 
static void setOutputStream (DtOutputStream *stream)
 
static DtOutputStream & outputStream ()
 
static DtReaderWritercreateFromXmlFile (const DtFilename &, bool createAsProperty=false)
 
static DtReaderWritercreateFromXml (const DtString &, bool createAsProperty=false)
 
static DtReaderWritercreateFromEnvironment (DtEnvironmentSP, bool createAsProperty=false)
 
static DtString getAttribute (DtEnvironmentSP env, const DtString &name, DtEnvValueSP root)
 
- Static Protected Attributes inherited from DtReaderWriter
static DtString theUnspecifiedValue
 
static DtGetSelfCallbackInfo thePostGetSelfCallback
 
static DtPutSelfCallbackInfo thePrePutSelfCallback
 
static const DtVariableBindingsList theEmptyVariableBindingsList
 
static bool theCreatorFcnSet
 
static DtReaderWriterFactorytheFactory
 
static
DtReaderWriterFactoryCreatorFcn 
theFactoryCreatorFcn
 
static bool thePutIndent
 
static DtOutputStream * theOutputStream
 

Member Typedef Documentation

typedef std::pair<DtVector, int> DtFormation::PositionData

This holds an offset vector for a formation position, and the unit index it corresponds to.

Constructor & Destructor Documentation

DtFormation::DtFormation ( )

default constructor

DtFormation::DtFormation ( const DtString name,
DtReaderWriterRegistry *const  parentRegistry = 0 
)

constructor

DtFormation::DtFormation ( const DtFormation orig)

copy constructor

virtual DtFormation::~DtFormation ( )
virtual

destructor

Member Function Documentation

DtFormation& DtFormation::operator= ( const DtFormation orig)

assignment operator

virtual void DtFormation::addPosition ( int  promotionId,
int  leaderPromotionId,
const DtVector positionOffset 
)
virtual

Add an entry to the formation.

Parameters
promotionIdIndicates relative 'importance' of position in the formation. 0 is the most important, and increasing values are less important. All positions in a formation have a unique promotion Id. starting with 0. There should be no gaps in promotionIds in a formation. For example, you should not have a formation consisting of 0, 1, 4, 5, 6 (the leaderPromotionId (in this case 2 and 3 are missing).
leaderPromotionIdPromotion id of the formation position this entry is to follow. For the overall leader (the promotionId that doesn't follow anyone else, this value should -1. positionOffset: Offset in body coordinates of the leader, at which an entity in this formation position should try to maintain.
virtual void DtFormation::removeAndDeleteAll ( )
virtual

Removes and deletes memory associated with all entries in the formation.

Reimplemented from DtRwList.

virtual const DtFormationEntry* DtFormation::getFormationEntryForPromotionId ( int  ) const
virtual
Returns
Formation where the promotionId matches the supplied id. If no entry exists, returns NULL
virtual DtFormationEntry* DtFormation::getFormationEntryForPromotionId ( int  )
virtual
virtual const DtFormationEntry* DtFormation::getFormationEntryForUnitIndex ( int  ) const
virtual
Parameters
Integerindex is the index in the formation list, which corresponds to the index in the unit definition.
Returns
The formation entry for the given index.
virtual int DtFormation::promotionIdForIndex ( const int  index) const
virtual

Provides the promotion ID associated with the given unit index (i.e. the DtFormation list index).

virtual std::string DtFormation::subFormationForIndex ( const int  index) const
virtual

Provides the subformation associated with the given unit index.

virtual std::list<DtVector> DtFormation::formationPositions ( const int  numPositions = 0,
int leaderIndex = 0 
) const
virtual
Returns
Computes a list of the offsets from each slot in the formation to the formation leader, i.e. the slot with the lowest promotion ID of those slots returned. (Normally the first slot in the returned list has promotion ID = 0, and this is what all other positions are relative to, but it would not be the case if the last formation slot had promotion ID 0.) Note that this is not the raw formation offset data, which is an offset to the immediate leader.
Parameters
numPositionsOffsets for the first numPositions are provided. If numPositions is greater than the number of slots defined in the formation, additional positions will be computed. If numPositions is less than the number of nominal formation positions, it is possible that none of the positions returned will correspond to promotion ID 0 (because promotion ID 0 is at the bottom of the formation). However, the position corresponding to the lowest promotionID of those positions returns will have a returned position of (0,0,0), and the other position offsets returned will be relative to that position. If this parameter is omitted, then all of the positions in the formation are returned.
leaderIndexis the index into the returned list of the leader of this set of positions, i.e. the position with value (0,0,0). (If the formation is defined with entries in promotion-ID order, this value will be 0.)
virtual std::list<DtVector> DtFormation::formationPositionsFromUnit ( const int  numPositions = 0,
int leaderIndex = 0 
) const
virtual

Computes a list of the offsets from each slot in the formation to the unit center. This function is useful for placing the subordinates of a unit given the unit position. See formationPositions for a description of parameters.

virtual std::vector<PositionData> DtFormation::promotedPositions ( const int  numPositions = 0) const
virtual

This function provides formation position info in formation promotion ID order. This is useful if the caller wants to put subordinates (possibly, fewer than in a full strength unit) into the most important slots of the formation. Since a formation definition might not have promotion IDs in the same order as formation entries (formation slots), getting the first N positions using formationPositions() may not yield the first N promotion IDs, and might not include promotion ID 0.

Parameters
numPositionsThe number of positions to provide. May be more or less than the number of positions defined in the formation. If this parameter is omitted, then all of the positions in the formation are returned.
Returns
A list of pairs where each pair contains an offset from the formation leader and an index into the unit's subordinates list (= index into the formation definition) corresponding to that offset.
The first element in the returned vector corresponds to promotion ID 0, and will have and offset (0,0,0). The offsets in the following elements will be from the first element.
The indices may be useful to help the caller assign the current subordinates to formation slots. For example, if unit index 0 is the unit leader, and formation slot 0 is point/recon, then maybe position 1 or 2 corresponds to unit index 0, and the caller can make that assignment instead of giving slot 0 to the leader.
virtual std::vector<PositionData> DtFormation::promotedPositionsFromUnit ( const int  numPositions = 0) const
virtual

This function is similar to promotedPositions() except that the offsets are from the center of the unit, where the unit is defined by these numPositions.

bool DtFormation::operator== ( const DtFormation ) const
bool DtFormation::operator!= ( const DtFormation ) const
virtual void DtFormation::addEntry ( DtFormationEntry entry)
virtual

Adds new entry to ourself.

virtual DtFormationEntry* DtFormation::createAndAddFormationEntry ( )
virtual

Creates and adds a new DtFormationEntry to the table. If it is the first node, will be at 0, 0, 0. If a node other than the first node, will call newFormationEntryOffset() to return the new offset. The node will follow the last node in the formation.

Returns
The formation entry that was created. This function already adds it to the formation, so the caller does not have to do that.
virtual bool DtFormation::isValid ( ) const
virtual

Makes sure that the input formation has one promotion ID per entry, that it has an entry with promotion ID 0, and that it has consecutive promotion IDs up to an including the formation size. Returns true if this is the case.

virtual double DtFormation::standardSpacing ( ) const
virtual

Accessor for myStandardSpacing. No setter, since this value is a function of formation entry contents. This is the standard spacing of the formation. This is equal to the offset distance from the position at promotion ID 0 to the position that has 0 as the leader (if there is more than one, the closest is used). When the formation spacings are requested in the formationSpacing functions, the returned values will be scaled by desired spacing / standard spacing. If the actual spacing is < 1.0, or there is no formation entry (yet) with 0 as the leader, the spacing value is 1.0.

virtual void DtFormation::computeAndSetStandardSpacing ( )
protectedvirtual

Checks existing formation entries and finds the distance between the entry at promotion ID 0 and its closest immediate follower. Sets this value into myStandardSpacing.

virtual DtVector DtFormation::newFormationEntryOffset ( const DtVector lastOffset) const
protectedvirtual

Returns a new formation entry offset. If the first node, returns 0, 0, 0; else if only the second node, returns -10, 0, 0; else returns the lastOffset.

virtual void DtFormation::removeEntry ( DtFormationEntry entry)
protectedvirtual

Removes and deletes the entry.

virtual void DtFormation::copyList ( const DtFormation orig)
protectedvirtual
virtual void DtFormation::emptyList ( )
protectedvirtual

Used by the destructor. It removes and DELETES all formation entries on the list.

virtual DtlObjPtr DtFormation::getData ( DtlObjPtr  args,
const DtReaderWriter::SearchPaths searchPaths,
const DtVariableBindingsList variableBindings 
)
protectedvirtual

Constructs a DtFormationEntry item, and then retrieves it from the stream.

Implements DtRwList.

Member Data Documentation

double DtFormation::myStandardSpacing
protected

Standard spacing (between positions) of this formation.


The documentation for this class was generated from the following file:

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)