57 const std::string& _path) :
cslKey(_cslKey),
path(_path) {}
238 float inElapsedTimeSinceLastFlightLoop,
253 typedef std::multimap<unsigned long,std::pair<CSLModel*,const CSLModel::MatchCritTy*> >
mmapCSLModelPTy;
276 mapCSLModelTy::iterator* _pOutIter =
nullptr);
282 mapCSLModelTy::iterator* _pOutIter =
nullptr);
292 const std::string& _airline,
293 const std::string& _livery,
Represents a CSL model as it is saved on disk.
Definition: CSLModels.h:113
bool IsObjInvalid() const
(Minimum) )State of the X-Plane object: Is it invalid?
Definition: CSLModels.h:223
std::string cslId
full id: package name / shortId, expected to be unique
Definition: CSLModels.h:142
const Doc8643 * doc8643
Proper Doc8643 entry for this model.
Definition: CSLModels.h:165
listCSLObjTy listObj
list of objects representing this model
Definition: CSLModels.h:150
int GetNumEngines() const
Definition: CSLModels.h:213
int xsbAircraftLn
Line number in the xsb_aircraft.txt file where the model definition starts.
Definition: CSLModels.h:159
unsigned refCnt
Reference counter: Number of Aircraft actively using this model.
Definition: CSLModels.h:169
char GetClassEngType() const
Definition: CSLModels.h:214
char GetClassNumEng() const
Definition: CSLModels.h:212
std::string shortId
short id, just an arbitrary label read from xsb_aircraft.txt::OBJ8_AIRCRAFT
Definition: CSLModels.h:140
const std::string & GetId() const
full id: package name / shortId, expected to be unique
Definition: CSLModels.h:200
std::uint16_t pkgHash
simple hash of package name, for easy matching in networked setup
Definition: CSLModels.h:146
const Doc8643 & GetDoc8643() const
Classification (like "L2P" or "L4J") and WTC (like "H" or "L/M")
Definition: CSLModels.h:209
virtual ~CSLModel()
Destructor frees resources.
Definition: CSLModels.cpp:360
std::list< XPLMObjectRef > GetAllObjRefs()
Try get ALL object handles, only returns anything if it is the complete list.
Definition: CSLModels.cpp:452
static float GarbageCollection(float inElapsedSinceLastCall, float inElapsedTimeSinceLastFlightLoop, int inCounter, void *inRefcon)
Unload all objects which haven't been used for a while.
Definition: CSLModels.cpp:500
std::future< float > futVertOfs
future for asynchronously reading vertOfs
Definition: CSLModels.h:173
MatchCritVecTy vecMatchCrit
further match-relevant fields like airline and livery can be a list
Definition: CSLModels.h:148
std::string icaoType
ICAO aircraft type this model represents: xsb_aircraft.txt::ICAO
Definition: CSLModels.h:163
float FetchVertOfsFromObjFile() const
Read the obj files to fill CSLModel::vertOfs.
Definition: CSLModels.cpp:526
const std::string & GetLivery() const
Livery code this model represents: xsb_aircraft.txt::LIVERY
Definition: CSLModels.h:204
ObjLoadStateTy GetObjState() const
(Minimum) )State of the X-Plane objects: Is it being loaded or available?
Definition: CSLModels.cpp:438
const std::string & GetIcaoType() const
ICAO aircraft type this model represents: xsb_aircraft.txt::ICAO
Definition: CSLModels.h:202
bool IsValid() const
Minimum requirement for using this object is: id, type, path.
Definition: CSLModels.h:197
bool HasRotor() const
Definition: CSLModels.h:215
char GetClassType() const
Definition: CSLModels.h:211
std::string modelName
name, formed by last part of path plus id
Definition: CSLModels.h:144
void CompModelName()
Puts together the model name string from a path component and shortId
Definition: CSLModels.cpp:421
const std::string & GetIcaoAirline() const
ICAO Airline code this model represents: xsb_aircraft.txt::AIRLINE
Definition: CSLModels.h:203
CSLModel()
Constructor.
Definition: CSLModels.h:177
const std::string & GetShortId() const
short id, just an arbitrary label read from xsb_aircraft.txt::OBJ8_AIRCRAFT
Definition: CSLModels.h:199
int GetRelatedGrp() const
"related" group for this model (a group of alike plane models), or 0
Definition: CSLModels.h:205
int related
"related" group for this model (a group of alike plane models), or 0
Definition: CSLModels.h:167
float GetVertOfs() const
Vertical Offset to be applied to aircraft model.
Definition: CSLModels.h:218
void Unload()
Unload all objects.
Definition: CSLModels.cpp:518
const char * GetWTC() const
Wake turbulence category.
Definition: CSLModels.h:210
std::vector< MatchCritTy > MatchCritVecTy
Vector of match-relevant fields.
Definition: CSLModels.h:137
std::string GetKeyString() const
compiles the string used as key in the CSL model map
Definition: CSLModels.cpp:432
float vertOfs
Vertical offset to be applied [m].
Definition: CSLModels.h:152
void IncRefCnt()
Increase the reference counter for Aircraft usage.
Definition: CSLModels.h:230
CSLModel & operator=(CSLModel &&o)=default
bool bVertOfsReadFromFile
Shall we try reading vertOfs from the OBJ8 file if we need this a/c?
Definition: CSLModels.h:154
void DecRefCnt()
Decrease the reference counter for Aircraft usage.
Definition: CSLModels.cpp:487
float refZeroTs
Time point when refCnt reached 0 (used in garbage collection, in terms of XP's total running time)
Definition: CSLModels.h:171
CSLModel(CSLModel &&o)=default
Generate standard move constructor.
unsigned GetRefCnt() const
Current reference counter.
Definition: CSLModels.h:234
std::string xsbAircraftPath
Path to the xsb_aircraft.txt file from where this model is loaded.
Definition: CSLModels.h:157
const std::string & GetModelName() const
name, formed by last part of path plus id (human readable, but not guaranteed to be unique)
Definition: CSLModels.h:201
void AddMatchCriteria(const std::string &_type, const MatchCritTy &_matchCrit, int lnNr)
Set the a/c type model and add other match criteria.
Definition: CSLModels.cpp:390
One .obj file of a CSL model (of which it can have multiple)
Definition: CSLModels.h:40
bool IsInvalid() const
Is invalid?
Definition: CSLModels.h:67
ObjLoadStateTy xpObjState
State of the X-Plane object: Is it being loaded or available?
Definition: CSLModels.h:52
std::string pathOrig
full path to the original .obj file IF there is the need to create a copy upon load
Definition: CSLModels.h:44
XPLMObjectRef GetAndLoadObj()
Load and return the underlying X-Plane objects.
Definition: CSLModels.cpp:98
ObjLoadStateTy GetObjState() const
State of the X-Plane object: Is it being loaded or available?
Definition: CSLModels.h:65
XPLMObjectRef xpObj
The X-Plane object reference to the loaded model as requested with XPLMLoadObjectAsync.
Definition: CSLModels.h:50
CSLObj & operator=(CSLObj &&o)=default
std::string cslKey
key of the CSL model this belongs to
Definition: CSLModels.h:42
void SetCopyResult(bool bResult)
Update with the result of the copy operation.
Definition: CSLCopy.cpp:188
void Load()
Starts loading the XP object.
Definition: CSLModels.cpp:216
bool TriggerCopyAndReplace()
Trigger a separate thread to copy the .obj file if needed.
Definition: CSLCopy.cpp:230
float FetchVertOfsFromObjFile() const
Read the obj file to calculate its vertical offset.
Definition: CSLModels.cpp:151
std::string text_lit
texture_lit file if defined, to be used in the TEXTURE_LIT line of the .obj file
Definition: CSLModels.h:46
void Unload()
Free up the object.
Definition: CSLModels.cpp:243
static void XPObjLoadedCB(XPLMObjectRef inObject, void *inRefcon)
callback function called when loading is done
Definition: CSLModels.cpp:254
~CSLObj()
Destructor makes sure the XP object is removed, too.
Definition: CSLModels.cpp:92
CSLObj(const std::string &_cslKey, const std::string &_path)
Constructor doesn't do much.
Definition: CSLModels.h:56
static void SetOtherObjCopyResult(bool bResult)
Update another CSLObj with the result of the copy operation.
Definition: CSLCopy.cpp:203
CSLObj(CSLObj &&o)=default
Generate standard move constructor.
bool NeedsObjCopy() const
Will this object require copying the .obj file upon load?
Definition: CSLModels.h:84
std::string path
full path to the (potentially copied) .obj file
Definition: CSLModels.h:43
void Invalidate()
Marks the CSL Model invalid in case object loading once failed.
Definition: CSLModels.cpp:309
void DetermineWhichObjToLoad()
Determine which file to load and if we need a copied .obj file.
Definition: CSLModels.cpp:112
bool CopyAndReplace()
Perform the copy-on-load functionality, replacing dataRefs and textures, expected to be called via st...
Definition: CSLCopy.cpp:73
std::string texture
texture file if defined, to be used in the TEXTURE line of the .obj file
Definition: CSLModels.h:45
Definition: XPMPAircraft.h:70
int CSLModelMatching(const std::string &_type, const std::string &_airline, const std::string &_livery, CSLModel *&pModel)
Find a matching model.
Definition: CSLModels.cpp:1368
void CSLModelsCleanup()
Grace cleanup.
Definition: CSLModels.cpp:1065
std::multimap< unsigned long, std::pair< CSLModel *, const CSLModel::MatchCritTy * > > mmapCSLModelPTy
Multimap of references to CSLModels and match criteria for matching purposes.
Definition: CSLModels.h:253
std::pair< std::string, std::string > pairOfStrTy
Definition: CSLModels.h:109
CSLModel * CSLModelById(const std::string &_cslId, mapCSLModelTy::iterator *_pOutIter)
Find a model by unique id.
Definition: CSLModels.cpp:1110
std::list< CSLObj > listCSLObjTy
List of objects.
Definition: CSLModels.h:107
std::map< std::string, CSLModel > mapCSLModelTy
Map of CSLModels (owning the object), ordered by related group / type.
Definition: CSLModels.h:250
void CSLModelsInit()
Initialization.
Definition: CSLModels.cpp:1046
ObjLoadStateTy
State of the X-Plane object: Is it being loaded or available?
Definition: CSLModels.h:30
@ OLS_COPYING
creating a new .obj file copy, replacing dataRefs and textures
Definition: CSLModels.h:33
@ OLS_UNAVAIL
Not yet tried loading the CSL object.
Definition: CSLModels.h:32
@ OLS_INVALID
loading once failed -> invalid!
Definition: CSLModels.h:31
@ OLS_LOADING
async load underway
Definition: CSLModels.h:34
@ OLS_AVAILABLE
X-Plane object available in xpObj
Definition: CSLModels.h:35
int RelatedGet(RelTxtTy relType, const std::string &_acType)
Find the related group for a given key, 0 if none.
Definition: RelatedDoc8643.cpp:146
std::map< std::string, std::string > mapCSLPackageTy
Map of CSLPackages: Maps an id to the base path (path ends on forward slash)
Definition: CSLModels.h:27
CSLModel * CSLModelByKey(const std::string &_cslKey, mapCSLModelTy::iterator *_pOutIter)
Find a model by (even more) unique key.
Definition: CSLModels.cpp:1134
const char * CSLModelsLoad(const std::string &_path, int _maxDepth)
Read the CSL Models found in the given path and below.
Definition: CSLModels.cpp:1081
@ REL_TXT_OP
related file for operators, relOp.txt
Definition: RelatedDoc8643.h:46
Combines match-relevant fields (beside ICAO a/c type)
Definition: CSLModels.h:116
std::string livery
Livery code this model represents: xsb_aircraft.txt::LIVERY
Definition: CSLModels.h:123
const std::string & getAirline() const
ICAO Airline code / operator.
Definition: CSLModels.h:129
int relOp
'related' group of the airline, if it exists, otherwise 0
Definition: CSLModels.h:120
bool merge(const MatchCritTy &o)
Decide which criteria is better and keep that.
Definition: CSLModels.cpp:321
int getRelOp() const
'Related' group of operator, if any, otherwise 0
Definition: CSLModels.h:130
std::string icaoAirline
ICAO Airline code this model represents: xsb_aircraft.txt::AIRLINE
Definition: CSLModels.h:119
void setAirline(const std::string &_icaoOp)
Sets airline (operator) and looks up its 'related' group.
Definition: CSLModels.h:126
Represents a line in the Doc8643.txt file, of which we use only classification and WTC.
Definition: RelatedDoc8643.h:78
bool HasRotor() const
Definition: RelatedDoc8643.h:94
int GetNumEngines() const
Definition: RelatedDoc8643.h:92
char wtc[4]
Definition: RelatedDoc8643.h:81
char GetClassNumEng() const
Definition: RelatedDoc8643.h:91
char GetClassEngType() const
Definition: RelatedDoc8643.h:93
char GetClassType() const
Definition: RelatedDoc8643.h:90