WSF
WsfVariableBase Class Reference

#include <WsfVariable.hpp>

Inheritance diagram for WsfVariableBase:

Public Member Functions

 WsfVariableBase ()
bool HasDefaultValue () const
 Has a default value been defined for a reference.
bool IsReference () const
 Is the variable a reference to a script variable?

Protected Member Functions

bool DefaultOptionPresent (UtInput &aInput)
 Determine if the '/default' option is present.
std::string ObjectName (WsfComponent *aObjectPtr)
 Return the name of the object for messages.
bool ReadReference (UtInput &aInput)
bool ResolveReference (const std::string &aVariableName, WsfComponent *aObjectPtr, WsfScriptContext *aContextPtr, const UtScriptData *&aRefValuePtr, WsfScriptContext &aGlobalContext)

Routines for type 'WsfStringId'

WsfStringId mRefVarNameId
 The name (ID) of the referenced variable. It is less than zero if the variable is not a reference.
bool mHasDefaultValue
 'true' if the '/default' option was provided
bool Initialize (const std::string &aName, WsfComponent *aObjectPtr, WsfScriptContext *aContextPtr, WsfStringId &aValue, WsfScriptContext &aGlobalContext)
void ReadValue (UtInput &aInput, WsfStringId &aValue)

Routines for type 'double'

bool Initialize (const std::string &aName, WsfComponent *aObjectPtr, WsfScriptContext *aContextPtr, double &aValue, WsfScriptContext &aGlobalContext)
void ReadValue (UtInput &aInput, double &aValue)
void ReadValueOfType (UtInput &aInput, UtInput::ValueType aType, double &aValue)

Routines for type 'float'

bool Initialize (const std::string &aName, WsfComponent *aObjectPtr, WsfScriptContext *aContextPtr, float &aValue, WsfScriptContext &aGlobalContext)
void ReadValue (UtInput &aInput, float &aValue)
void ReadValueOfType (UtInput &aInput, UtInput::ValueType aType, float &aValue)

Routines for type 'int'

bool Initialize (const std::string &aName, WsfComponent *aObjectPtr, WsfScriptContext *aContextPtr, int &aValue, WsfScriptContext &aGlobalContext)
void ReadValue (UtInput &aInput, int &aValue)
void ReadValueOfType (UtInput &aInput, UtInput::ValueType aType, int &aValue)

Routines for type 'bool'

bool Initialize (const std::string &aName, WsfComponent *aObjectPtr, WsfScriptContext *aContextPtr, bool &aValue, WsfScriptContext &aGlobalContext)
void ReadValue (UtInput &aInput, bool &aValue)

Routines for type 'std::string'

bool Initialize (const std::string &aName, WsfComponent *aObjectPtr, WsfScriptContext *aContextPtr, std::string &aValue, WsfScriptContext &aGlobalContext)
void ReadValue (UtInput &aInput, std::string &aValue)

Detailed Description

A class which supports defining a variable that can either be a fixed value or a reference to a script variable.

This class is defined so that only minimal changes need to be made to the code to replace a simple scalar variable with one that can get its value from a script variable.

The base class for a variable. This contains:

  • attributes that are not dependent on the type of the variable.
  • type-specific methods to read, initialize and access the variable.

Constructor & Destructor Documentation

◆ WsfVariableBase()

Member Function Documentation

◆ DefaultOptionPresent()

bool WsfVariableBase::DefaultOptionPresent ( UtInput & aInput)
protected

Determine if the '/default' option is present.

References mHasDefaultValue.

Referenced by ReadValue(), ReadValue(), ReadValue(), ReadValue(), ReadValue(), ReadValue(), ReadValueOfType(), ReadValueOfType(), and ReadValueOfType().

◆ HasDefaultValue()

bool WsfVariableBase::HasDefaultValue ( ) const
inline

◆ Initialize() [1/6]

bool WsfVariableBase::Initialize ( const std::string & aName,
WsfComponent * aObjectPtr,
WsfScriptContext * aContextPtr,
bool & aValue,
WsfScriptContext & aGlobalContext )
protected

References ok, and ResolveReference().

◆ Initialize() [2/6]

bool WsfVariableBase::Initialize ( const std::string & aName,
WsfComponent * aObjectPtr,
WsfScriptContext * aContextPtr,
double & aValue,
WsfScriptContext & aGlobalContext )
protected

◆ Initialize() [3/6]

bool WsfVariableBase::Initialize ( const std::string & aName,
WsfComponent * aObjectPtr,
WsfScriptContext * aContextPtr,
float & aValue,
WsfScriptContext & aGlobalContext )
protected

References ok, and ResolveReference().

◆ Initialize() [4/6]

bool WsfVariableBase::Initialize ( const std::string & aName,
WsfComponent * aObjectPtr,
WsfScriptContext * aContextPtr,
int & aValue,
WsfScriptContext & aGlobalContext )
protected

