Audacity  3.2.0
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 size_t AllProjects::size() const
18 {
19  return gAudacityProjects.size();
20 }
21 
23 {
24  return gAudacityProjects.begin();
25 }
26 
28 {
29  return gAudacityProjects.end();
30 }
31 
33 {
34  return gAudacityProjects.rbegin();
35 }
36 
38 {
39  return gAudacityProjects.rend();
40 }
41 
43 {
44  std::lock_guard<std::mutex> guard{ Mutex() };
45  auto start = begin(), finish = end(), iter = std::find_if(
46  start, finish,
47  [&]( const value_type &ptr ){ return ptr.get() == &project; }
48  );
49  if (iter == finish)
50  return nullptr;
51  auto result = *iter;
52  gAudacityProjects.erase( iter );
53  return result;
54 }
55 
56 void AllProjects::Add( const value_type &pProject )
57 {
58  if (!pProject) {
59  wxASSERT(false);
60  return;
61  }
62  std::lock_guard<std::mutex> guard{ Mutex() };
63  gAudacityProjects.push_back( pProject );
64 }
65 
66 std::mutex &AllProjects::Mutex()
67 {
68  static std::mutex theMutex;
69  return theMutex;
70 }
71 
72 int AudacityProject::mProjectCounter=0;// global counter.
73 
74 /* Define Global Variables */
75 //This array holds onto all of the projects currently open
77 
79 {
80  mProjectNo = mProjectCounter++; // Bug 322
82  // But not for the attached windows. They get built only on demand, such as
83  // from menu items.
84 }
85 
87 {
88 }
89 
90 const wxString &AudacityProject::GetProjectName() const
91 {
92  return mName;
93 }
94 
96 {
97  mName = name;
98 }
99 
101 {
102  return mInitialImportPath;
103 }
104 
106 {
107  if (mInitialImportPath.empty())
108  {
109  mInitialImportPath = path;
110  }
111 }
112 
113 // Generate the needed, linkable registry functions
DEFINE_XML_METHOD_REGISTRY
DEFINE_XML_METHOD_REGISTRY(ProjectFileIORegistry)
AllProjects::begin
const_iterator begin() const
Definition: Project.cpp:22
Project.h
AudacityProject::~AudacityProject
virtual ~AudacityProject()
Definition: Project.cpp:86
AllProjects::const_iterator
Container::const_iterator const_iterator
Definition: Project.h:48
AllProjects::end
const_iterator end() const
Definition: Project.cpp:27
AudacityProject::SetInitialImportPath
void SetInitialImportPath(const FilePath &path)
Definition: Project.cpp:105
AllProjects::Container
std::vector< AProjectHolder > Container
Definition: Project.h:39
AudacityProject::AudacityProject
AudacityProject()
Definition: Project.cpp:78
AllProjects::Remove
value_type Remove(AudacityProject &project)
Definition: Project.cpp:42
AudacityProject::GetInitialImportPath
FilePath GetInitialImportPath() const
Definition: Project.cpp:100
AllProjects::size
size_t size() const
Definition: Project.cpp:17
AudacityProject::mProjectNo
int mProjectNo
Definition: Project.h:120
AllProjects::rbegin
const_reverse_iterator rbegin() const
Definition: Project.cpp:32
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:56
name
const TranslatableString name
Definition: Distortion.cpp:98
XMLMethodRegistry
Definition: XMLMethodRegistry.h:87
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:89
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:117
AllProjects::Mutex
static std::mutex & Mutex()
Definition: Project.cpp:66
AudacityProject::SetProjectName
void SetProjectName(const wxString &name)
Definition: Project.cpp:95
AudacityProject::GetProjectName
const wxString & GetProjectName() const
Definition: Project.cpp:90
AudacityProject::mProjectCounter
static int mProjectCounter
Definition: Project.h:119
AllProjects::value_type
Container::value_type value_type
Definition: Project.h:56
AllProjects::rend
const_reverse_iterator rend() const
Definition: Project.cpp:37
AudacityProject::mInitialImportPath
FilePath mInitialImportPath
Definition: Project.h:122