VR-Forces 4.1 Class Documentation
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
DtScriptInterface Class Reference

This class is a two-way interface between the script language and its parent controller. More...

Inheritance diagram for DtScriptInterface:
Inheritance graph
[legend]

Public Member Functions

virtual ~DtScriptInterface ()
virtual bool invokeInit ()=0
virtual void invokeTick ()=0
 This will be called by the parent to invoke the script tick.
virtual bool loadScript ()=0
 This will be called by the parent to let the interface know when to load the script.
virtual DtString type () const =0
 Script engine type.
virtual void setTaskId (int taskId)
virtual int taskId () const
virtual void setScriptId (const DtString &scriptId)
virtual const DtStringscriptId () const
virtual void setScriptPath (const DtFilename &scriptPath)
virtual const DtFilename & scriptPath () const
virtual void setParent (DtScriptMultiTaskController *parent)
 Sets the parent of this object.
virtual
DtScriptMultiTaskController
parent () const
virtual void setEntity (DtVrfObject *entity)
virtual DtVrfObjectentity () const
virtual void init ()
virtual void setTaskVariables (const DtRwVariableBindings &variables)
virtual const
DtRwVariableBindings
taskVariables () const
virtual bool updateTaskVariables ()
virtual void processScenarioSave (DtRwVariableBindings *saveState)=0
 Called when the scenario is saved.
virtual bool processScenarioLoad (const DtRwVariableBindings *loadState)=0
 Called when the scenario is loaded.
virtual void processClearForReuse ()
 This function should be overridden by the inheritor to clear out any task specific variables.
virtual void setTaskStarting (bool v)
virtual bool taskStarting () const
double scriptGetExerciseTime ()
 Methods that are available for any script to use.
double scriptGetTimeOfDay ()
 Methods that are available for any script to use.
double scriptGetWindSpeed ()
 Returns wind speed in meters/second.
double scriptGetWindDirection ()
 Returns wind direction in radians.
DtScriptVrfObject scriptGetVrfObjectByName (const std::string name)
 Methods that are available for any script to use.
void printError (const std::string message)
 Methods that are available for any script to use.
void printWarn (const std::string message)
 Methods that are available for any script to use.
void printInfo (const std::string message)
 Methods that are available for any script to use.
void printVerbose (const std::string message)
 Methods that are available for any script to use.
void printDebug (const std::string message)
 Methods that are available for any script to use.
bool entityTypeMatches (const std::string &, const std::string &)
 Methods that are available for any script to use.
void setTickPeriod (double)
 Tick management. Will store information in PSR of controller only.
double getTerrainAltitude (const double lat, const double lon, bool &dataAvailable, std::string &surface) const
 Gets the terrain height at the given location.
bool doesChordHitTerrain (const DtLocation3D &pt1, const DtLocation3D &pt2, bool &dataAvailableart) const
 Determines if the chord formed by (point1, point2) intersects the terrain.
virtual DtLocation3D findClosestPointToRoad (const DtLocation3D &point, double searchRadius, bool &dataAvailable, bool &success) const
 Methods that are available for any script to use.
std::string getForceName (int forceType)
 Methods that are available for any script to use.
bool forcesHostile (std::string force1, std::string force2)
 Methods that are available for any script to use.

Protected Member Functions

 DtScriptInterface ()
 DtScriptInterface (const DtScriptInterface &other)
DtScriptInterfaceoperator= (const DtScriptInterface &other)
virtual void scriptTaskComplete (bool success)
 This function is meant to be called by the script itself or the script object to tell the parent that the script task is complete.
virtual bool scriptText (std::string &text)
 Returns the script text as a string and a bool on whether the text is valid or not.
virtual const DtReaderWritergetTaskParam (const DtString &paramName)
virtual bool getParamMetaDataType (const DtString &paramName, DtString &typeName)

Protected Attributes

