FlightGear next
FGGlobals Class Reference

Bucket for subsystem pointers representing the sim's state. More...

#include <globals.hxx>

Public Member Functions

 FGGlobals ()
 
virtual ~FGGlobals ()
 
virtual FGRendererget_renderer () const
 
void set_renderer (FGRenderer *render)
 
SGSubsystemMgr * get_subsystem_mgr () const
 
template<class T>
T * get_subsystem () const
 
SGEventMgr * get_event_mgr () const
 
double get_sim_time_sec () const
 
void inc_sim_time_sec (double dt)
 
void set_sim_time_sec (double t)
 
const SGPath & get_fg_root () const
 
void set_fg_root (const SGPath &root)
 
void set_texture_cache_dir (const SGPath &textureCache)
 
PathList get_data_paths () const
 Get list of data locations.
 
PathList get_data_paths (const std::string &suffix) const
 Get data locations which contain the file path suffix.
 
void append_data_path (const SGPath &path, bool afterFGRoot=false)
 
SGPath findDataPath (const std::string &pathSuffix) const
 Given a path suffix (eg 'Textures' or 'AI/Traffic'), find the first data directory which defines it.
 
const SGPath & get_fg_home () const
 
void set_fg_home (const SGPath &home)
 
const SGPath & get_download_dir () const
 
void set_download_dir (const SGPath &path)
 
const SGPath & get_texture_cache_dir () const
 
const SGPath & get_terrasync_dir () const
 
void set_terrasync_dir (const SGPath &path)
 
const PathListget_fg_scenery () const
 
const PathListget_extra_read_allowed_paths () const
 
void append_fg_scenery (const SGPath &scenery)
 Add a scenery directory.
 
void append_fg_scenery (const PathList &scenery)
 
void clear_fg_scenery ()
 
void append_read_allowed_paths (const SGPath &path)
 Allow Nasal to read a path.
 
void set_catalog_aircraft_path (const SGPath &path)
 specify a path we'll prepend to the aircraft paths list if non-empty.
 
PathList get_aircraft_paths () const
 
void append_aircraft_path (const SGPath &path)
 Add an aircraft directory.
 
void append_aircraft_paths (const PathList &path)
 
SGPath resolve_aircraft_path (const std::string &branch) const
 Given a path to an aircraft-related resource file, resolve it against the appropriate root.
 
SGPath resolve_maybe_aircraft_path (const std::string &branch) const
 Same as above, but test for non 'Aircraft/' branch paths, and always resolve them against fg_root.
 
SGPath resolve_resource_path (const std::string &branch) const
 Search in the following directories:
 
const std::string & get_browser () const
 
void set_browser (const std::string &b)
 
long int get_warp () const
 
void set_warp (long int w)
 
long int get_warp_delta () const
 
void set_warp_delta (long int d)
 
SGTime * get_time_params () const
 
void set_time_params (SGTime *t)
 
SGMaterialLib * get_matlib () const
 
void set_matlib (SGMaterialLib *m)
 
SGPropertyNode * get_props ()
 
void resetPropertyRoot ()
 reset the property tree to new, empty tree.
 
FGLocaleget_locale ()
 
SGCommandMgr * get_commands ()
 
SGGeod get_aircraft_position () const
 
SGVec3d get_aircraft_position_cart () const
 
void get_aircraft_orientation (double &heading, double &pitch, double &roll)
 
SGGeod get_view_position () const
 
SGVec3d get_view_position_cart () const
 
SGVec3d get_ownship_reference_position_cart () const
 
string_listget_channel_options_list ()
 
void set_channel_options_list (string_list *l)
 
string_listget_initial_waypoints ()
 
void set_initial_waypoints (string_list *list)
 
FGViewMgrget_viewmgr () const
 
flightgear::Viewget_current_view () const
 
FGControlsget_controls () const
 
FGSceneryget_scenery () const
 
FGTACANListget_channellist () const
 
void set_channellist (FGTACANList *c)
 
SGPath autosaveFilePath (SGPath userDataPath=SGPath()) const
 Return an SGPath instance for the autosave file under 'userDataPath', which defaults to $FG_HOME.
 
void loadUserSettings (SGPath userDatapath=SGPath())
 Load user settings from the autosave file under 'userDataPath', which defaults to $FG_HOME.
 
void saveUserSettings (SGPath userDatapath=SGPath())
 Save user settings to the autosave file under 'userDataPath', which defaults to $FG_HOME.
 
void addListenerToCleanup (SGPropertyChangeListener *l)
 
