NAP
Public Types | Public Member Functions | Public Attributes | List of all members
ProjectInfo Class Reference

#include <nap/projectinfo.h>

Public Types

enum  EContext : uint8 { Application = 0, Editor = 1 }
 

Public Member Functions

bool isEditorMode () const
 
std::string getFilename () const
 
std::string getProjectDir () const
 
std::string getNAPRootDir () const
 
std::string getBuildDir () const
 
std::vector< std::string > getModuleDirectories () const
 
std::string getDataFile () const
 
std::string getDataDirectory () const
 
std::string getIniDir () const
 
std::string getIniFilePath (const std::string &name) const
 
bool hasServiceConfigFile () const
 
const PathMappinggetPathMapping () const
 
void patchPath (std::string &path, const std::unordered_map< std::string, std::string > &additionalValues={}) const
 
void patchPaths (std::vector< std::string > &paths, const std::unordered_map< std::string, std::string > &additionalValues={}) const
 
std::unique_ptr< ProjectInfoclone () const
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual bool init (utility::ErrorState &errorState)
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

std::string mTitle
 Property: 'Title' project title. More...
 
std::string mVersion
 Property: 'Version' project version. More...
 
std::string mDefaultData
 Property: 'Data' relative path to the application content (json) file. More...
 
std::string mPathMappingFile
 Property: 'PathMapping' relative path to the path mapping file. More...
 
std::string mServiceConfigFilename = {}
 Property: 'ServiceConfig' optional relative path to service configuration file. More...
 
std::vector< std::string > mRequiredModules
 Property: 'RequiredModules' names of modules this project depends on. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

Contains project related information, including project title, version number, the names of the modules the project depends on and what data file to load. The data file contains the actual app content. The project file describes the project.

The link to a service configuration file is optional, but when specified it is loaded and applied by Core on startup. The link to the path mapping file is required, otherwise the system won't be able to resolve all the paths.

Inheritance diagram for ProjectInfo:
[legend]
Collaboration diagram for ProjectInfo:
[legend]

Member Enumeration Documentation

◆ EContext

enum EContext : uint8
strong

Controls how paths to modules and other dependencies are resolved.

Enumerator
Application 

Resolved against running application.

Editor 

Resolved against editor.

Member Function Documentation

◆ clone()

std::unique_ptr<ProjectInfo> clone ( ) const

Clones this project info, including all properties.

Returns
a clone of this object

◆ getBuildDir()

std::string getBuildDir ( ) const
Returns
Absolute path to the build output directory

◆ getDataDirectory()

std::string getDataDirectory ( ) const
Returns
Absolute path of this project's data directory

◆ getDataFile()

std::string getDataFile ( ) const

Returns the absolute path to the application data file, which contains application content.

Returns
Absolute path to the application data file

◆ getFilename()

std::string getFilename ( ) const
Returns
The absolute file path this ProjectInfo was loaded from

◆ getIniDir()

std::string getIniDir ( ) const

Returns the absolute path to this project's .ini directory. Note that it is not created if it does not exist. The .ini directory contains files that are used to (re)-store settings in between sessions

Returns
Absolute path to this project's .ini directory

◆ getIniFilePath()

std::string getIniFilePath ( const std::string &  name) const

Returns an absolute .ini file path based on the given name. Note that this call does not create the .ini directory if it does not exist. The .ini file is used to (re)-store settings in between sessions

Parameters
namename of the file
Returns
absolute path to the .ini file on disk

◆ getModuleDirectories()

std::vector<std::string> getModuleDirectories ( ) const
Returns
Absolute paths of directories to use when searching for modules

◆ getNAPRootDir()

std::string getNAPRootDir ( ) const
Returns
Absolute path to the root of NAP Framework

◆ getPathMapping()

const PathMapping& getPathMapping ( ) const
Returns
The path mapping for this project.

◆ getProjectDir()

std::string getProjectDir ( ) const
Returns
Absolute path of the project directory

◆ hasServiceConfigFile()

bool hasServiceConfigFile ( ) const

Returns if a service configuration file has been provided. Service configuration resources deserialized from the configuration file override service defaults. This means that if no config file is provided, services are initialized using their default configuration resource.

Returns
if a service configuration file is specified.

◆ isEditorMode()

bool isEditorMode ( ) const
Returns
True if this process is running in an editor

◆ patchPath()

void patchPath ( std::string &  path,
const std::unordered_map< std::string, std::string > &  additionalValues = {} 
) const

Replace all occurrences of specific project variables such as 'ROOT', 'BUILD_CONFIG' etc. with the actual resolved values. For example:

ROOT -> path to nap root directory BUILD_ARCH -> x86_64 BUILD_CONFIG -> Debug-x86_64 BUILD_TYPE -> Release PROJECT_DIR -> path to project directory

Parameters
pathfull path that contains the project variables to replace
additionalValuesadditional variables to resolve
Returns
if the path is patched

◆ patchPaths()

void patchPaths ( std::vector< std::string > &  paths,
const std::unordered_map< std::string, std::string > &  additionalValues = {} 
) const

Replace all occurrences of specific project variables such as 'ROOT', 'BUILD_CONFIG' etc. with the actual resolved values. For example:

ROOT -> path to nap root directory BUILD_ARCH -> x86_64 BUILD_CONFIG -> Debug-x86_64 BUILD_TYPE -> Release PROJECT_DIR -> path to project directory

Parameters
pathspaths that contains the project variables to replace
additionalValuesadditional variables to resolve

Member Data Documentation

◆ mDefaultData

std::string mDefaultData

Property: 'Data' relative path to the application content (json) file.

◆ mPathMappingFile

std::string mPathMappingFile

Property: 'PathMapping' relative path to the path mapping file.

◆ mRequiredModules

std::vector<std::string> mRequiredModules

Property: 'RequiredModules' names of modules this project depends on.

◆ mServiceConfigFilename

std::string mServiceConfigFilename = {}

Property: 'ServiceConfig' optional relative path to service configuration file.

◆ mTitle

std::string mTitle

Property: 'Title' project title.

◆ mVersion

std::string mVersion

Property: 'Version' project version.