int myTaskId
DtString myScriptId
DtFilename myScriptPath
DtVrfObjectmyEntity
DtRwVariableBindings myTaskVariables
DtScriptMultiTaskControllermyParent
bool myTaskStarting
 Indicates that a new task is starting, and should be initialized on the next tick.

Detailed Description

This class is a two-way interface between the script language and its parent controller.

There are functions that either the parent controller will call on the script interface (such as tick() ) and there will be functions the script interface will call on the parent controller to inform the parent of status updates and for data access.

Constructor & Destructor Documentation

DtScriptInterface::DtScriptInterface ( )
protected
DtScriptInterface::DtScriptInterface ( const DtScriptInterface other)
protected
virtual DtScriptInterface::~DtScriptInterface ( )
virtual

Member Function Documentation

DtScriptInterface& DtScriptInterface::operator= ( const DtScriptInterface other)
protected
virtual bool DtScriptInterface::invokeInit ( )
pure virtual

Implemented in DtLuaScriptInterfaceImpl.

virtual void DtScriptInterface::invokeTick ( )
pure virtual

This will be called by the parent to invoke the script tick.

Implemented in DtLuaScriptInterfaceImpl.

virtual bool DtScriptInterface::loadScript ( )
pure virtual

This will be called by the parent to let the interface know when to load the script.

Implemented in DtLuaScriptInterfaceImpl.

virtual DtString DtScriptInterface::type ( ) const
pure virtual

Script engine type.

Implemented in DtLuaScriptInterfaceImpl.

virtual void DtScriptInterface::setTaskId ( int  taskId)
inlinevirtual
virtual int DtScriptInterface::taskId ( ) const
inlinevirtual
virtual void DtScriptInterface::setScriptId ( const DtString scriptId)
inlinevirtual
virtual const DtString& DtScriptInterface::scriptId ( ) const
inlinevirtual
virtual void DtScriptInterface::setScriptPath ( const DtFilename &  scriptPath)
inlinevirtual
virtual const DtFilename& DtScriptInterface::scriptPath ( ) const
inlinevirtual
virtual void DtScriptInterface::setParent ( DtScriptMultiTaskController parent)
inlinevirtual

Sets the parent of this object.

It is assumed that the parent will take care of deleting itself so this class should NOT do that.

virtual DtScriptMultiTaskController* DtScriptInterface::parent ( ) const
inlinevirtual
virtual void DtScriptInterface::setEntity ( DtVrfObject entity)
inlinevirtual
virtual DtVrfObject* DtScriptInterface::entity ( ) const
inlinevirtual
virtual void DtScriptInterface::init ( )
inlinevirtual

Reimplemented in DtLuaScriptInterfaceImpl.

virtual void DtScriptInterface::setTaskVariables ( const DtRwVariableBindings variables)
inlinevirtual
virtual const DtRwVariableBindings& DtScriptInterface::taskVariables ( ) const
inlinevirtual
virtual bool DtScriptInterface::updateTaskVariables ( )
virtual
virtual void DtScriptInterface::processScenarioSave ( DtRwVariableBindings saveState)
pure virtual

Called when the scenario is saved.

The stateState pointer may not be valid, in which case something went wrong with saving

Implemented in DtLuaScriptInterfaceImpl.

virtual bool DtScriptInterface::processScenarioLoad ( const DtRwVariableBindings loadState)
pure virtual

Called when the scenario is loaded.

The load state pointer may not be valid, which does not indicate that the scenario loaded incorrectly, but that the data for this particular script interface was either corrupt or did not exist.

Implemented in DtLuaScriptInterfaceImpl.

virtual void DtScriptInterface::processClearForReuse ( )
virtual

This function should be overridden by the inheritor to clear out any task specific variables.

This version should probably be called last if you override it rather than first to take care of things before these things get cleared.

Reimplemented in DtLuaScriptInterfaceImpl.

virtual void DtScriptInterface::setTaskStarting ( bool  v)
virtual
virtual bool DtScriptInterface::taskStarting ( ) const
virtual
double DtScriptInterface::scriptGetExerciseTime ( )

