ansys::Project::Project Class Reference
Last update: 16.07.2025Base class for Project API, also see SimProject. More...
#include "Project.hpp"

Classes | |
| struct | CheckProjectInfo |
| Utility structure for VisitorCheckProject project checking action. More... | |
Public Member Functions | |
| Project () | |
| Constructor. More... | |
| virtual | ~Project () |
| Destructor - Will close the project and release the lock (if any). | |
| bool | isLoaded () const |
| Indicates if a project is currrently opened (or newly created with success). | |
| virtual bool | isProject (const URL &pLocation) |
| Check if a filename is a project file (fast read, not entirely checked) | |
| virtual Error | newProject (const URL &pLocation) |
| Create a project at the specified URL. More... | |
| virtual Error | openProject (const URL &pLocation, bool pReadOnly=false) |
| Open a project at the specified URL. More... | |
| virtual Error | openProjectFromString (const std::string &pData, const URL &pProjectLocation, bool pReadOnly=false) |
| Open a project by reading its data from a string. More... | |
| Error | saveProject () |
| Save the currently opened project. | |
| Error | saveProjectToString (std::string &pString) |
| Save the currently opened project to an XML string. | |
| Error | saveAsProject (const URL &pLocation, bool pFlagCopyFiles=false, bool pFlagCopyExternal=false) |
| Save the project index file to a new location. More... | |
| Error | exportProject (const URL &pLocation, bool pFlagCopyExternal=true, bool pFlagEnforceStructure=false) |
| Export the project to a new location (keeping current project opened and unchanged). More... | |
| Error | archiveProject (const URL &pTargetArchive) const |
| Compress the project to an archive (keeping current project opened and unchanged) More... | |
| Error | archiveProject (const URL &pTargetArchive, const std::vector< std::string > &pListIgnore) const |
| Compress the project to an archive (keeping current project opened and unchanged) More... | |
| Error | forkProject (Iterator &pIter, const URL &pNewProjectFilename, Project *&pProject) |
| Split the project at the specified location to a subproject. More... | |
| Error | loadSubProject (Iterator &pIter) |
| Load the specified subproject. More... | |
| std::vector< Iterator > | getSubProjects () |
| Return the list of subprojects stored in the project. | |
| Error | loadAllSubProjects () |
| Load all subprojects stored in the project. | |
| Error | join (Iterator pIter) |
| Join the subproject back to the master project. | |
| Error | getProjectLockInfo (const URL &pLocation, std::string &pLockInfo) |
| Indicates if the specified project is locked and retrieve the lock information. More... | |
| Error | eraseProjectLock (const URL &pLocation) |
| Erase the project lock. More... | |
| virtual Error | checkProject (CheckProjectInfo &pSettings) const |
| Check if a Project is valid. More... | |
| virtual Error | upgradeProject () |
| Upgrade project to current version. More... | |
| Iterator | copyItemTo (Iterator pSource, Project &pTarget, Iterator pTargetFolder=Iterator(), bool pRecursive=false) |
| Copy the Iterator item to the target project. More... | |
| Error | closeProject () |
| Close the project and release the lock. More... | |
| const URL & | getProjectLocation () const |
| Get the URL of the project file with path. | |
| URL | getProjectFolder () const |
| Get the URL of the project folder, if enabled by policy. | |
| ProjectStoragePolicy & | getStoragePolicy () |
| Return the StoragePolicy for the current project or to configure before newProject(). | |
| bool | isLocalToProject (const URL &pURL) const |
| Indicates if the specified absolute URL is inside the project folder. | |
| bool | isOwnedByProject (const URL &pURL) const |
| If the specified URL is a file in the project folder, and registered, returns true. | |
| Iterator | getIteratorForURL (const URL &pURL) const |
| If the specified URL is a file in the project folder, and registered, returns the Iterator. | |
| URL | getRelativePathToFile (const URL &pURL) const |
| Future feature - Not available. | |
| bool | registerCallback (const std::string &pOwner, const std::string &pCallbackName, BaseCallback *pCallback) |
| Register a function callback to a project event. More... | |
| Error | executeCallback (const std::string &pCallbackName, CallbackParams &pParams) |
| Trigger any registered callback for this callback ID. | |
| virtual Error | copyMetadata (const Iterator &pSource, Iterator &pTarget) const |
| Copy all metadata values from source to target iterator. | |
| virtual Error | copyRuntimeMetadata (const Iterator &pSource, Iterator &pTarget) const |
| Copy all runtime metadata values from source to target iterator. | |
| virtual Error | getInheritedMetadata (const Iterator &pIter, MetadataConst &pMeta) |
| Return the metadata for the current iterator and include relevant data from parent iterators. More... | |
| Iterator | root () const |
| Return the iterator to the project root folder. | |
| Iterator | get (const Path &pPath) const |
| For a project Path, return the associated Iterator. More... | |
| int | getProjectId () const |
| Return a project id, which will be the same as in the matching Iterator::getProjectId(). | |
Static Public Member Functions | |
| static Error | unarchiveProject (const URL &pArchive, const URL &pTargetFolder) |
| Extract the project to an from an archive,. More... | |
Protected Member Functions | |
| virtual Project * | projectObjectFactory () const |
| Create a new object of the current effective project type. More... | |
| virtual Error | copyProjectContent (Iterator pFolder, const URL &pSourceFolder, const URL &pTargetFolder, std::map< Iterator, URL > &pURLChanges, bool pCopyExternalFiles, bool pEnforceStructure) |
| Internal function - Copy a folder iterator content files from a source directory to target. More... | |
Detailed Description
Base class for Project API, also see SimProject.
To use the concepts of Simulation, Run, Output, and Result, a SimProject should be used to create/load the files.
The Project object is the low-level service, offering only the File, Folder, and Link capabilities.
The project concept is detailed in Project API.
Constructor & Destructor Documentation
◆ Project()
| ansys::Project::Project::Project | ( | ) |
Constructor.
A project should be created/opened with newProject()/openProject() Before creating a project, the storage policy should be set up, to configure whether the new project should be a free-storage or a managed project. See getStoragePolicy().
Member Function Documentation
◆ archiveProject() [1/2]
Compress the project to an archive (keeping current project opened and unchanged)
If the project is managed (project folder), flprj+folder are compressed If the project is free storage, all files referenced from project folder (in current or subfolders) are included. Files with global URLs or, relative URL going up (../) will not be saved in the archive.
- Parameters
-
pTargetArchive 7z file to write
◆ archiveProject() [2/2]
| Error ansys::Project::Project::archiveProject | ( | const URL & | pTargetArchive, |
| const std::vector< std::string > & | pListIgnore | ||
| ) | const |
Compress the project to an archive (keeping current project opened and unchanged)
If the project is managed (project folder), flprj+folder are compressed If the project is free storage, all files referenced from project folder (in current or subfolders) are included. Files with global URLs or, relative URL going up (../) will not be saved in the archive.
- Parameters
-
pTargetArchive 7z file to write pListIgnore list of file names or patterns to ignore
◆ checkProject()
|
virtual |
Check if a Project is valid.
- Parameters
-
pSettings CheckProjectInfo structure used to specify check project settings and return the results.
Reimplemented in ansys::Project::SimProject.
◆ closeProject()
| Error ansys::Project::Project::closeProject | ( | ) |
Close the project and release the lock.
All Iterators to this project will become invalid and will be unusable (!ok()).
◆ copyItemTo()
◆ copyProjectContent()
|
protectedvirtual |
Internal function - Copy a folder iterator content files from a source directory to target.
- Parameters
-
pFolder Iterator of a folder to copy. pSourceFolder Location of the storage for the folder. pTargetFolder Location of the storage for the new folder (folder must exist already). pURLChanges If Iterators would have their URL changed by saving a project to the new location, this index is to be filled with iterators and their new URL (setURL/getURL). In the case of a saveAsProject the URL changes are applied and kept, in the case of an export the URL changes are to be applied , the project saved, then restored. pFlagCopyExternal if enabled, external files and folders are copied to the new project location. if disabled, URL references are kept as is. If a file is stored in a unregistered subfolder, the same file structure is copied to the target location. pFlagEnforceStructure The project is saved to a project folder and subfolders are enforced to their Simulation/Run names.
◆ eraseProjectLock()
Erase the project lock.
- Parameters
-
pLocation URL of the project file.
◆ exportProject()
| Error ansys::Project::Project::exportProject | ( | const URL & | pLocation, |
| bool | pFlagCopyExternal = true, |
||
| bool | pFlagEnforceStructure = false |
||
| ) |
Export the project to a new location (keeping current project opened and unchanged).
This operation will copy/collate the files of the project.
- Parameters
-
pLocation New location and name of the flprj file pFlagCopyExternal If enabled, external files and folders are copied to the new project location. If disabled, URL references are kept as is pFlagEnforceStructure The project is saved to a project folder and subfolders are enforced to their Simulation/Run names.
◆ forkProject()
| Error ansys::Project::Project::forkProject | ( | Iterator & | pIter, |
| const URL & | pNewProjectFilename, | ||
| Project *& | pNewProject | ||
| ) |
Split the project at the specified location to a subproject.
The specified location (a folder iterator) becomes the new project root, and is linked as a subproject in the current project. A new project file is saved at the specified URL filename.
- Parameters
-
pIter Folder iterator to split as a subproject. pPrjLocation Location/name of the project index file, if a blank URL is provided, it is saved alongside the target folder, with the default project filename suffix (.flprj). pNewProject A blank, properly typed, project object to use (if forking a SimProject, use a SimProject target).
◆ get()
For a project Path, return the associated Iterator.
The Path is the internal project hiearchy, which might include hidden/virtual subfolders. To get the iterator from a file path on disk, see getIteratorForURL().
◆ getInheritedMetadata()
|
virtual |
Return the metadata for the current iterator and include relevant data from parent iterators.
In Project this only returns the metadata for the current iterator, unless the parent item is a Transparent item, the data is then also included. Used in some UI elements.
Reimplemented in ansys::Project::SimProject.
◆ getProjectLockInfo()
◆ loadSubProject()
Load the specified subproject.
- Parameters
-
pIter Folder iterator to split as a subproject. pPrjLocation Location/name of the project index file, if a blank URL is provided, it is saved alongside the target folder, with the default project filename suffix (.flprj). pNewProject A blank, properly typed, project object to use (if forking a SimProject, use a SimProject target).
◆ newProject()
Create a project at the specified URL.
The URL is a folder with a *.flprj filename, the location must be writeable. A Storage plug-in must be loaded to accommodate the URL type. ( StorageFilesystem is always available for local file storage).
The Project is created from the currently configured ProjectStoragePolicy and a new folder is created alongside the *.flprj file, if applicable.
◆ openProject()
|
virtual |
Open a project at the specified URL.
From the storage policies, opening the project might fail if the project is locked, or read-only not permitted if locked.
- Parameters
-
pLocation : Filename of the project (.flprj) file pFlagReadOnly : If read-only the project cannot be modified
◆ openProjectFromString()
|
virtual |
Open a project by reading its data from a string.
- Parameters
-
pProjectData Project data, such as written by saveProjectToString() pProjectLocation Location on filesystem, assumed for relative URLs pFlagReadOnly If read-only, the project cannot be modified
◆ projectObjectFactory()
|
protectedvirtual |
Create a new object of the current effective project type.
Overridden at the SimProject level
Reimplemented in ansys::Project::SimProject.
◆ registerCallback()
| bool ansys::Project::Project::registerCallback | ( | const std::string & | pOwner, |
| const std::string & | pCallbackName, | ||
| BaseCallback * | pCallback | ||
| ) |
Register a function callback to a project event.
Project events are generated by the project viewer UI contextMenuActions, itemDoubleClick, itemSelected, etc.
- Parameters
-
pOwner An identifier for the owner of this callback. pCallbackName One of the standard callback events offered by the project. pCallback The function callback to execute upon the event.
◆ saveAsProject()
| Error ansys::Project::Project::saveAsProject | ( | const URL & | pLocation, |
| bool | pFlagCopyFiles = false, |
||
| bool | pFlagCopyExternal = false |
||
| ) |
Save the project index file to a new location.
The project content is copied if pFlagCopyFiles is enabled The type of the project is kept the same (project folder enabled/disabled).
- Parameters
-
pLocation New location and name of the flprj file pFlagCopyFiles If enabled, external files and folders are copied to the new project location. pFlagCopyFiles If the project contains references to external files, they will be copied to the new project folder.
◆ unarchiveProject()
|
static |
Extract the project to an from an archive,.
It will extract/overwrite the project files in the specified folder
◆ upgradeProject()
|
virtual |
Upgrade project to current version.
Upgrading a project might make it incompatible with earlier versions of the software. Some metadata definitions might not be useable with the current software version until the project is updated.
See also ProjectStorageManager::setAutoUpgradesEnabled(bool). If automatic upgrades are enabled in the project policy, the project is upgraded when it is read.
Reimplemented in ansys::Project::SimProject.