LTAPI
API to access LiveTraffic's aircraft information
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.
 
bool needsInit () const
 
bool isValid ()
 Found the dataRef and it contains formats we can work with?
 
bool FindDataRef ()
 Finds the dataRef (and would try again and again, no matter what bValid says)
 
XPLMDataTypeID getDataRefTypes () const
 Get types supported by the dataRef.
 
bool hasInt () const
 Is int a supported dataRef type?
 
bool hasFloat () const
 Is float a supported dataRef type?
 
int getInt ()
 Get dataRef's integer value. Silently returns 0 if dataRef doesn't exist.
 
float getFloat ()
 Get dataRef's float value. Silently returns 0.0f if dataRef doesn't exist.
 
bool getBool ()
 Gets dataRef's integer value and returns if it is not zero.
 
int getData (void *pOut, int inOffset, int inMaxBytes)
 Gets dataRef's binary data.
 
void set (int i)
 Writes an integer value to the dataRef.
 
void set (float f)
 Writes a float vlue to the dataRef.
 

Static Public Attributes

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

Protected Attributes

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

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?

◆ 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

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 file: