Audacity  2.2.2
Public Member Functions | Private Types | Private Member Functions | List of all members
GetProjectInfoCommand Class Referencefinal

Command that returns requested project information. More...

#include <GetProjectInfoCommand.h>

Inheritance diagram for GetProjectInfoCommand:
CommandImplementation Command

Public Member Functions

 GetProjectInfoCommand (CommandType &type, std::unique_ptr< CommandOutputTarget > &&target)
 
virtual ~GetProjectInfoCommand ()
 
bool Apply (CommandExecutionContext context) override
 
- Public Member Functions inherited from CommandImplementation
void Progress (double completed)
 
void Status (const wxString &status) override
 
void Error (const wxString &message) override
 
 CommandImplementation (CommandType &type, std::unique_ptr< CommandOutputTarget > &&output)
 
virtual ~CommandImplementation ()
 
wxString GetName ()
 An instance method for getting the command name (for consistency) More...
 
CommandSignatureGetSignature ()
 Get the signature of the command. More...
 
bool SetParameter (const wxString &paramName, const wxVariant &paramValue)
 
- Public Member Functions inherited from Command
virtual ~Command ()
 

Private Types

typedef bool(GetProjectInfoCommand::* Getter )(const Track *track) const
 

Private Member Functions

int SendNumberOfTracks (CommandExecutionContext context)
 
int SendFocusedTrackIndex (CommandExecutionContext context)
 
void SendTracksInfo (TrackList *projTracks, Getter)
 
bool testSelected (const Track *track) const
 
bool testLinked (const Track *track) const
 
bool testSolo (const Track *track) const
 
bool testMute (const Track *track) const
 

Additional Inherited Members

- Protected Member Functions inherited from CommandImplementation
void TypeCheck (const wxString &typeName, const wxString &paramName, const wxVariant &param)
 
void CheckParam (const wxString &paramName)
 
bool HasParam (const wxString &paramName)
 
bool GetBool (const wxString &paramName)
 
long GetLong (const wxString &paramName)
 
double GetDouble (const wxString &paramName)
 
wxString GetString (const wxString &paramName)
 
- Protected Attributes inherited from CommandImplementation
std::unique_ptr
< CommandOutputTarget
mOutput
 

Detailed Description

Command that returns requested project information.

Definition at line 31 of file GetProjectInfoCommand.h.

Member Typedef Documentation

typedef bool(GetProjectInfoCommand::* GetProjectInfoCommand::Getter)(const Track *track) const
private

Definition at line 47 of file GetProjectInfoCommand.h.

Constructor & Destructor Documentation

GetProjectInfoCommand::GetProjectInfoCommand ( CommandType type,
std::unique_ptr< CommandOutputTarget > &&  target 
)
inline

Definition at line 34 of file GetProjectInfoCommand.h.

35  : CommandImplementation(type, std::move(target))
36  { }
CommandImplementation(CommandType &type, std::unique_ptr< CommandOutputTarget > &&output)
Definition: Command.cpp:95
virtual GetProjectInfoCommand::~GetProjectInfoCommand ( )
inlinevirtual

Definition at line 37 of file GetProjectInfoCommand.h.

38  { }

Member Function Documentation

bool GetProjectInfoCommand::Apply ( CommandExecutionContext  context)
overridevirtual

Actually carry out the command. Return true if successful and false otherwise.

Reimplemented from CommandImplementation.

Definition at line 49 of file GetProjectInfoCommand.cpp.

References CommandImplementation::Error(), AudacityProject::GetFileName(), CommandExecutionContext::GetProject(), CommandImplementation::GetString(), AudacityProject::GetTracks(), SendFocusedTrackIndex(), SendNumberOfTracks(), SendTracksInfo(), CommandImplementation::Status(), testLinked(), testMute(), testSelected(), and testSolo().

50 {
51  wxString mode = GetString(wxT("Type"));
52  TrackList *projTracks = context.GetProject()->GetTracks();
53 
54  if (mode.IsSameAs(wxT("Name")))
55  {
56  Status(context.GetProject()->GetFileName());
57  }
58  else if (mode.IsSameAs(wxT("FocusedTrackID")))
59  {
60  SendFocusedTrackIndex(context);
61  }
62  else if (mode.IsSameAs(wxT("NumberOfTracks")))
63  {
64  SendNumberOfTracks(context);
65  }
66  else if (mode.IsSameAs(wxT("SelectedTracks")))
67  {
69  }
70  else if (mode.IsSameAs(wxT("LinkedTracks")))
71  {
73  }
74  else if (mode.IsSameAs(wxT("SoloTracks")))
75  {
77  }
78  else if (mode.IsSameAs(wxT("MuteTracks")))
79  {
81  }
82  else
83  {
84  Error(wxT("Invalid info type!"));
85  return false;
86  }
87  return true;
88 }
A list of TrackListNode items.
Definition: Track.h:612
int SendNumberOfTracks(CommandExecutionContext context)
wxString GetString(const wxString &paramName)
Definition: Command.cpp:165
bool testSelected(const Track *track) const
bool testSolo(const Track *track) const
bool testMute(const Track *track) const
void Status(const wxString &status) override
Definition: Command.cpp:179
bool testLinked(const Track *track) const
int SendFocusedTrackIndex(CommandExecutionContext context)
TrackList * GetTracks()
Definition: Project.h:174
AudacityProject * GetProject() const
Definition: Command.h:60
void SendTracksInfo(TrackList *projTracks, Getter)
const wxString & GetFileName()
Definition: Project.h:284
void Error(const wxString &message) override
Definition: Command.cpp:184
int GetProjectInfoCommand::SendFocusedTrackIndex ( CommandExecutionContext  context)
private