simgear::pkg::Root * packageRoot ()
 
void setPackageRoot (const SGSharedPtr< simgear::pkg::Root > &p)
 
bool is_headless ()
 A runtime headless mode for running without a GUI.
 
void set_headless (bool mode)
 

Detailed Description

Bucket for subsystem pointers representing the sim's state.

Definition at line 78 of file globals.hxx.

Constructor & Destructor Documentation

◆ FGGlobals()

FGGlobals::FGGlobals ( )

Definition at line 146 of file globals.cxx.

◆ ~FGGlobals()

FGGlobals::~FGGlobals ( )
virtual

Definition at line 194 of file globals.cxx.

Member Function Documentation

◆ addListenerToCleanup()

void FGGlobals::addListenerToCleanup ( SGPropertyChangeListener * l)

Definition at line 976 of file globals.cxx.

◆ append_aircraft_path()

void FGGlobals::append_aircraft_path ( const SGPath & path)

Add an aircraft directory.

This also makes the path Nasal-readable: to avoid can-read-any-file security holes, do NOT call this on paths obtained from the property tree or other Nasal-writable places

Definition at line 524 of file globals.cxx.

◆ append_aircraft_paths()

void FGGlobals::append_aircraft_paths ( const PathList & path)

Definition at line 548 of file globals.cxx.

◆ append_data_path()

void FGGlobals::append_data_path ( const SGPath & path,
bool afterFGRoot = false )

Definition at line 329 of file globals.cxx.

◆ append_fg_scenery() [1/2]

void FGGlobals::append_fg_scenery ( const PathList & scenery)

Definition at line 373 of file globals.cxx.

◆ append_fg_scenery() [2/2]

void FGGlobals::append_fg_scenery ( const SGPath & scenery)

Add a scenery directory.

This also makes the path Nasal-readable: to avoid can-read-any-file security holes, do NOT call this on paths obtained from the property tree or other Nasal-writable places

Definition at line 380 of file globals.cxx.

◆ append_read_allowed_paths()

void FGGlobals::append_read_allowed_paths ( const SGPath & path)

Allow Nasal to read a path.

To avoid can-read-any-file security holes, do NOT call this on paths obtained from the property tree or other Nasal-writable places

Only works during initial load (before fgInitAllowedPaths)

Definition at line 448 of file globals.cxx.

◆ autosaveFilePath()

SGPath FGGlobals::autosaveFilePath ( SGPath userDataPath = SGPath()) const

Return an SGPath instance for the autosave file under 'userDataPath', which defaults to $FG_HOME.

Definition at line 739 of file globals.cxx.

◆ clear_fg_scenery()

void FGGlobals::clear_fg_scenery ( )

Definition at line 458 of file globals.cxx.

◆ findDataPath()

SGPath FGGlobals::findDataPath ( const std::string & pathSuffix) const

Given a path suffix (eg 'Textures' or 'AI/Traffic'), find the first data directory which defines it.

Definition at line 348 of file globals.cxx.

◆ get_aircraft_orientation()

void FGGlobals::get_aircraft_orientation ( double & heading,
double & pitch,
double & roll )

Definition at line 624 of file globals.cxx.

◆ get_aircraft_paths()

PathList FGGlobals::get_aircraft_paths ( ) const

Definition at line 513 of file globals.cxx.

◆ get_aircraft_position()

SGGeod FGGlobals::get_aircraft_position ( ) const

Definition at line 611 of file globals.cxx.

◆ get_aircraft_position_cart()

SGVec3d FGGlobals::get_aircraft_position_cart ( ) const

Definition at line 619 of file globals.cxx.

◆ get_browser()

const std::string & FGGlobals::get_browser ( ) const
inline

Definition at line 302 of file globals.hxx.

◆ get_channel_options_list()

string_list * FGGlobals::get_channel_options_list ( )
inline

Definition at line 344 of file globals.hxx.

◆ get_channellist()

FGTACANList * FGGlobals::get_channellist ( ) const
inline

Definition at line 366 of file globals.hxx.

◆ get_commands()

SGCommandMgr * FGGlobals::get_commands ( )
inline

Definition at line 330 of file globals.hxx.

◆ get_controls()

FGControls * FGGlobals::get_controls ( ) const

Definition at line 971 of file globals.cxx.

◆ get_current_view()

flightgear::View * FGGlobals::get_current_view ( ) const

Definition at line 960 of file globals.cxx.

◆ get_data_paths() [1/2]

PathList FGGlobals::get_data_paths ( ) const

Get list of data locations.

