GemaCoreLib
The GeMA Core library
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
GmPath Class Reference

Class used to store releveant system and project paths, providing functions for path macro translations. More...

#include <gmPath.h>

Collaboration diagram for GmPath:
Collaboration graph
[legend]

Public Member Functions

 GmPath ()
 Constructor. Inits the application path.
 
void setConfigPath (QString path)
 Sets the path used to find configuration files ($APPCONFIG value)
 
void setScriptsPath (QString path)
 Sets the path used to find utilitary Lua scripts ($SCRIPTS value)
 
QString scriptsPath () const
 Returns the current scripts path.
 
void setUserGivenPaths (QString logPath, QString inputPath, QString outputPath)
 Sets paths given by the user as command line parameters. More...
 
void setSimulationPath (QString simulationDir, QString simulationBaseName)
 Sets the location and base file name for the simulation project ($SIMULATIONDIR and $SIMULATIONNAME values)
 
QString translatePath (QString path) const
 Utilitary function used to translate macros in a path, replacing them by the appropriate location. More...
 
void printPathMacros (const GmLogCategory &logger, GmLogLevel level, bool printProjectMacros)
 Prints the contents of the path Macros to the provided logger/level.
 

Static Public Member Functions

static QString toNativeSeparators (QString path)
 Returns a path translated to the format used by the operating system.
 

Private Attributes

QString _appPath
 Directory that contains the executable (stripped of release or debug dirs if present)
 
QString _initialPath
 The current path when the library was initialized.
 
QString _buildMode
 'release', 'debug' or '' depending on the presence of those subdirs in the unstripped program path
 
QString _configPath
 Directory that contains the config file in use.
 
QString _scriptsPath
 Directory that contains utilitary Lua script files.
 
QString _simulationDir
 Directory that contains the simulation file in use.
 
QString _simulationBaseFileName
 Base simulation file name, without extension.
 
QString _logPath
 The path for the log file. Either a user supplied path (through command line) or equal to _appPath.
 
QString _inputPath
 An input file path. Either a user supplied path (through command line) or equal to _simulationDir.
 
QString _outputPath
 An output file path. Either a user supplied path (through command line) or equal to _simulationDir.
 
QDateTime _simTime
 The time when the simulation started.
 

Detailed Description

Class used to store releveant system and project paths, providing functions for path macro translations.

Member Function Documentation

◆ setUserGivenPaths()

void GmPath::setUserGivenPaths ( QString  logPath,
QString  inputPath,
QString  outputPath 
)
inline

Sets paths given by the user as command line parameters.

Parameters
logPathThe path used for the log file, queried with the $LOG macro. If empty, its value defaults to the application path ($CURRENT).
inputPathInput file path, queried with the $INPUT macro. If empty, its value defaults to the project dir ($SIMULATIONDIR)
outputPathOutput file path, queried with the $OUTPUT macro. If empty, its value defaults to the project dir ($SIMULATIONDIR)

◆ translatePath()

QString GmPath::translatePath ( QString  path) const

Utilitary function used to translate macros in a path, replacing them by the appropriate location.

Understood macros include:

  • $APP : refers to the directory where the application lives, stripped of debug or release subdirs
  • $CURRENT : refers to the directory where the application was run
  • $LOG : refers to the directory where the log file is written. Can be the value set by setUserGivenPaths() or equal to $CURRENT if the previous option is empty.
  • $APPCONFIG : refers to the directory from where the config file was read
  • $SCRIPTS : refers to the configured directory used for loading auxiliary Lua scripts
  • $SIMULATIONDIR : refers to the directory where the simulation file was read
  • $SIMULATIONNAME : refers to the base name (without extension) of the simulation file read
  • $BUILDMODE : refers to release or debug if present in the original (unstripped) application path
  • $INPUT : refers to a 'input' directory given by the value set by setUserGivenPaths() or equal to $SIMULATIONDIR if the previous option is empty.
  • $OUTPUT : refers to a 'output' directory given by the value set by setUserGivenPaths() or equal to $SIMULATIONDIR if the previous option is empty.
  • $yy : year of the simulation execution with 2 digits
  • $MM : month of the simulation execution with 2 digits
  • $dd : day of the simulation execution with 2 digits
  • $hh : hour of the simulation execution with 2 digits
  • $mm : minute of the simulation execution with 2 digits
  • $ss : second of the simulation execution with 2 digits
Parameters
pathPath to be translated

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