LTAPI
API to access LiveTraffic's aircraft information
|
Connects to LiveTraffic's dataRefs and returns aircraft information. More...
#include <LTAPI.h>
Public Types | |
typedef LTAPIAircraft * | fCreateAcObject() |
Callback function type passed in to LTAPIConnect() More... | |
Public Member Functions | |
LTAPIConnect (fCreateAcObject *_pfCreateAcObject=LTAPIAircraft::CreateNewObject, int numBulkAc=50) | |
Constructor. More... | |
virtual | ~LTAPIConnect () |
const MapLTAPIAircraft & | UpdateAcList (ListLTAPIAircraft *plistRemovedAc=nullptr) |
Main function: updates map of aircrafts and returns reference to it. More... | |
const MapLTAPIAircraft & | getAcMap () const |
Returns the map of aircraft as it currently stands. More... | |
SPtrLTAPIAircraft | getAcByMultIdx (int multiIdx) const |
Finds an aircraft for a given multiplayer slot. More... | |
SPtrLTAPIAircraft | getAcInCameraView () const |
Returns the aircraft being viewed in LiveTraffic's camera view, if any. More... | |
Static Public Member Functions | |
static bool | isLTAvail () |
Is LiveTraffic available? (checks via XPLMFindPluginBySignature) More... | |
static int | getLTVerNr () |
LiveTraffic's version number. More... | |
static int | getLTVerDate () |
LiveTraffic's version date. More... | |
static bool | doesLTDisplayAc () |
Does LiveTraffic display aircrafts? (Is it activated?) More... | |
static int | getLTNumAc () |
How many aircraft does LiveTraffic display right now? More... | |
static bool | doesLTControlAI () |
Does LiveTaffic control AI planes? More... | |
static time_t | getLTSimTime () |
What is current simulated time in LiveTraffic (usually 'now' minus buffering period)? More... | |
static std::chrono::system_clock::time_point | getLTSimTimePoint () |
What is current simulated time in LiveTraffic (usually 'now' minus buffering period)? More... | |
Public Attributes | |
std::chrono::seconds | sPeriodExpsv = std::chrono::seconds(3) |
Protected Member Functions | |
template<class T > | |
bool | DoBulkFetch (int numAc, LTDataRef &DR, int &outSizeLT, std::unique_ptr< T[]> &vBulk) |
fetch bulk data and create/update aircraft objects More... | |
Protected Attributes | |
const int | iBulkAc = 50 |
Number of aircraft to fetch in one bulk operation. More... | |
std::unique_ptr< LTAPIAircraft::LTAPIBulkData[]> | vBulkNum |
bulk data array for communication with LT More... | |
std::unique_ptr< LTAPIAircraft::LTAPIBulkInfoTexts[]> | vInfoTexts |
bulk info text array for communication with LT More... | |
fCreateAcObject * | pfCreateAcObject = nullptr |
Pointer to callback function returning new aircraft objects. More... | |
MapLTAPIAircraft | mapAc |
THE map of aircrafts. More... | |
std::chrono::time_point< std::chrono::steady_clock > | lastExpsvFetch |
Last fetching of expensive data. More... | |
Connects to LiveTraffic's dataRefs and returns aircraft information.
Typically, exactly one instance of this class is used.
typedef LTAPIAircraft* LTAPIConnect::fCreateAcObject() |
Callback function type passed in to LTAPIConnect()
The callback is actually called by UpdateAcList().
If you use a class derived from LTAPIAircraft, then you pass in a pointer to a callback function, which returns new empty objects of your derived class whenever UpdateAcList() needs to create a new aircraft object.
LTAPIConnect::LTAPIConnect | ( | fCreateAcObject * | _pfCreateAcObject = LTAPIAircraft::CreateNewObject , |
int | numBulkAc = 50 |
||
) |
Constructor.
_pfCreateAcObject | (Optional) Poitner to callback function, which returns new aircraft objects, see typedef fCreateAcObject() |
numBulkAc | Number of aircraft to fetch in one bulk operation |
|
virtual |
|
protected |
fetch bulk data and create/update aircraft objects
numAc | Total number of aircraft to fetch | |
DR | The dataRef to use for fetching the actual data from LT | |
[out] | outSizeLT | Returns LT's structure size |
vBulk | Reference to allocated memory for data transfer |
T | is the structure to fill, either LTAPIAircraft::LTAPIBulkData or LTAPIAircraft::LTAPIBulkInfoTexts |
|
static |
Does LiveTaffic control AI planes?
true
.
|
static |
Does LiveTraffic display aircrafts? (Is it activated?)
This is the only function which checks again and again if LiveTraffic's dataRefs are available. Use this to verify if LiveTraffic is (now) available before calling any other function on LiveTraffic's dataRefs.
SPtrLTAPIAircraft LTAPIConnect::getAcByMultIdx | ( | int | multiIdx | ) | const |
Finds an aircraft for a given multiplayer slot.
multiIdx | The multiplayer index to look for |
multiIdx
, is empty if not found SPtrLTAPIAircraft LTAPIConnect::getAcInCameraView | ( | ) | const |
Returns the aircraft being viewed in LiveTraffic's camera view, if any.
|
inline |
Returns the map of aircraft as it currently stands.
|
static |
How many aircraft does LiveTraffic display right now?
|
static |
What is current simulated time in LiveTraffic (usually 'now' minus buffering period)?
|
static |
What is current simulated time in LiveTraffic (usually 'now' minus buffering period)?
|
static |
LiveTraffic's version date.
Version date became available with v2.01 only. This is why 20191231 is returned in case LiveTraffic is available, but not the dataRef to fetch the date from.
|
static |
LiveTraffic's version number.
Version number became available with v2.01 only. This is why 150 is returned in case LiveTraffic is available, but not the dataRef to fetch the number from.
|
static |
Is LiveTraffic available? (checks via XPLMFindPluginBySignature)
const MapLTAPIAircraft & LTAPIConnect::UpdateAcList | ( | ListLTAPIAircraft * | plistRemovedAc = nullptr | ) |
Main function: updates map of aircrafts and returns reference to it.
plistRemovedAc | (Optional) If you want to know which a/c are removed during this call (because the disappeared from LiveTraffic) then pass a ListLTAPIAircraft object: LTAPI will transfer otherwise removed objects there and management of them is then up to you. LTAPI will only emplace_back to the list, never remove anything. |
|
protected |
Number of aircraft to fetch in one bulk operation.
|
protected |
Last fetching of expensive data.
|
protected |
THE map of aircrafts.
|
protected |
Pointer to callback function returning new aircraft objects.
std::chrono::seconds LTAPIConnect::sPeriodExpsv = std::chrono::seconds(3) |
Number of seconds between two calls of the expensive type, which fetches all texts from LiveTraffic, which in fact don't change that often anyway
|
protected |
bulk data array for communication with LT
|
protected |
bulk info text array for communication with LT