Audacity 3.2.0
Project.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Project.h
6
7 Dominic Mazzoni
8
9**********************************************************************/
10
11#ifndef __AUDACITY_PROJECT__
12#define __AUDACITY_PROJECT__
13
14#include "ClientData.h" // to inherit
15
16#include <memory>
17#include <mutex>
18
19#include <wx/event.h>
20using FilePath = wxString;
21
22class AudacityProject;
23
26
34class PROJECT_API AllProjects
35{
36
37 // Use shared_ptr to projects, because elsewhere we need weak_ptr
38 using AProjectHolder = std::shared_ptr< AudacityProject >;
39 using Container = std::vector< AProjectHolder >;
41
42public:
43 AllProjects() = default;
44
45 size_t size() const;
46 bool empty() const { return size() == 0; }
47
48 using const_iterator = Container::const_iterator;
49 const_iterator begin() const;
50 const_iterator end() const;
51
52 using const_reverse_iterator = Container::const_reverse_iterator;
53 const_reverse_iterator rbegin() const;
54 const_reverse_iterator rend() const;
55
56 using value_type = Container::value_type;
57
58 // If the project is present, remove it from the global array and return
59 // a shared pointer, else return null. This invalidates any iterators.
61
63
66 void Add( const value_type &pProject );
67
70 static std::mutex &Mutex();
71};
72
73// Container of various objects associated with the project, which is
74// responsible for destroying them
77>;
78
85class PROJECT_API AudacityProject final
86 : public wxEvtHandler
88 , public std::enable_shared_from_this<AudacityProject>
89{
90 struct CreateToken{};
91 public:
93
95 static std::shared_ptr<AudacityProject> Create();
98 virtual ~AudacityProject();
99
100 int GetProjectNumber(){ return mProjectNo;}
101
102 // Project name can be either empty or have the name of the project.
103 //
104 // If empty, it signifies that the project is empty/unmodified or
105 // that the project hasn't yet been saved to a permanent project
106 // file.
107 //
108 // If a name has been assigned, it is merely used to identify
109 // the project and should not be used for any other purposes.
110 const wxString &GetProjectName() const;
111 void SetProjectName(const wxString &name);
112
113 // Used exclusively in batch mode, this allows commands to remember
114 // and use the initial import path
115 FilePath GetInitialImportPath() const;
116 void SetInitialImportPath(const FilePath &path);
117
118private:
119
120 // The project's name
121 wxString mName;
122
123 static int mProjectCounter;// global counter.
124 int mProjectNo; // count when this project was created.
125
127
128 public:
129 bool mbBusyImporting{ false }; // used to fix bug 584
130 int mBatchMode{ 0 };// 0 means not, >0 means in batch mode.
131};
132
133// Generate a registry for serialized data attached to the project
134#include "XMLMethodRegistry.h"
135class AudacityProject;
138
139#endif
Utility ClientData::Site to register hooks into a host class that attach client data.
const TranslatableString name
Definition: Distortion.cpp:82
wxString FilePath
Definition: Project.h:20
ClientData::Site< AudacityProject, ClientData::Base, ClientData::SkipCopying, std::shared_ptr > AttachedProjectObjects
Definition: Project.h:77
DECLARE_XML_METHOD_REGISTRY(PROJECT_API, ProjectFileIORegistry)
static Container gAudacityProjects
Definition: Project.h:40
std::vector< AProjectHolder > Container
Definition: Project.h:39
Container::const_reverse_iterator const_reverse_iterator
Definition: Project.h:52
Container::const_iterator const_iterator
Definition: Project.h:48
AllProjects()=default
Container::value_type value_type
Definition: Project.h:56
std::shared_ptr< AudacityProject > AProjectHolder
Definition: Project.h:38
bool empty() const
Definition: Project.h:46
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
int GetProjectNumber()
Definition: Project.h:100
FilePath mInitialImportPath
Definition: Project.h:126
wxString mName
Definition: Project.h:121
static int mProjectCounter
Definition: Project.h:123
Utility to register hooks into a host class that attach client data.
Definition: ClientData.h:220
void Add(const FilePath &path)
void Remove(const FilePath &path)
@ SkipCopying
ignore the source and leave empty
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150
A convenient default parameter for class template Site.
Definition: ClientData.h:28