References ok, and ResolveReference().

◆ Initialize() [5/6]

bool WsfVariableBase::Initialize ( const std::string & aName,
WsfComponent * aObjectPtr,
WsfScriptContext * aContextPtr,
std::string & aValue,
WsfScriptContext & aGlobalContext )
protected

References ok, and ResolveReference().

◆ Initialize() [6/6]

bool WsfVariableBase::Initialize ( const std::string & aName,
WsfComponent * aObjectPtr,
WsfScriptContext * aContextPtr,
WsfStringId & aValue,
WsfScriptContext & aGlobalContext )
protected

References ok, and ResolveReference().

◆ IsReference()

bool WsfVariableBase::IsReference ( ) const
inline

◆ ObjectName()

std::string WsfVariableBase::ObjectName ( WsfComponent * aObjectPtr)
protected

◆ ReadReference()

bool WsfVariableBase::ReadReference ( UtInput & aInput)
protected

Read a potential reference.

This reads the next item from the input stream, and if it is the start of reference, extract the name of the referenced script variable and any other optional data. If the next item is not a reference, the item is pushed back on the input stream for processing by the caller.

Returns
'true' if the input was a variable reference. 'false' is returned if it is not a variable reference, in which case the caller should perform a 'ReadValue(OfType)' to read the value.

References mRefVarNameId.

Referenced by ReadValue(), ReadValue(), ReadValue(), ReadValue(), ReadValue(), ReadValue(), ReadValueOfType(), ReadValueOfType(), and ReadValueOfType().

◆ ReadValue() [1/6]

void WsfVariableBase::ReadValue ( UtInput & aInput,
bool & aValue )
protected

◆ ReadValue() [2/6]

void WsfVariableBase::ReadValue ( UtInput & aInput,
double & aValue )
protected

◆ ReadValue() [3/6]

void WsfVariableBase::ReadValue ( UtInput & aInput,
float & aValue )
protected

◆ ReadValue() [4/6]

void WsfVariableBase::ReadValue ( UtInput & aInput,
int & aValue )
protected

◆ ReadValue() [5/6]

void WsfVariableBase::ReadValue ( UtInput & aInput,
std::string & aValue )
protected

◆ ReadValue() [6/6]

void WsfVariableBase::ReadValue ( UtInput & aInput,
WsfStringId & aValue )
protected

◆ ReadValueOfType() [1/3]

void WsfVariableBase::ReadValueOfType ( UtInput & aInput,
UtInput::ValueType aType,
double & aValue )
protected

◆ ReadValueOfType() [2/3]

void WsfVariableBase::ReadValueOfType ( UtInput & aInput,
UtInput::ValueType aType,
float & aValue )
protected

◆ ReadValueOfType() [3/3]

void WsfVariableBase::ReadValueOfType ( UtInput & aInput,
UtInput::ValueType aType,
int & aValue )
protected

◆ ResolveReference()

bool WsfVariableBase::ResolveReference ( const std::string & aVariableName,
WsfComponent * aObjectPtr,
WsfScriptContext * aContextPtr,
const UtScriptData *& aRefValuePtr,
WsfScriptContext & aGlobalContext )
protected

If the variable is a reference, determine the script context and index of the reference.

Parameters
aVariableNameThe name of the variable as known by the user (for system log/error output)
aObjectPtrThe name of the object containing the variable (for system log/error output)
aContextPtrThe context from which to start searching to satisfy a reference.
aRefValuePtr[output] The script data object that points to the resolved script variable. This will be 0 if the variable is not a reference or if the reference could not be satisfied.
aGlobalContextThe script manager
Returns
'true' if the variable is a reference and it was successfully resolved, or if the variable was not a reference. 'false' is returned if the variable is a reference and it cannot be resolved.

References WsfScriptContext::GetContext(), WsfScriptContext::GetPLATFORM(), WsfScriptContext::GetPROCESSOR(), WsfScriptContext::GetSCENARIO(), WsfScenario::GetSystemLog(), HasDefaultValue(), mRefVarNameId, ObjectName(), and WsfSystemLog::WriteLogEntry().

Referenced by Initialize(), Initialize(), Initialize(), Initialize(), Initialize(), and Initialize().

Member Data Documentation

◆ mHasDefaultValue

◆ mRefVarNameId

WsfStringId WsfVariableBase::mRefVarNameId
protected

The name (ID) of the referenced variable. It is less than zero if the variable is not a reference.

Referenced by IsReference(), WsfVariable< T >::operator+=(), WsfVariable< T >::operator-=(), WsfVariable< T >::operator=(), WsfVariable< T >::operator=(), ReadReference(), ResolveReference(), and WsfVariableBase().


The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved