XPMP2
X-Plane multiplayer library 2 - using instancing
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
XPMP2::CSLModel Class Reference

Represetns a CSL model as it is saved on disk. More...

#include <CSLModels.h>

Classes

struct  MatchCritTy
 Combines match-relevant fields (beside ICAO a/c type) More...
 

Public Types

typedef std::vector< MatchCritTyMatchCritVecTy
 Vector of match-relevant fields. More...
 

Public Member Functions

 CSLModel ()
 Constructor. More...
 
 CSLModel (CSLModel &&o)=default
 Generate standard move constructor. More...
 
CSLModeloperator= (CSLModel &&o)=default
 
virtual ~CSLModel ()
 Destructor frees resources. More...
 
void AddMatchCriteria (const std::string &_type, const MatchCritTy &_matchCrit, int lnNr)
 Set the a/c type model and add other match criteria. More...
 
void CompModelName ()
 Puts together the model name string from a path component and shortId More...
 
bool IsValid () const
 Minimum requirement for using this object is: id, type, path. More...
 
const std::string & GetShortId () const
 short id, just an arbitrary label read from xsb_aircraft.txt::OBJ8_AIRCRAFT More...
 
const std::string & GetId () const
 full id: package name / shortId, expected to be unique More...
 
const std::string & GetModelName () const
 name, formed by last part of path plus id (human readable, but not guaranteed to be unique) More...
 
const std::string & GetIcaoType () const
 ICAO aircraft type this model represents: xsb_aircraft.txt::ICAO More...
 
const std::string & GetIcaoAirline () const
 ICAO Airline code this model represents: xsb_aircraft.txt::AIRLINE More...
 
const std::string & GetLivery () const
 Livery code this model represents: xsb_aircraft.txt::LIVERY More...
 
int GetRelatedGrp () const
 "related" group for this model (a group of alike plane models), or 0 More...
 
std::string GetKeyString () const
 compiles the string used as key in the CSL model map More...
 
const Doc8643GetDoc8643 () const
 Classification (like "L2P" or "L4J") and WTC (like "H" or "L/M") More...
 
const char * GetWTC () const
 Wake turbulence category. More...
 
char GetClassType () const
 
char GetClassNumEng () const
 
char GetClassEngType () const
 
bool HasRotor () const
 
float GetVertOfs () const
 Vertical Offset to be applied to aircraft model. More...
 
ObjLoadStateTy GetObjState () const
 (Minimum) )State of the X-Plane objects: Is it being loaded or available? More...
 
bool IsObjInvalid () const
 (Minimum) )State of the X-Plane object: Is it invalid? More...
 
std::list< XPLMObjectRef > GetAllObjRefs ()
 Try get ALL object handles, only returns anything if it is the complete list. More...
 
void IncRefCnt ()
 Increase the reference counter for Aircraft usage. More...
 
void DecRefCnt ()
 Decrease the reference counter for Aircraft usage. More...
 
unsigned GetRefCnt () const
 Current reference counter. More...
 

Static Public Member Functions

static float GarbageCollection (float inElapsedSinceLastCall, float inElapsedTimeSinceLastFlightLoop, int inCounter, void *inRefcon)
 Unload all objects which haven't been used for a while. More...
 

Public Attributes

std::string shortId
 short id, just an arbitrary label read from xsb_aircraft.txt::OBJ8_AIRCRAFT More...
 
std::string cslId
 full id: package name / shortId, expected to be unique More...
 
std::string modelName
 name, formed by last part of path plus id More...
 
std::uint16_t pkgHash = 0
 simple hash of package name, for easy matching in networked setup More...
 
MatchCritVecTy vecMatchCrit
 further match-relevant fields like airline and livery can be a list More...
 
listCSLObjTy listObj
 list of objects representing this model More...
 
float vertOfs = 3.0f
 Vertical offset to be applied [m]. More...
 
bool bVertOfsReadFromFile = true
 Shall we try reading vertOfs from the OBJ8 file if we need this a/c? More...
 
std::string xsbAircraftPath
 Path to the xsb_aircraft.txt file from where this model is loaded. More...
 
int xsbAircraftLn = 0
 Line number in the xsb_aircraft.txt file where the model definition starts. More...
 

