Audacity  3.0.3
Project.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  Project.cpp
6 
7  Dominic Mazzoni
8  Vaughan Johnson
9 
10 *//*******************************************************************/
11 
12 #include "Project.h"
13 
14 #include <wx/display.h>
15 #include <wx/filename.h>
16 
17 wxDEFINE_EVENT(EVT_TRACK_PANEL_TIMER, wxCommandEvent);
18 
19 size_t AllProjects::size() const
20 {
21  return gAudacityProjects.size();
22 }
23 
25 {
26  return gAudacityProjects.begin();
27 }
28 
30 {
31  return gAudacityProjects.end();
32 }
33 
35 {
36  return gAudacityProjects.rbegin();
37 }
38 
40 {
41  return gAudacityProjects.rend();
42 }
43 
45 {
46  std::lock_guard<std::mutex> guard{ Mutex() };
47  auto start = begin(), finish = end(), iter = std::find_if(
48  start, finish,
49  [&]( const value_type &ptr ){ return ptr.get() == &project; }
50  );
51  if (iter == finish)
52  return nullptr;
53  auto result = *iter;
54  gAudacityProjects.erase( iter );
55  return result;
56 }
57 
58 void AllProjects::Add( const value_type &pProject )
59 {
60  if (!pProject) {
61  wxASSERT(false);
62  return;
63  }
64  std::lock_guard<std::mutex> guard{ Mutex() };
65  gAudacityProjects.push_back( pProject );
66 }
67 
68 std::mutex &AllProjects::Mutex()
69 {
70  static std::mutex theMutex;
71  return theMutex;
72 }
73 
74 int AudacityProject::mProjectCounter=0;// global counter.
75 
76 /* Define Global Variables */
77 //This array holds onto all of the projects currently open
79 
81 {
82  mProjectNo = mProjectCounter++; // Bug 322
84  // But not for the attached windows. They get built only on demand, such as
85  // from menu items.
86 }
87 
89 {
90 }
91 
92 const wxString &AudacityProject::GetProjectName() const
93 {
94  return mName;
95 }
96 
98 {
99  mName = name;
100 }
101 
103 {
104  return mInitialImportPath;
105 }
106 
108 {
109  if (mInitialImportPath.empty())
110  {
111  mInitialImportPath = path;
112  }
113 }
114 
115 // Generate the needed, linkable registry functions
DEFINE_XML_METHOD_REGISTRY
DEFINE_XML_METHOD_REGISTRY(ProjectFileIORegistry)
AllProjects::begin
const_iterator begin() const
Definition: Project.cpp:24
Project.h
AudacityProject::~AudacityProject
virtual ~AudacityProject()
Definition: Project.cpp:88
AllProjects::const_iterator
Container::const_iterator const_iterator
Definition: Project.h:48
AllProjects::end
const_iterator end() const
Definition: Project.cpp:29
AudacityProject::SetInitialImportPath
void SetInitialImportPath(const FilePath &path)
Definition: Project.cpp:107
AllProjects::Container
std::vector< AProjectHolder > Container
Definition: Project.h:39
AudacityProject::AudacityProject
AudacityProject()
Definition: Project.cpp:80
AllProjects::Remove
value_type Remove(AudacityProject &project)
Definition: Project.cpp:44
AudacityProject::GetInitialImportPath
FilePath GetInitialImportPath() const
Definition: Project.cpp:102
AllProjects::size
size_t size() const
Definition: Project.cpp:19
AudacityProject::mProjectNo
int mProjectNo
Definition: Project.h:123
AllProjects::rbegin
const_reverse_iterator rbegin() const
Definition: Project.cpp:34
FilePath
wxString FilePath
Definition: Project.h:20
AllProjects::gAudacityProjects
static Container gAudacityProjects
Definition: Project.h:40
AllProjects::Add
void Add(const value_type &pProject)
This invalidates iterators.
Definition: Project.cpp:58
name
const TranslatableString name
Definition: Distortion.cpp:98
XMLMethodRegistry
Definition: XMLMethodRegistry.h:78
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
ClientData::Site::BuildAll
void BuildAll()
For each RegisteredFactory, if the corresponding attachment is absent in this, build and store it.
Definition: ClientData.h:441
AudacityProject::mName
wxString mName
Definition: Project.h:120
AllProjects::Mutex
static std::mutex & Mutex()
Definition: Project.cpp:68
wxDEFINE_EVENT
wxDEFINE_EVENT(EVT_TRACK_PANEL_TIMER, wxCommandEvent)
AudacityProject::SetProjectName
void SetProjectName(const wxString &name)
Definition: Project.cpp:97
AudacityProject::GetProjectName
const wxString & GetProjectName() const
Definition: Project.cpp:92
AudacityProject::mProjectCounter
static int mProjectCounter
Definition: Project.h:122
AllProjects::value_type
Container::value_type value_type
Definition: Project.h:56
AllProjects::rend
const_reverse_iterator rend() const
Definition: Project.cpp:39
AudacityProject::mInitialImportPath
FilePath mInitialImportPath
Definition: Project.h:125