Methods that are available for any script to use.

double DtScriptInterface::scriptGetTimeOfDay ( )

Methods that are available for any script to use.

double DtScriptInterface::scriptGetWindSpeed ( )

Returns wind speed in meters/second.

double DtScriptInterface::scriptGetWindDirection ( )

Returns wind direction in radians.

DtScriptVrfObject DtScriptInterface::scriptGetVrfObjectByName ( const std::string  name)

Methods that are available for any script to use.

void DtScriptInterface::printError ( const std::string  message)

Methods that are available for any script to use.

void DtScriptInterface::printWarn ( const std::string  message)

Methods that are available for any script to use.

void DtScriptInterface::printInfo ( const std::string  message)

Methods that are available for any script to use.

void DtScriptInterface::printVerbose ( const std::string  message)

Methods that are available for any script to use.

void DtScriptInterface::printDebug ( const std::string  message)

Methods that are available for any script to use.

bool DtScriptInterface::entityTypeMatches ( const std::string &  ,
const std::string &   
)

Methods that are available for any script to use.

void DtScriptInterface::setTickPeriod ( double  )

Tick management. Will store information in PSR of controller only.

double DtScriptInterface::getTerrainAltitude ( const double  lat,
const double  lon,
bool dataAvailable,
std::string &  surface 
) const

Gets the terrain height at the given location.

This function always makes a non-blocking call to the terrain interface (see documentation for DtTerrainInterface), even if dataAvailable is null; if dataAvailable is not null, then it is filled in with the result from the terrainInterface call indicating whether the altitude data is valid.

Note that in the Lua interface, dataAvailable and surface are pure_out_values, meaning that the arguments are not included in the function call, but are provided as additional return values of the function. E.g. use: height, valid, surfaceType = getTerrainAltitude(lat, lon)

bool DtScriptInterface::doesChordHitTerrain ( const DtLocation3D pt1,
const DtLocation3D pt2,
bool dataAvailableart 
) const

Determines if the chord formed by (point1, point2) intersects the terrain.

The ground surface and features are considered. Returns a boolean indicating whether the LOS is blocked, and provides a flag indicating if the result is valid (the terrain data was available). This function always makes a non-blocking call to the terrain interface (see documentation for DtTerrainInterface), even if dataAvailable passed in is null.

virtual DtLocation3D DtScriptInterface::findClosestPointToRoad ( const DtLocation3D point,
double  searchRadius,
bool dataAvailable,
bool success 
) const
virtual

Methods that are available for any script to use.

std::string DtScriptInterface::getForceName ( int  forceType)

Methods that are available for any script to use.

bool DtScriptInterface::forcesHostile ( std::string  force1,
std::string  force2 
)

Methods that are available for any script to use.

virtual void DtScriptInterface::scriptTaskComplete ( bool  success)
protectedvirtual

This function is meant to be called by the script itself or the script object to tell the parent that the script task is complete.

This call will mark this object for deletion.

virtual bool DtScriptInterface::scriptText ( std::string &  text)
protectedvirtual

Returns the script text as a string and a bool on whether the text is valid or not.

virtual const DtReaderWriter* DtScriptInterface::getTaskParam ( const DtString paramName)
protectedvirtual
virtual bool DtScriptInterface::getParamMetaDataType ( const DtString paramName,
DtString typeName 
)
protectedvirtual

Member Data Documentation

int DtScriptInterface::myTaskId
protected
DtString DtScriptInterface::myScriptId
protected
DtFilename DtScriptInterface::myScriptPath
protected
DtVrfObject* DtScriptInterface::myEntity
protected
DtRwVariableBindings DtScriptInterface::myTaskVariables
protected
DtScriptMultiTaskController* DtScriptInterface::myParent
protected
bool DtScriptInterface::myTaskStarting
protected

Indicates that a new task is starting, and should be initialized on the next tick.


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

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)