Protected Member Functions

void Unload ()
 Unload all objects. More...
 
float FetchVertOfsFromObjFile () const
 Read the obj files to fill CSLModel::vertOfs. More...
 

Protected Attributes

std::string icaoType
 ICAO aircraft type this model represents: xsb_aircraft.txt::ICAO More...
 
const Doc8643doc8643 = nullptr
 Proper Doc8643 entry for this model. More...
 
int related = 0
 "related" group for this model (a group of alike plane models), or 0 More...
 
unsigned refCnt = 0
 Reference counter: Number of Aircraft actively using this model. More...
 
float refZeroTs = 0.0f
 Time point when refCnt reached 0 (used in garbage collection, in terms of XP's total running time) More...
 
std::future< float > futVertOfs
 future for asynchronously reading vertOfs More...
 

Detailed Description

Represetns a CSL model as it is saved on disk.

Member Typedef Documentation

◆ MatchCritVecTy

Vector of match-relevant fields.

Constructor & Destructor Documentation

◆ CSLModel() [1/2]

XPMP2::CSLModel::CSLModel ( )
inline

Constructor.

◆ CSLModel() [2/2]

XPMP2::CSLModel::CSLModel ( CSLModel &&  o)
default

Generate standard move constructor.

◆ ~CSLModel()

XPMP2::CSLModel::~CSLModel ( )
virtual

Destructor frees resources.

Member Function Documentation

◆ AddMatchCriteria()

void XPMP2::CSLModel::AddMatchCriteria ( const std::string &  _type,
const MatchCritTy _matchCrit,
int  lnNr 
)

Set the a/c type model and add other match criteria.

Also fills doc8643 and related. Keeps most significant match criteria only (if "DLH/-" and "DLH/D-ABCD" are defined, then only "DLH/D-ABCD" is kept as that covers the "DLH/-" case, too)

◆ CompModelName()

void XPMP2::CSLModel::CompModelName ( )

Puts together the model name string from a path component and shortId

◆ DecRefCnt()

void XPMP2::CSLModel::DecRefCnt ( )

Decrease the reference counter for Aircraft usage.

◆ FetchVertOfsFromObjFile()

float XPMP2::CSLModel::FetchVertOfsFromObjFile ( ) const
protected

Read the obj files to fill CSLModel::vertOfs.

Note
Expected to be called in a separate thread via std::async

◆ GarbageCollection()

float XPMP2::CSLModel::GarbageCollection ( float  inElapsedSinceLastCall,
float  inElapsedTimeSinceLastFlightLoop,
int  inCounter,
void *  inRefcon 
)
static

Unload all objects which haven't been used for a while.

◆ GetAllObjRefs()

std::list< XPLMObjectRef > XPMP2::CSLModel::GetAllObjRefs ( )

Try get ALL object handles, only returns anything if it is the complete list.

This starts async loading of all objects.

◆ GetClassEngType()

char XPMP2::CSLModel::GetClassEngType ( ) const
inline

◆ GetClassNumEng()

char XPMP2::CSLModel::GetClassNumEng ( ) const
inline

◆ GetClassType()

char XPMP2::CSLModel::GetClassType ( ) const
inline

◆ GetDoc8643()

const Doc8643& XPMP2::CSLModel::GetDoc8643 ( ) const
inline

Classification (like "L2P" or "L4J") and WTC (like "H" or "L/M")

◆ GetIcaoAirline()

const std::string& XPMP2::CSLModel::GetIcaoAirline ( ) const
inline

ICAO Airline code this model represents: xsb_aircraft.txt::AIRLINE

◆ GetIcaoType()

const std::string& XPMP2::CSLModel::GetIcaoType ( ) const
inline

ICAO aircraft type this model represents: xsb_aircraft.txt::ICAO

◆ GetId()

const std::string& XPMP2::CSLModel::GetId ( ) const
inline

full id: package name / shortId, expected to be unique

◆ GetKeyString()

std::string XPMP2::CSLModel::GetKeyString ( ) const

compiles the string used as key in the CSL model map

◆ GetLivery()

const std::string& XPMP2::CSLModel::GetLivery ( ) const
inline

Livery code this model represents: xsb_aircraft.txt::LIVERY

◆ GetModelName()

const std::string& XPMP2::CSLModel::GetModelName ( ) const
inline

name, formed by last part of path plus id (human readable, but not guaranteed to be unique)

◆ GetObjState()

ObjLoadStateTy XPMP2::CSLModel::GetObjState ( ) const

(Minimum) )State of the X-Plane objects: Is it being loaded or available?