Definition at line 109 of file GetProjectInfoCommand.cpp.

References TrackPanel::GetFocusedTrack(), CommandExecutionContext::GetProject(), AudacityProject::GetTrackPanel(), AudacityProject::GetTracks(), and CommandImplementation::Status().

Referenced by Apply().

110 {
111  int returnVal=0;
112  int focusTrackIndex=0;
113  TrackPanel *panel = context.GetProject()->GetTrackPanel();
114  Track* focusedTrack = panel->GetFocusedTrack();
115 
116  TrackListIterator iter(context.GetProject()->GetTracks());
117  Track *t = iter.First();
118  while (t)
119  {
120  if(t == focusedTrack) // when we've found the focused track, we know the trackIndex
121  {
122  returnVal = focusTrackIndex;
123  break;
124  }
125  focusTrackIndex++;
126  t = iter.Next();
127  }
128  wxString trackIndexStr;
129  trackIndexStr << returnVal; // convert to a string to send over named pipe
130  Status(trackIndexStr);
131  return returnVal;
132 }
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:245
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:95
void Status(const wxString &status) override
Definition: Command.cpp:179
An iterator for a TrackList.
Definition: Track.h:395
Track * GetFocusedTrack()
TrackPanel * GetTrackPanel()
Definition: Project.h:289
TrackList * GetTracks()
Definition: Project.h:174
AudacityProject * GetProject() const
Definition: Command.h:60
int GetProjectInfoCommand::SendNumberOfTracks ( CommandExecutionContext  context)
private

Definition at line 92 of file GetProjectInfoCommand.cpp.

References CommandExecutionContext::GetProject(), AudacityProject::GetTracks(), and CommandImplementation::Status().

Referenced by Apply().

93 {
94  int returnVal=0;
95 
96  TrackListIterator iter(context.GetProject()->GetTracks());
97  Track *t = iter.First();
98  while (t)
99  {
100  returnVal++;
101  t = iter.Next();
102  }
103  wxString trackNumStr;
104  trackNumStr << returnVal; // convert to a string to send over named pipe
105  Status(trackNumStr);
106  return returnVal;
107 }
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:95
void Status(const wxString &status) override
Definition: Command.cpp:179
An iterator for a TrackList.
Definition: Track.h:395
TrackList * GetTracks()
Definition: Project.h:174
AudacityProject * GetProject() const
Definition: Command.h:60
void GetProjectInfoCommand::SendTracksInfo ( TrackList projTracks,
Getter  functPtrToGetter 
)
private

Definition at line 135 of file GetProjectInfoCommand.cpp.

References TrackListIterator::First(), TrackListIterator::Next(), and CommandImplementation::Status().

Referenced by Apply().

137 {
138  wxString boolValueStr;
139  TrackListIterator iter(projTracks);
140  Track *trk = iter.First();
141  while (trk)
142  {
143  if( (this->*functPtrToGetter)(trk)) // Function Pointer to the desired parameter to Test
144  boolValueStr.Append(wxT("1"),1);
145  else
146  boolValueStr.Append(wxT("0"),1);
147  trk = iter.Next();
148  }
149  Status(boolValueStr);
150 }
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:95
void Status(const wxString &status) override
Definition: Command.cpp:179
An iterator for a TrackList.
Definition: Track.h:395
bool GetProjectInfoCommand::testLinked ( const Track track) const
private

Definition at line 157 of file GetProjectInfoCommand.cpp.

References Track::GetLinked().

Referenced by Apply().

158 {
159  return track->GetLinked();
160 }
bool GetLinked() const
Definition: Track.h:272
bool GetProjectInfoCommand::testMute ( const Track track) const
private

Definition at line 168 of file GetProjectInfoCommand.cpp.

References PlayableTrack::GetMute().

Referenced by Apply().

169 {
170  auto pt = dynamic_cast<const PlayableTrack *>(track);
171  return pt && pt->GetMute();
172 }
An AudioTrack that can be played and stopped.
Definition: Track.h:369
bool GetMute() const
Definition: Track.h:376
bool GetProjectInfoCommand::testSelected ( const Track track) const
private

Definition at line 152 of file GetProjectInfoCommand.cpp.

References Track::GetSelected().

Referenced by Apply().

153 {
154  return track->GetSelected();
155 }
bool GetSelected() const
Definition: Track.h:269
bool GetProjectInfoCommand::testSolo ( const Track track) const
private

Definition at line 162 of file GetProjectInfoCommand.cpp.

References PlayableTrack::GetSolo().

Referenced by Apply().

163 {
164  auto pt = dynamic_cast<const PlayableTrack *>(track);
165  return pt && pt->GetSolo();
166 }
bool GetSolo() const
Definition: Track.h:377
An AudioTrack that can be played and stopped.
Definition: Track.h:369

The documentation for this class was generated from the following files: