tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_Project.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
14//==============================================================================
27 public Selectable,
28 private juce::AsyncUpdater
29{
30public:
31 //==============================================================================
32 ~Project() override;
33
34 //==============================================================================
36 bool save();
37 void handleAsyncUpdate() override;
38
39 //==============================================================================
41 bool isValid() const;
42 bool isReadOnly() const;
43 bool isTemporary() const { return temporary; }
44
45 int getProjectID() const;
46 juce::String getName() const;
47 juce::String getDescription() const;
48 const juce::File& getProjectFile() const noexcept { return file; }
49 juce::File getDefaultDirectory() const;
50 juce::File getDirectoryForMedia (ProjectItem::Category category) const;
51
52 void setName (const juce::String& newName);
53 void setDescription (const juce::String& newDesc);
54
55 void createNewProjectId();
56
57 juce::String getProjectProperty (const juce::String& name) const;
58 void setProjectProperty (const juce::String& name, const juce::String& value);
59
60 void refreshProjectPropertiesFromFile();
61
62 bool isLibraryProject() const;
63 bool askAboutTempoDetect (const juce::File&, bool& shouldSetAutoTempo) const;
64
65 juce::Array<ProjectItemID> findOrphanItems();
66
67 //==============================================================================
68 int getNumProjectItems();
69 ProjectItemID getProjectItemID (int index);
70 juce::Array<ProjectItemID> getAllProjectItemIDs() const;
71 juce::Array<int> getAllItemIDs() const;
72 ProjectItem::Ptr getProjectItemAt (int index);
73 juce::Array<ProjectItem::Ptr> getAllProjectItems();
74 int getIndexOf (ProjectItemID) const;
75
76 ProjectItem::Ptr getProjectItemForID (ProjectItemID);
77 ProjectItem::Ptr getProjectItemForFile (const juce::File& file);
78
79 //==============================================================================
83 ProjectItem::Ptr createNewItem (const juce::File& fileToReference,
84 const juce::String& type,
85 const juce::String& name,
86 const juce::String& description,
87 const ProjectItem::Category cat,
88 bool atTopOfList);
89
90 bool removeProjectItem (ProjectItemID, bool deleteSourceMaterial);
91
92 void moveProjectItem (int indexToMoveFrom, int indexToMoveTo);
93
94 ProjectItem::Ptr createNewEdit();
95
97 void redirectIDsFromProject (int oldProjId, int newProjId);
98
99 //==============================================================================
109
110 void mergeArchiveContents (const juce::File& archiveFile);
111
112 void mergeOtherProjectIntoThis (const juce::File& otherProject);
113
116 void createDefaultFolders();
117
118 //==============================================================================
119 enum ProjectSortType
120 {
121 SortByName,
122 SortByDesc,
123 SortByType,
124 SortByLength,
125 SortBySize,
126 SortByModified,
127 SortByCreated,
128 };
129
130 //==============================================================================
133
134 //==============================================================================
136
138 void lockFile();
139 void unlockFile();
140
142
143 Engine& engine;
144 ProjectManager& projectManager;
145
146private:
147 friend class ProjectItem;
148 friend class ProjectManager;
149
150 juce::File file;
151 int projectId = 0;
152
153 juce::NamedValueSet properties;
154 juce::CriticalSection objectLock, propertyLock;
155
158
159 struct ObjectInfo
160 {
161 int itemID = 0, fileOffset = 0;
162 ProjectItem::Ptr item;
163 };
164
166 int objectOffset = 0, indexOffset = 0;
167 bool readOnly = false, hasChanged = false, temporary = false;
168
169 Project (Engine&, ProjectManager&, const juce::File&);
170
171 juce::BufferedInputStream* getInputStream();
172
173 void load();
174 void saveTo (juce::FileOutputStream&);
175 bool readProjectHeader (juce::InputStream&, bool clearObjectInfo = true);
176 void loadAllProjectItems();
177 bool loadProjectItem (ObjectInfo&);
178 void ensureFolderCreated (ProjectItem::Category);
179 void changed() override;
180
182 ProjectItem::Ptr quickAddProjectItem (const juce::String& relPathName,
183 const juce::String& type,
184 const juce::String& name,
185 const juce::String& description,
186 const ProjectItem::Category cat,
187 ProjectItemID newID);
188
190};
191
192}} // namespace tracktion { inline namespace engine
The Engine is the central class for all tracktion sessions.
An ID representing one of the items in a Project.
Represents a file-based resource that is used in a project.
void lockFile()
Stops anyone writing/moving the project file.
bool isValid() const
true if it's got a proper project ID.
bool save()
only saves if a change has been made since last time
void redirectIDsFromProject(int oldProjId, int newProjId)
Tells all exportables in all edits to change this project ID.
ProjectItem::Ptr createNewItem(const juce::File &fileToReference, const juce::String &type, const juce::String &name, const juce::String &description, const ProjectItem::Category cat, bool atTopOfList)
Returns an existing object if there is one.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
void searchFor(juce::Array< ProjectItemID > &results, SearchOperation &)
this will load the keyword table, and do a search
void refreshFolderStructure()
makes sure all media is in the correct sub folder
NagMode
General enum for requests that have a project setting and so can return true without asking the user.
@ nagAutoNo
Should not do task automatically.
@ nagAutoYes
Should do task automatically.
Base class for things that can be selected, and whose properties can appear in the properties panel.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)