Skip to main content

Common Fluids Format 2023 R2

Project

Last update: 16.07.2025
1#ifndef CFFSDK_PROJECT_PROJECT_H
2#define CFFSDK_PROJECT_PROJECT_H
3
4#include "Project/LibraryType.hpp"
5#include "Project/URL.hpp"
6#include "Project/Error.hpp"
7#include "Project/Iterator.hpp"
8#include "Project/ProjectStoragePolicy.hpp"
9#include <memory>
10
11namespace ansys {
12namespace Project {
13
14class PItem;
15class ProjectStorageManager;
16class ProjectStoragePolicy;
17class BaseCallback;
18class CallbackParams;
19class CheckProjectInfo;
20class MetadataConst;
21
22class ANSYS_PROJECT_DLL Project {
23public:
24 Project();
25 virtual ~Project();
26
27 // new/load/save and location
28 bool isLoaded() const;
29 virtual bool isProject(const URL& pLocation);
30 virtual Error newProject(const URL& pLocation);
31 virtual Error openProject(const URL& pLocation,bool pReadOnly=false);
32 virtual Error openProjectFromString(const std::string& pData,
33 const URL& pProjectLocation,
34 bool pReadOnly=false);
35 Error saveProject();
36 Error saveProjectToString(std::string& pString);
37 Error saveAsProject(const URL& pLocation,bool pFlagCopyFiles=false,bool pFlagCopyExternal=false);
38
39 Error exportProject(const URL& pLocation,bool pFlagCopyExternal=true,bool pFlagEnforceStructure=false);
40
41 Error archiveProject(const URL& pTargetArchive) const;
42 Error archiveProject(const URL& pTargetArchive,const std::vector<std::string>& pListIgnore) const;
43 static Error unarchiveProject(const URL& pArchive,const URL& pTargetFolder);
44
45 Error forkProject(Iterator& pIter,const URL& pNewProjectFilename,Project*& pProject);
46 bool isSubProject() const;
47 Error loadSubProject(Iterator& pIter);
48 std::vector<Iterator> getSubProjects();
49 Error loadAllSubProjects();
50 Error join(Iterator pIter);
51
52 Error getProjectLockInfo(const URL& pLocation,std::string& pLockInfo);
53 Error eraseProjectLock(const URL& pLocation);
54
55 struct CheckProjectInfo;
56 virtual Error checkProject(CheckProjectInfo& pSettings) const;
57 virtual Error upgradeProject();
58
59 Iterator copyItemTo(Iterator pSource,Project& pTarget,Iterator pTargetFolder=Iterator(),bool pRecursive=false);
60
61 Error closeProject();
62
63 const URL& getProjectLocation() const;
64 URL getProjectFolder() const;
65 ProjectStoragePolicy& getStoragePolicy();
66 const ProjectStoragePolicy& getStoragePolicy() const;
67
68 bool isLocalToProject(const URL& pURL) const;
69 bool isOwnedByProject(const URL& pURL) const;
70 Iterator getIteratorForURL(const URL& pURL) const;
71 URL getRelativePathToFile(const URL& pURL) const;
72
73 bool registerCallback(const std::string& pOwner,
74 const std::string& pCallbackName,
75 BaseCallback* pCallback);
76 Error executeCallback(const std::string& pCallbackName,
77 CallbackParams& pParams);
78
79 virtual Error copyMetadata(const Iterator& pSource,
80 Iterator& pTarget) const;
81 virtual Error copyRuntimeMetadata(const Iterator& pSource,
82 Iterator& pTarget) const;
83 virtual Error getInheritedMetadata(const Iterator& pIter,
84 MetadataConst& pMeta);
85
86 // file access through iterators
87 Iterator getDir();
88 bool setDir(Iterator& pDir);
89
90 Iterator root() const;
91 Iterator get(const Path& pPath) const;
92
93 int getProjectId() const;
94
99 // Behavior flags
100 bool aCheckCore;
103
105
106 // Counters
107 std::vector<Iterator> aVectBadLinks;
108 std::vector<Iterator> aVectBadInternalFolders;
109 std::vector<Iterator> aVectBadInternalFiles;
110 std::vector<Iterator> aVectBadExternalFolders;
111 std::vector<Iterator> aVectBadExternalFiles;
112
114 CheckProjectInfo(bool pFlagStrict)
115 :aCheckCore(true),
116 aCheckInternalURLs(true),
117 aCheckExternalURLs(false),
118 aStrictMode(pFlagStrict) {
119 };
120 };
121protected:
122 virtual Error updateFromPolicy() { return Error(); };
123 virtual Error setupNewProject();
124 virtual Project* projectObjectFactory() const;
125 virtual Error copyProjectContent(Iterator pFolder,const URL& pSourceFolder,const URL& pTargetFolder,
126 std::map<Iterator,URL>& pURLChanges,
127 bool pCopyExternalFiles,bool pEnforceStructure);
128
129 static int sFormatVersion;
130 static std::string getReleaseId();
131private:
132
133 Error clearData();
134 Error setProjectLockInfo();
135 Error migrateIterator(Iterator& pIter, Project& pNewProject);
136
137 enum ProjectState { PSUndefined, PSLoaded };
138 ProjectState aProjectState;
139 URL aLocation;
140
141 Iterator aCWD;
142 std::shared_ptr<PItem> aRoot;
143 bool aIsSubProject;
144
145 ProjectStoragePolicy aPolicy;
146 std::shared_ptr<ProjectStorageManager> aFileManager;
147
148 std::vector<Project*> aSubprojects;
149
150 int aProjectId;
151 static int sProjectId;
152};
153
154}
155}
156
157#endif // CFFSDK_PROJECT_PROJECT_H
The return state / error value of a Project function call.
Definition: Error.hpp:11
Pointer to a project location.
Definition: Iterator.hpp:20
Constant (read-only) value of Metadata.
Definition: MetadataConst.hpp:23
Paths used for internal Project filesystem.
Definition: Path.hpp:11
Project storage settings, control folder management, folder names, etc.
Definition: ProjectStoragePolicy.hpp:15
Base class for Project API, also see SimProject.
Definition: Project.hpp:22
The address of a local or remote file, using the URI format.
Definition: URL.hpp:12
Definition: API.dox:1
Utility structure for VisitorCheckProject project checking action.
Definition: Project.hpp:98
CheckProjectInfo(bool pFlagStrict)
Return value - list of missing files referenced by the project.
Definition: Project.hpp:114
std::vector< Iterator > aVectBadExternalFolders
Return value - list of missing files in the project.
Definition: Project.hpp:110
std::vector< Iterator > aVectBadExternalFiles
Return value - list of missing folders referenced by the project.
Definition: Project.hpp:111
bool aStrictMode
Enable to check if all files referenced outside the project actually exist.
Definition: Project.hpp:104
std::vector< Iterator > aVectBadInternalFolders
Return value - list of invalid links in the project.
Definition: Project.hpp:108
std::vector< Iterator > aVectBadInternalFiles
Return value - list of missing folders in the project.
Definition: Project.hpp:109
bool aCheckExternalURLs
Enable to check if all files stored in the project actually exist.
Definition: Project.hpp:102
std::vector< Iterator > aVectBadLinks
Error mode flag. (error vs warning in output)
Definition: Project.hpp:107
bool aCheckInternalURLs
Enable to check the project basic settings.
Definition: Project.hpp:101

Connect with Ansys