fg_root is always the final item in the result.

Definition at line 308 of file globals.cxx.

◆ get_data_paths() [2/2]

PathList FGGlobals::get_data_paths ( const std::string & suffix) const

Get data locations which contain the file path suffix.

Eg pass ing 'AI/Traffic' to get all data paths which define <path>/AI/Traffic subdir

Definition at line 316 of file globals.cxx.

◆ get_download_dir()

const SGPath & FGGlobals::get_download_dir ( ) const
inline

Definition at line 216 of file globals.hxx.

◆ get_event_mgr()

SGEventMgr * FGGlobals::get_event_mgr ( ) const

Definition at line 605 of file globals.cxx.

◆ get_extra_read_allowed_paths()

const PathList & FGGlobals::get_extra_read_allowed_paths ( ) const
inline

Definition at line 235 of file globals.hxx.

◆ get_fg_home()

const SGPath & FGGlobals::get_fg_home ( ) const
inline

Definition at line 213 of file globals.hxx.

◆ get_fg_root()

const SGPath & FGGlobals::get_fg_root ( ) const
inline

Definition at line 189 of file globals.hxx.

◆ get_fg_scenery()

const PathList & FGGlobals::get_fg_scenery ( ) const
inline

Definition at line 234 of file globals.hxx.

◆ get_initial_waypoints()

string_list * FGGlobals::get_initial_waypoints ( )
inline

Definition at line 351 of file globals.hxx.

◆ get_locale()

FGLocale * FGGlobals::get_locale ( )
inline

Definition at line 328 of file globals.hxx.

◆ get_matlib()

SGMaterialLib * FGGlobals::get_matlib ( ) const
inline

Definition at line 314 of file globals.hxx.

◆ get_ownship_reference_position_cart()

SGVec3d FGGlobals::get_ownship_reference_position_cart ( ) const

Definition at line 644 of file globals.cxx.

◆ get_props()

SGPropertyNode * FGGlobals::get_props ( )
inline

Definition at line 320 of file globals.hxx.

◆ get_renderer()

FGRenderer * FGGlobals::get_renderer ( ) const
virtual

Definition at line 572 of file globals.cxx.

◆ get_scenery()

FGScenery * FGGlobals::get_scenery ( ) const

Definition at line 950 of file globals.cxx.

◆ get_sim_time_sec()

double FGGlobals::get_sim_time_sec ( ) const
inline

Definition at line 185 of file globals.hxx.

◆ get_subsystem()

template<class T>
T * FGGlobals::get_subsystem ( ) const
inline

Definition at line 177 of file globals.hxx.

◆ get_subsystem_mgr()

SGSubsystemMgr * FGGlobals::get_subsystem_mgr ( ) const

Definition at line 589 of file globals.cxx.

◆ get_terrasync_dir()

const SGPath & FGGlobals::get_terrasync_dir ( ) const
inline

Definition at line 226 of file globals.hxx.

◆ get_texture_cache_dir()

const SGPath & FGGlobals::get_texture_cache_dir ( ) const
inline

Definition at line 224 of file globals.hxx.

◆ get_time_params()

SGTime * FGGlobals::get_time_params ( ) const
inline

Definition at line 311 of file globals.hxx.

◆ get_view_position()

SGGeod FGGlobals::get_view_position ( ) const

Definition at line 632 of file globals.cxx.

◆ get_view_position_cart()

SGVec3d FGGlobals::get_view_position_cart ( ) const

Definition at line 640 of file globals.cxx.

◆ get_viewmgr()

FGViewMgr * FGGlobals::get_viewmgr ( ) const

Definition at line 955 of file globals.cxx.

◆ get_warp()

long int FGGlobals::get_warp ( ) const

Definition at line 930 of file globals.cxx.

◆ get_warp_delta()

long int FGGlobals::get_warp_delta ( ) const

Definition at line 940 of file globals.cxx.

◆ inc_sim_time_sec()

void FGGlobals::inc_sim_time_sec ( double dt)
inline

Definition at line 186 of file globals.hxx.

◆ is_headless()

bool FGGlobals::is_headless ( )

A runtime headless mode for running without a GUI.

Definition at line 1002 of file globals.cxx.

◆ loadUserSettings()

void FGGlobals::loadUserSettings ( SGPath userDatapath = SGPath())

Load user settings from the autosave file under 'userDataPath', which defaults to $FG_HOME.

Definition at line 860 of file globals.cxx.

◆ packageRoot()

simgear::pkg::Root * FGGlobals::packageRoot ( )

