Audacity  3.0.3
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>
20 using FilePath = wxString;
21 
22 class AudacityProject;
23 
26 
34 class 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 
42 public:
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.
60  value_type Remove( AudacityProject &project );
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 
80  EVT_TRACK_PANEL_TIMER, wxCommandEvent);
81 
88 class PROJECT_API AudacityProject final
89  : public wxEvtHandler
90  , public AttachedProjectObjects
91  , public std::enable_shared_from_this<AudacityProject>
92 {
93  public:
95 
97  virtual ~AudacityProject();
98 
99  int GetProjectNumber(){ return mProjectNo;}
100 
101  // Project name can be either empty or have the name of the project.
102  //
103  // If empty, it signifies that the project is empty/unmodified or
104  // that the project hasn't yet been saved to a permanent project
105  // file.
106  //
107  // If a name has been assigned, it is merely used to identify
108  // the project and should not be used for any other purposes.
109  const wxString &GetProjectName() const;
110  void SetProjectName(const wxString &name);
111 
112  // Used exclusively in batch mode, this allows commands to remember
113  // and use the initial import path
114  FilePath GetInitialImportPath() const;
115  void SetInitialImportPath(const FilePath &path);
116 
117 private:
118 
119  // The project's name
120  wxString mName;
121 
122  static int mProjectCounter;// global counter.
123  int mProjectNo; // count when this project was created.
124 
126 
127  public:
128  bool mbBusyImporting{ false }; // used to fix bug 584
129  int mBatchMode{ 0 };// 0 means not, >0 means in batch mode.
130 };
131 
132 // Generate a registry for serialized data attached to the project
133 #include "XMLMethodRegistry.h"
134 class AudacityProject;
137 
138 #endif
size
size_t size
Definition: ffmpeg-2.3.6-single-header.h:412
XMLMethodRegistry.h
AttachedProjectObjects
ClientData::Site< AudacityProject, ClientData::Base, ClientData::SkipCopying, std::shared_ptr > AttachedProjectObjects
Definition: Project.h:77
AllProjects::const_iterator
Container::const_iterator const_iterator
Definition: Project.h:48
ClientData::Base
A convenient default parameter for class template Site.
Definition: ClientData.h:28
ClientData.h
Utility ClientData::Site to register hooks into a host class that attach client data.
AllProjects::Container
std::vector< AProjectHolder > Container
Definition: Project.h:39
ClientData::SkipCopying
@ SkipCopying
ignore the source and leave empty
Definition: ClientDataHelpers.h:34
AllProjects::empty
bool empty() const
Definition: Project.h:46
AudacityProject::mProjectNo
int mProjectNo
Definition: Project.h:123
AllProjects::AllProjects
AllProjects()=default
FilePath
wxString FilePath
Definition: Project.h:20
AllProjects::gAudacityProjects
static Container gAudacityProjects
Definition: Project.h:40
AudacityProject::GetProjectNumber
int GetProjectNumber()
Definition: Project.h:99
name
const TranslatableString name
Definition: Distortion.cpp:98
ClientData::Site
Utility to register hooks into a host class that attach client data.
Definition: ClientData.h:220
XMLMethodRegistry
Definition: XMLMethodRegistry.h:78
DECLARE_XML_METHOD_REGISTRY
DECLARE_XML_METHOD_REGISTRY(PROJECT_API, ProjectFileIORegistry)
AllProjects::AProjectHolder
std::shared_ptr< AudacityProject > AProjectHolder
Definition: Project.h:38
AllProjects::const_reverse_iterator
Container::const_reverse_iterator const_reverse_iterator
Definition: Project.h:52
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
AllProjects
Definition: Project.h:35
AudacityProject::mName
wxString mName
Definition: Project.h:120
wxDECLARE_EXPORTED_EVENT
wxDECLARE_EXPORTED_EVENT(PROJECT_API, EVT_TRACK_PANEL_TIMER, wxCommandEvent)
ActiveProjects::Remove
void Remove(const FilePath &path)
ActiveProjects::Add
void Add(const FilePath &path)
AudacityProject::mProjectCounter
static int mProjectCounter
Definition: Project.h:122
AllProjects::value_type
Container::value_type value_type
Definition: Project.h:56
AudacityProject::mInitialImportPath
FilePath mInitialImportPath
Definition: Project.h:125