Audacity 3.2.0
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Clipboard Class Referencefinal

#include <Clipboard.h>

Inheritance diagram for Clipboard:
[legend]
Collaboration diagram for Clipboard:
[legend]

Classes

struct  Scope
 Empty the clipboard at start of scope; restore its contents after. More...
 

Public Member Functions

const TrackListGetTracks () const
 
double T0 () const
 
double T1 () const
 
double Duration () const
 
const std::weak_ptr< AudacityProject > & Project () const
 
void Clear ()
 
void Assign (TrackList &&newContents, double t0, double t1, const std::weak_ptr< AudacityProject > &pProject)
 
 ~Clipboard ()
 
void Swap (Clipboard &other)
 
- Public Member Functions inherited from Observer::Publisher< ClipboardChangeMessage >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Static Public Member Functions

static ClipboardGet ()
 

Public Attributes

struct AUDACITY_DLL_API Scope
 

Private Member Functions

 Clipboard ()
 
 Clipboard (const Clipboard &)=delete
 
Clipboardoperator= (const Clipboard &)=delete
 

Private Attributes

std::shared_ptr< TrackListmTracks
 
std::weak_ptr< AudacityProjectmProject {}
 
double mT0 { 0 }
 
double mT1 { 0 }
 

Additional Inherited Members

- Public Types inherited from Observer::Publisher< ClipboardChangeMessage >
using message_type = ClipboardChangeMessage
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const ClipboardChangeMessage &) >
 Type of functions that can be connected to the Publisher. More...
 
- Static Public Attributes inherited from Observer::Publisher< ClipboardChangeMessage >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from Observer::Publisher< ClipboardChangeMessage >
CallbackReturn Publish (const ClipboardChangeMessage &message)
 Send a message to connected callbacks. More...
 

Detailed Description

Definition at line 26 of file Clipboard.h.

Constructor & Destructor Documentation

◆ ~Clipboard()

Clipboard::~Clipboard ( )
default

◆ Clipboard() [1/2]

Clipboard::Clipboard ( )
private

Definition at line 13 of file Clipboard.cpp.

14: mTracks { TrackList::Create( nullptr ) }
15{
16}
std::shared_ptr< TrackList > mTracks
Definition: Clipboard.h:63
static TrackListHolder Create(AudacityProject *pOwner)
Definition: Track.cpp:330

◆ Clipboard() [2/2]

Clipboard::Clipboard ( const Clipboard )
privatedelete

Member Function Documentation

◆ Assign()

void Clipboard::Assign ( TrackList &&  newContents,
double  t0,
double  t1,
const std::weak_ptr< AudacityProject > &  pProject 
)
Precondition
!newContents.GetOwner()

Definition at line 53 of file Clipboard.cpp.

55{
56 assert(!newContents.GetOwner());
57 newContents.Swap( *mTracks );
58 newContents.Clear();
59
60 mT0 = t0;
61 mT1 = t1;
62 mProject = pProject;
63
64 if (this == &Get())
65 // Delayed message at idle time
66 // Don't need to capture a weak pointer to the global object
67 BasicUI::CallAfter([this]{ Publish({}); });
68}
static Clipboard & Get()
Definition: Clipboard.cpp:28
std::weak_ptr< AudacityProject > mProject
Definition: Clipboard.h:64
double mT0
Definition: Clipboard.h:65
double mT1
Definition: Clipboard.h:66
CallbackReturn Publish(const ClipboardChangeMessage &message)
Send a message to connected callbacks.
Definition: Observer.h:207
void Swap(TrackList &that)
Definition: Track.cpp:346
AudacityProject * GetOwner()
Definition: Track.h:887
void Clear(bool sendEvent=true)
Make the list empty.
Definition: Track.cpp:605
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:213

References BasicUI::CallAfter(), Get(), mProject, mT0, mT1, mTracks, and Observer::Publisher< ClipboardChangeMessage >::Publish().

Here is the call graph for this function:

◆ Clear()

void Clipboard::Clear ( )

Definition at line 40 of file Clipboard.cpp.

41{
42 mT0 = 0.0;
43 mT1 = 0.0;
44 mProject.reset();
45 mTracks->Clear();
46
47 if (this == &Get())
48 // Delayed message at idle time
49 // Don't need to capture a weak pointer to the global object
50 BasicUI::CallAfter([this]{ Publish({}); });
51}

References BasicUI::CallAfter(), Get(), mProject, mT0, mT1, mTracks, and Observer::Publisher< ClipboardChangeMessage >::Publish().

Referenced by HistoryDialog::OnDiscardClipboard(), and QuitAudacity().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Duration()

double Clipboard::Duration ( ) const
inline

Definition at line 36 of file Clipboard.h.

36{ return mT1 - mT0; }

◆ Get()

Clipboard & Clipboard::Get ( )
static

◆ GetTracks()

const TrackList & Clipboard::GetTracks ( ) const

Definition at line 35 of file Clipboard.cpp.

36{
37 return *mTracks;
38}

References mTracks.

◆ operator=()

Clipboard & Clipboard::operator= ( const Clipboard )
privatedelete

◆ Project()

const std::weak_ptr< AudacityProject > & Clipboard::Project ( ) const
inline

Definition at line 38 of file Clipboard.h.

38{ return mProject; }

◆ Swap()

void Clipboard::Swap ( Clipboard other)

Definition at line 20 of file Clipboard.cpp.

21{
22 std::swap( mTracks, other.mTracks );
23 std::swap( mProject, other.mProject );
24 std::swap( mT0, other.mT0 );
25 std::swap( mT1, other.mT1 );
26}
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:628

References mProject, mT0, mT1, mTracks, and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by Clipboard::Scope::Scope(), and Clipboard::Scope::~Scope().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ T0()

double Clipboard::T0 ( ) const
inline

Definition at line 34 of file Clipboard.h.

34{ return mT0; }

◆ T1()

double Clipboard::T1 ( ) const
inline

Definition at line 35 of file Clipboard.h.

35{ return mT1; }

Member Data Documentation

◆ mProject

std::weak_ptr<AudacityProject> Clipboard::mProject {}
private

Definition at line 64 of file Clipboard.h.

Referenced by Assign(), Clear(), and Swap().

◆ mT0

double Clipboard::mT0 { 0 }
private

Definition at line 65 of file Clipboard.h.

Referenced by Assign(), Clear(), and Swap().

◆ mT1

double Clipboard::mT1 { 0 }
private

Definition at line 66 of file Clipboard.h.

Referenced by Assign(), Clear(), and Swap().

◆ mTracks

std::shared_ptr<TrackList> Clipboard::mTracks
private
Invariant
!mTracks->GetOwner()

Definition at line 63 of file Clipboard.h.

Referenced by Assign(), Clear(), GetTracks(), and Swap().

◆ Scope

struct AUDACITY_DLL_API Clipboard::Scope

Definition at line 53 of file Clipboard.h.


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