Definition at line 992 of file globals.cxx.

◆ resetPropertyRoot()

void FGGlobals::resetPropertyRoot ( )

reset the property tree to new, empty tree.

Ensure all subsystems are shutdown and unbound before call this.

Definition at line 685 of file globals.cxx.

◆ resolve_aircraft_path()

SGPath FGGlobals::resolve_aircraft_path ( const std::string & branch) const

Given a path to an aircraft-related resource file, resolve it against the appropriate root.

This means looking at the location defined by /sim/aircraft-dir, and then aircraft_path in turn, finishing with fg_root/Aircraft.

if the path could not be resolved, an empty path is returned.

Definition at line 555 of file globals.cxx.

◆ resolve_maybe_aircraft_path()

SGPath FGGlobals::resolve_maybe_aircraft_path ( const std::string & branch) const

Same as above, but test for non 'Aircraft/' branch paths, and always resolve them against fg_root.

Definition at line 560 of file globals.cxx.

◆ resolve_resource_path()

SGPath FGGlobals::resolve_resource_path ( const std::string & branch) const

Search in the following directories:

  1. Root directory of current aircraft (defined by /sim/aircraft-dir)
  2. All aircraft directories if branch starts with Aircraft/
  3. fg_data directory

Definition at line 565 of file globals.cxx.

◆ saveUserSettings()

void FGGlobals::saveUserSettings ( SGPath userDatapath = SGPath())

Save user settings to the autosave file under 'userDataPath', which defaults to $FG_HOME.

When calling this method, make sure the value of 'userDataPath' is trustworthy. In particular, make sure it can't be influenced by Nasal code, not even indirectly via a Nasal-writable place such as the property tree.

Note: the default value is safe—if not, it would be a bug.

Definition at line 902 of file globals.cxx.

◆ set_browser()

void FGGlobals::set_browser ( const std::string & b)
inline

Definition at line 303 of file globals.hxx.

◆ set_catalog_aircraft_path()

void FGGlobals::set_catalog_aircraft_path ( const SGPath & path)

specify a path we'll prepend to the aircraft paths list if non-empty.

This is used with packaged aircraft, to ensure their catalog (and hence, dependency packages) are found correctly.

Definition at line 508 of file globals.cxx.

◆ set_channel_options_list()

void FGGlobals::set_channel_options_list ( string_list * l)
inline

Definition at line 347 of file globals.hxx.

◆ set_channellist()

void FGGlobals::set_channellist ( FGTACANList * c)
inline

Definition at line 367 of file globals.hxx.

◆ set_download_dir()

void FGGlobals::set_download_dir ( const SGPath & path)

Definition at line 468 of file globals.cxx.

◆ set_fg_home()

void FGGlobals::set_fg_home ( const SGPath & home)

Definition at line 293 of file globals.cxx.

◆ set_fg_root()

void FGGlobals::set_fg_root ( const SGPath & root)

Definition at line 265 of file globals.cxx.

◆ set_headless()

void FGGlobals::set_headless ( bool mode)

Definition at line 1007 of file globals.cxx.

◆ set_initial_waypoints()

void FGGlobals::set_initial_waypoints ( string_list * list)
inline

Definition at line 355 of file globals.hxx.

◆ set_matlib()

void FGGlobals::set_matlib ( SGMaterialLib * m)

Definition at line 966 of file globals.cxx.

◆ set_renderer()

void FGGlobals::set_renderer ( FGRenderer * render)

Definition at line 577 of file globals.cxx.

◆ set_sim_time_sec()

void FGGlobals::set_sim_time_sec ( double t)
inline

Definition at line 187 of file globals.hxx.

◆ set_terrasync_dir()

void FGGlobals::set_terrasync_dir ( const SGPath & path)

Definition at line 489 of file globals.cxx.

◆ set_texture_cache_dir()

void FGGlobals::set_texture_cache_dir ( const SGPath & textureCache)

Definition at line 298 of file globals.cxx.

◆ set_time_params()

void FGGlobals::set_time_params ( SGTime * t)
inline

Definition at line 312 of file globals.hxx.

◆ set_warp()

void FGGlobals::set_warp ( long int w)

Definition at line 935 of file globals.cxx.

◆ set_warp_delta()

void FGGlobals::set_warp_delta ( long int d)

Definition at line 945 of file globals.cxx.

◆ setPackageRoot()

void FGGlobals::setPackageRoot ( const SGSharedPtr< simgear::pkg::Root > & p)

Definition at line 997 of file globals.cxx.


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