Skip to main content

Common Fluids Format 2024 R2

ansys::Project::Project Class Reference

Last update: 16.07.2025

Base class for Project API, also see SimProject. More...

#include "Project.hpp"

Inheritance diagram for ansys::Project::Project:
ansys::Project::SimProject

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< IteratorgetSubProjects ()
 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 URLgetProjectLocation () const
 Get the URL of the project file with path.
 
URL getProjectFolder () const
 Get the URL of the project folder, if enabled by policy.
 
ProjectStoragePolicygetStoragePolicy ()
 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 ProjectprojectObjectFactory () 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]

Error ansys::Project::Project::archiveProject ( const URL pTargetArchive) 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
pTargetArchive7z 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
pTargetArchive7z file to write
pListIgnorelist of file names or patterns to ignore

◆ checkProject()

Error ansys::Project::Project::checkProject ( CheckProjectInfo pSettings) const
virtual

Check if a Project is valid.

Parameters
pSettingsCheckProjectInfo 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()

Iterator ansys::Project::Project::copyItemTo ( Iterator  pSource,
Project pTarget,
Iterator  pTargetFolder = Iterator(),
bool  pRecursive = false 
)

Copy the Iterator item to the target project.

This operation only copies the project index data, not the files themselves. The URL pointed by the files is only valid if the new project is appropriately positioned.

◆ copyProjectContent()

Error ansys::Project::Project::copyProjectContent ( Iterator  pFolder,
const URL pSourceFolder,
const URL pTargetFolder,
std::map< Iterator, URL > &  pURLChanges,
bool  pCopyExternalFiles,
bool  pEnforceStructure 
)
protectedvirtual

Internal function - Copy a folder iterator content files from a source directory to target.

Parameters
pFolderIterator of a folder to copy.
pSourceFolderLocation of the storage for the folder.
pTargetFolderLocation of the storage for the new folder (folder must exist already).
pURLChangesIf 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.
pFlagCopyExternalif 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.
pFlagEnforceStructureThe project is saved to a project folder and subfolders are enforced to their Simulation/Run names.

◆ eraseProjectLock()

Error ansys::Project::Project::eraseProjectLock ( const URL pLocation)

Erase the project lock.

Parameters
pLocationURL 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
pLocationNew location and name of the flprj file
pFlagCopyExternalIf enabled, external files and folders are copied to the new project location. If disabled, URL references are kept as is
pFlagEnforceStructureThe 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
pIterFolder iterator to split as a subproject.
pPrjLocationLocation/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).
pNewProjectA blank, properly typed, project object to use (if forking a SimProject, use a SimProject target).

◆ get()

Iterator ansys::Project::Project::get ( const Path pPath) const

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()

Error ansys::Project::Project::getInheritedMetadata ( const Iterator pIter,
MetadataConst pMeta 
)
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()

Error ansys::Project::Project::getProjectLockInfo ( const URL pLocation,
std::string &  pLockInfo 
)

Indicates if the specified project is locked and retrieve the lock information.

Parameters
pLocationURL of the project to check.
pLockInfostring indicating the lock source, empty string if no lock
Returns
Error if the lock info cannot be retrieved.

◆ loadSubProject()

Error ansys::Project::Project::loadSubProject ( Iterator pIter)

Load the specified subproject.

Parameters
pIterFolder iterator to split as a subproject.
pPrjLocationLocation/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).
pNewProjectA blank, properly typed, project object to use (if forking a SimProject, use a SimProject target).

◆ newProject()

Error ansys::Project::Project::newProject ( const URL pLocation)
virtual

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()

Error ansys::Project::Project::openProject ( const URL pLocation,
bool  pFlagReadOnly = false 
)
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()

Error ansys::Project::Project::openProjectFromString ( const std::string &  pProjectData,
const URL pProjectLocation,
bool  pFlagReadOnly = false 
)
virtual

Open a project by reading its data from a string.

Parameters
pProjectDataProject data, such as written by saveProjectToString()
pProjectLocationLocation on filesystem, assumed for relative URLs
pFlagReadOnlyIf read-only, the project cannot be modified

◆ projectObjectFactory()

Project * ansys::Project::Project::projectObjectFactory ( ) const
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
pOwnerAn identifier for the owner of this callback.
pCallbackNameOne of the standard callback events offered by the project.
pCallbackThe 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
pLocationNew location and name of the flprj file
pFlagCopyFilesIf enabled, external files and folders are copied to the new project location.
pFlagCopyFilesIf the project contains references to external files, they will be copied to the new project folder.

◆ unarchiveProject()

Error ansys::Project::Project::unarchiveProject ( const URL pArchive,
const URL pTargetFolder 
)
static

Extract the project to an from an archive,.

It will extract/overwrite the project files in the specified folder

◆ upgradeProject()

Error ansys::Project::Project::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.

Connect with Ansys