◆ GetRefCnt()

unsigned XPMP2::CSLModel::GetRefCnt ( ) const
inline

Current reference counter.

◆ GetRelatedGrp()

int XPMP2::CSLModel::GetRelatedGrp ( ) const
inline

"related" group for this model (a group of alike plane models), or 0

◆ GetShortId()

const std::string& XPMP2::CSLModel::GetShortId ( ) const
inline

short id, just an arbitrary label read from xsb_aircraft.txt::OBJ8_AIRCRAFT

◆ GetVertOfs()

float XPMP2::CSLModel::GetVertOfs ( ) const
inline

Vertical Offset to be applied to aircraft model.

◆ GetWTC()

const char* XPMP2::CSLModel::GetWTC ( ) const
inline

Wake turbulence category.

◆ HasRotor()

bool XPMP2::CSLModel::HasRotor ( ) const
inline

◆ IncRefCnt()

void XPMP2::CSLModel::IncRefCnt ( )
inline

Increase the reference counter for Aircraft usage.

◆ IsObjInvalid()

bool XPMP2::CSLModel::IsObjInvalid ( ) const
inline

(Minimum) )State of the X-Plane object: Is it invalid?

◆ IsValid()

bool XPMP2::CSLModel::IsValid ( ) const
inline

Minimum requirement for using this object is: id, type, path.

◆ operator=()

CSLModel& XPMP2::CSLModel::operator= ( CSLModel &&  o)
default

◆ Unload()

void XPMP2::CSLModel::Unload ( )
protected

Unload all objects.

Member Data Documentation

◆ bVertOfsReadFromFile

bool XPMP2::CSLModel::bVertOfsReadFromFile = true

Shall we try reading vertOfs from the OBJ8 file if we need this a/c?

◆ cslId

std::string XPMP2::CSLModel::cslId

full id: package name / shortId, expected to be unique

◆ doc8643

const Doc8643* XPMP2::CSLModel::doc8643 = nullptr
protected

Proper Doc8643 entry for this model.

◆ futVertOfs

std::future<float> XPMP2::CSLModel::futVertOfs
protected

future for asynchronously reading vertOfs

◆ icaoType

std::string XPMP2::CSLModel::icaoType
protected

ICAO aircraft type this model represents: xsb_aircraft.txt::ICAO

◆ listObj

listCSLObjTy XPMP2::CSLModel::listObj

list of objects representing this model

◆ modelName

std::string XPMP2::CSLModel::modelName

name, formed by last part of path plus id

◆ pkgHash

std::uint16_t XPMP2::CSLModel::pkgHash = 0

simple hash of package name, for easy matching in networked setup

◆ refCnt

unsigned XPMP2::CSLModel::refCnt = 0
protected

Reference counter: Number of Aircraft actively using this model.

◆ refZeroTs

float XPMP2::CSLModel::refZeroTs = 0.0f
protected

Time point when refCnt reached 0 (used in garbage collection, in terms of XP's total running time)

◆ related

int XPMP2::CSLModel::related = 0
protected

"related" group for this model (a group of alike plane models), or 0

◆ shortId

std::string XPMP2::CSLModel::shortId

short id, just an arbitrary label read from xsb_aircraft.txt::OBJ8_AIRCRAFT

◆ vecMatchCrit

MatchCritVecTy XPMP2::CSLModel::vecMatchCrit

further match-relevant fields like airline and livery can be a list

◆ vertOfs

float XPMP2::CSLModel::vertOfs = 3.0f

Vertical offset to be applied [m].

◆ xsbAircraftLn

int XPMP2::CSLModel::xsbAircraftLn = 0

Line number in the xsb_aircraft.txt file where the model definition starts.

◆ xsbAircraftPath

std::string XPMP2::CSLModel::xsbAircraftPath

Path to the xsb_aircraft.txt file from where this model is loaded.


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