LTAPI
API to access LiveTraffic's aircraft information
Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
LTDataRef Class Reference

Represents a dataRef and covers late binding. More...

#include <LTAPI.h>

Public Member Functions

 LTDataRef (std::string _sDataRef)
 Constructor, set the dataRef's name. More...
 
bool needsInit () const
 
bool isValid ()
 Found the dataRef and it contains formats we can work with? More...
 
bool FindDataRef ()
 Finds the dataRef (and would try again and again, no matter what bValid says) More...
 
XPLMDataTypeID getDataRefTypes () const
 Get types supported by the dataRef. More...
 
bool hasInt () const
 Is int a supported dataRef type? More...
 
bool hasFloat () const
 Is float a supported dataRef type? More...
 
int getInt ()
 Get dataRef's integer value. Silently returns 0 if dataRef doesn't exist. More...
 
float getFloat ()
 Get dataRef's float value. Silently returns 0.0f if dataRef doesn't exist. More...
 
bool getBool ()
 Gets dataRef's integer value and returns if it is not zero. More...
 
int getData (void *pOut, int inOffset, int inMaxBytes)
 Gets dataRef's binary data. More...
 
void set (int i)
 Writes an integer value to the dataRef. More...
 
void set (float f)
 Writes a float vlue to the dataRef. More...
 

Static Public Attributes

static constexpr XPLMDataTypeID usefulTypes
 Defines which types to work with to become valid More...
 

Protected Attributes

std::string sDataRef
 dataRef name, passed in via constructor More...
 
XPLMDataRef dataRef = NULL
 dataRef identifier returned by X-Plane More...
 
XPLMDataTypeID dataTypes = xplmType_Unknown
 supported data types More...
 
bool bValid = true
 does this object have a valid binding to a dataRef already? More...
 

Detailed Description

Represents a dataRef and covers late binding.

Late binding is important: We read another plugin's dataRefs. The other plugin (here: LiveTraffic) needs to register the dataRefs first before we can find them. So we would potentially fail if we search for them during startup (like when declaring statically). With this wrapper we still can do static declaration because the actual call to XPLMFindDataRef happens only the first time we actually access it.

Constructor & Destructor Documentation

◆ LTDataRef()

LTDataRef::LTDataRef ( std::string  _sDataRef)

Constructor, set the dataRef's name.

Member Function Documentation

◆ FindDataRef()

bool LTDataRef::FindDataRef ( )

Finds the dataRef (and would try again and again, no matter what bValid says)

◆ getBool()

bool LTDataRef::getBool ( )
inline

Gets dataRef's integer value and returns if it is not zero.

◆ getData()

int LTDataRef::getData ( void *  pOut,
int  inOffset,
int  inMaxBytes 
)

Gets dataRef's binary data.

◆ getDataRefTypes()

XPLMDataTypeID LTDataRef::getDataRefTypes ( ) const
inline

Get types supported by the dataRef.

◆ getFloat()

float LTDataRef::getFloat ( )

Get dataRef's float value. Silently returns 0.0f if dataRef doesn't exist.

◆ getInt()

int LTDataRef::getInt ( )

Get dataRef's integer value. Silently returns 0 if dataRef doesn't exist.

◆ hasFloat()

bool LTDataRef::hasFloat ( ) const
inline

Is float a supported dataRef type?

◆ hasInt()

bool LTDataRef::hasInt ( ) const
inline

Is int a supported dataRef type?

◆ isValid()

bool LTDataRef::isValid ( )

Found the dataRef and it contains formats we can work with?

Note
Not const! Will call FindDataRef() to try becoming valid.

◆ needsInit()

bool LTDataRef::needsInit ( ) const
inline

◆ set() [1/2]

void LTDataRef::set ( float  f)

Writes a float vlue to the dataRef.

◆ set() [2/2]

void LTDataRef::set ( int  i)

Writes an integer value to the dataRef.

Member Data Documentation

◆ bValid

bool LTDataRef::bValid = true
protected

does this object have a valid binding to a dataRef already?

◆ dataRef

XPLMDataRef LTDataRef::dataRef = NULL
protected

dataRef identifier returned by X-Plane

◆ dataTypes

XPLMDataTypeID LTDataRef::dataTypes = xplmType_Unknown
protected

supported data types

◆ sDataRef

std::string LTDataRef::sDataRef
protected

dataRef name, passed in via constructor

◆ usefulTypes

constexpr XPLMDataTypeID LTDataRef::usefulTypes
staticconstexpr
Initial value:
=
xplmType_Int | xplmType_Float | xplmType_Data

Defines which types to work with to become valid


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