mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-17 16:50:26 +02:00
New library for registries
This commit is contained in:
parent
31515085c5
commit
ed3e4de17b
@ -13,6 +13,7 @@ set( LIBRARIES
|
|||||||
lib-preferences
|
lib-preferences
|
||||||
lib-math
|
lib-math
|
||||||
lib-files
|
lib-files
|
||||||
|
lib-registries
|
||||||
)
|
)
|
||||||
|
|
||||||
if ( ${_OPT}has_networking )
|
if ( ${_OPT}has_networking )
|
||||||
|
47
libraries/lib-registries/CMakeLists.txt
Normal file
47
libraries/lib-registries/CMakeLists.txt
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#[[
|
||||||
|
Some utilities for allowing open-endedness and decoupling of designs, by
|
||||||
|
maintaining global tables that can be populated at static initialization by
|
||||||
|
code in scattered places, on which the registry has no build dependency.
|
||||||
|
|
||||||
|
AttachedVirtualFunction implements "open methods" -- functions that type-switch
|
||||||
|
on the first argument, and dispatch to the correct implementation, but without
|
||||||
|
intrusiveness into the base of the class hierarchy. This allows the set of
|
||||||
|
methods and the set of subclasses both to be open-ended.
|
||||||
|
|
||||||
|
(That is unlike in the "Gang of Four" Visitor pattern, in which the set of
|
||||||
|
methods becomes open-ended while the set of subclasses is closed-ended: the
|
||||||
|
Visitor can't handle a new subclass without intrusion into the abstract
|
||||||
|
Visitor definition.)
|
||||||
|
|
||||||
|
ClientData allows a "Site" class to act as a container of attached objects
|
||||||
|
produced by registered factory functions, and retrieved by the various attaching
|
||||||
|
modules. The Site's constructor is effectively hookable. This in particular
|
||||||
|
allows the Project object to be low-level in the graph of file dependencies,
|
||||||
|
while it is also the top-level object of an ownership tree of various important
|
||||||
|
sub-structures. This is another "Dependency Inversion" of sorts (the D
|
||||||
|
principle of SOLID).
|
||||||
|
|
||||||
|
Registry implements trees of objects identified by textual paths, and allows
|
||||||
|
scattered code to insert items or subtrees at specified paths. Registry
|
||||||
|
computes the merging of trees, and supports visitation. It is used notably
|
||||||
|
by the tree of menus, allowing insertion of menu items in decoupled code.
|
||||||
|
]]#
|
||||||
|
|
||||||
|
set( SOURCES
|
||||||
|
AttachedVirtualFunction.h
|
||||||
|
ClientData.cpp
|
||||||
|
ClientData.h
|
||||||
|
ClientDataHelpers.h
|
||||||
|
Registrar.h
|
||||||
|
Registry.cpp
|
||||||
|
Registry.h
|
||||||
|
)
|
||||||
|
set( LIBRARIES
|
||||||
|
lib-preferences-interface
|
||||||
|
lib-exceptions
|
||||||
|
PRIVATE
|
||||||
|
wxBase
|
||||||
|
)
|
||||||
|
audacity_library( lib-registries "${SOURCES}" "${LIBRARIES}"
|
||||||
|
"" ""
|
||||||
|
)
|
15
libraries/lib-registries/ClientData.cpp
Normal file
15
libraries/lib-registries/ClientData.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/*!********************************************************************
|
||||||
|
|
||||||
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
|
@file ClientData.cpp
|
||||||
|
|
||||||
|
Paul Licameli
|
||||||
|
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#include "ClientData.h"
|
||||||
|
|
||||||
|
// These are needed out-of-line for the Windows link
|
||||||
|
ClientData::Base::~Base() = default;
|
||||||
|
template<> ClientData::Cloneable<>::~Cloneable() = default;
|
@ -24,9 +24,9 @@ Paul Licameli
|
|||||||
namespace ClientData {
|
namespace ClientData {
|
||||||
|
|
||||||
//! A convenient default parameter for class template @b Site
|
//! A convenient default parameter for class template @b Site
|
||||||
struct AUDACITY_DLL_API Base
|
struct REGISTRIES_API Base
|
||||||
{
|
{
|
||||||
virtual ~Base() {}
|
virtual ~Base();
|
||||||
};
|
};
|
||||||
|
|
||||||
//! A one-argument alias template for the default template-template parameter of ClientData::Site
|
//! A one-argument alias template for the default template-template parameter of ClientData::Site
|
||||||
@ -44,12 +44,12 @@ template< typename Object > using BarePtr = Object*;
|
|||||||
*/
|
*/
|
||||||
template<
|
template<
|
||||||
template<typename> class Owner = UniquePtr
|
template<typename> class Owner = UniquePtr
|
||||||
> struct AUDACITY_DLL_API Cloneable
|
> struct REGISTRIES_API Cloneable
|
||||||
{
|
{
|
||||||
using Base = Cloneable;
|
using Base = Cloneable;
|
||||||
using PointerType = Owner< Base >;
|
using PointerType = Owner< Base >;
|
||||||
|
|
||||||
virtual ~Cloneable() {}
|
virtual ~Cloneable();
|
||||||
virtual PointerType Clone() const = 0;
|
virtual PointerType Clone() const = 0;
|
||||||
};
|
};
|
||||||
|
|
@ -29,7 +29,7 @@ class LoadableModule;
|
|||||||
class ComponentInterface;
|
class ComponentInterface;
|
||||||
class Effect;
|
class Effect;
|
||||||
|
|
||||||
class AUDACITY_DLL_API Registrar
|
class REGISTRIES_API Registrar
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Registrar(){
|
Registrar(){
|
@ -14,7 +14,7 @@ Paul Licameli split from Menus.cpp
|
|||||||
|
|
||||||
#include <wx/log.h>
|
#include <wx/log.h>
|
||||||
|
|
||||||
#include "widgets/AudacityMessageBox.h"
|
#include "BasicUI.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ using Path = std::vector< Identifier >;
|
|||||||
wxLogDebug( msg.Translation() );
|
wxLogDebug( msg.Translation() );
|
||||||
#ifdef IS_ALPHA
|
#ifdef IS_ALPHA
|
||||||
// user-visible message
|
// user-visible message
|
||||||
AudacityMessageBox( msg );
|
BasicUI::ShowMessageBox( msg );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -56,7 +56,7 @@ namespace Registry {
|
|||||||
// Most items in the table will be the large ones describing commands, so the
|
// Most items in the table will be the large ones describing commands, so the
|
||||||
// waste of space in unions for separators and sub-menus should not be
|
// waste of space in unions for separators and sub-menus should not be
|
||||||
// large.
|
// large.
|
||||||
struct AUDACITY_DLL_API BaseItem {
|
struct REGISTRIES_API BaseItem {
|
||||||
// declare at least one virtual function so dynamic_cast will work
|
// declare at least one virtual function so dynamic_cast will work
|
||||||
explicit
|
explicit
|
||||||
BaseItem( const Identifier &internalName )
|
BaseItem( const Identifier &internalName )
|
||||||
@ -79,7 +79,7 @@ namespace Registry {
|
|||||||
// static tables of items to be computed once and reused
|
// static tables of items to be computed once and reused
|
||||||
// The name of the delegate is significant for path calculations, but the
|
// The name of the delegate is significant for path calculations, but the
|
||||||
// SharedItem's ordering hint is used if the delegate has none
|
// SharedItem's ordering hint is used if the delegate has none
|
||||||
struct AUDACITY_DLL_API SharedItem final : BaseItem {
|
struct REGISTRIES_API SharedItem final : BaseItem {
|
||||||
explicit SharedItem( const BaseItemSharedPtr &ptr_ )
|
explicit SharedItem( const BaseItemSharedPtr &ptr_ )
|
||||||
: BaseItem{ wxEmptyString }
|
: BaseItem{ wxEmptyString }
|
||||||
, ptr{ ptr_ }
|
, ptr{ ptr_ }
|
||||||
@ -97,7 +97,7 @@ namespace Registry {
|
|||||||
// the ComputedItem is visited
|
// the ComputedItem is visited
|
||||||
// The name of the substitute is significant for path calculations, but the
|
// The name of the substitute is significant for path calculations, but the
|
||||||
// ComputedItem's ordering hint is used if the substitute has none
|
// ComputedItem's ordering hint is used if the substitute has none
|
||||||
struct AUDACITY_DLL_API ComputedItem final : BaseItem {
|
struct REGISTRIES_API ComputedItem final : BaseItem {
|
||||||
// The type of functions that generate descriptions of items.
|
// The type of functions that generate descriptions of items.
|
||||||
// Return type is a shared_ptr to let the function decide whether to
|
// Return type is a shared_ptr to let the function decide whether to
|
||||||
// recycle the object or rebuild it on demand each time.
|
// recycle the object or rebuild it on demand each time.
|
||||||
@ -117,13 +117,13 @@ namespace Registry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Common abstract base class for items that are not groups
|
// Common abstract base class for items that are not groups
|
||||||
struct AUDACITY_DLL_API SingleItem : BaseItem {
|
struct REGISTRIES_API SingleItem : BaseItem {
|
||||||
using BaseItem::BaseItem;
|
using BaseItem::BaseItem;
|
||||||
~SingleItem() override = 0;
|
~SingleItem() override = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Common abstract base class for items that group other items
|
// Common abstract base class for items that group other items
|
||||||
struct AUDACITY_DLL_API GroupItem : BaseItem {
|
struct REGISTRIES_API GroupItem : BaseItem {
|
||||||
using BaseItem::BaseItem;
|
using BaseItem::BaseItem;
|
||||||
|
|
||||||
// Construction from an internal name and a previously built-up
|
// Construction from an internal name and a previously built-up
|
||||||
@ -231,14 +231,14 @@ namespace Registry {
|
|||||||
// The sequence of calls to RegisterItem has no significance for
|
// The sequence of calls to RegisterItem has no significance for
|
||||||
// determining the visitation ordering. When sequence is important, register
|
// determining the visitation ordering. When sequence is important, register
|
||||||
// a GroupItem.
|
// a GroupItem.
|
||||||
AUDACITY_DLL_API
|
REGISTRIES_API
|
||||||
void RegisterItem( GroupItem ®istry, const Placement &placement,
|
void RegisterItem( GroupItem ®istry, const Placement &placement,
|
||||||
BaseItemPtr pItem );
|
BaseItemPtr pItem );
|
||||||
|
|
||||||
// Define actions to be done in Visit.
|
// Define actions to be done in Visit.
|
||||||
// Default implementations do nothing
|
// Default implementations do nothing
|
||||||
// The supplied path does not include the name of the item
|
// The supplied path does not include the name of the item
|
||||||
class AUDACITY_DLL_API Visitor
|
class REGISTRIES_API Visitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Visitor();
|
virtual ~Visitor();
|
||||||
@ -257,7 +257,7 @@ namespace Registry {
|
|||||||
// seen in the registry for the first time is placed somehere, and that
|
// seen in the registry for the first time is placed somehere, and that
|
||||||
// ordering should be kept the same thereafter in later runs (which may add
|
// ordering should be kept the same thereafter in later runs (which may add
|
||||||
// yet other previously unknown items).
|
// yet other previously unknown items).
|
||||||
void Visit(
|
REGISTRIES_API void Visit(
|
||||||
Visitor &visitor,
|
Visitor &visitor,
|
||||||
BaseItem *pTopItem,
|
BaseItem *pTopItem,
|
||||||
const GroupItem *pRegistry = nullptr );
|
const GroupItem *pRegistry = nullptr );
|
||||||
@ -269,7 +269,7 @@ namespace Registry {
|
|||||||
// registry of plug-ins, and something must be done to preserve old
|
// registry of plug-ins, and something must be done to preserve old
|
||||||
// behavior. It can be done in the central place using string literal
|
// behavior. It can be done in the central place using string literal
|
||||||
// identifiers only, not requiring static compilation or linkage dependency.
|
// identifiers only, not requiring static compilation or linkage dependency.
|
||||||
struct AUDACITY_DLL_API
|
struct REGISTRIES_API
|
||||||
OrderingPreferenceInitializer : PreferenceInitializer {
|
OrderingPreferenceInitializer : PreferenceInitializer {
|
||||||
using Literal = const wxChar *;
|
using Literal = const wxChar *;
|
||||||
using Pair = std::pair< Literal, Literal >;
|
using Pair = std::pair< Literal, Literal >;
|
@ -84,7 +84,6 @@ list( APPEND SOURCES
|
|||||||
AdornedRulerPanel.h
|
AdornedRulerPanel.h
|
||||||
AllThemeResources.cpp
|
AllThemeResources.cpp
|
||||||
AllThemeResources.h
|
AllThemeResources.h
|
||||||
AttachedVirtualFunction.h
|
|
||||||
AudacityApp.cpp
|
AudacityApp.cpp
|
||||||
AudacityApp.h
|
AudacityApp.h
|
||||||
$<$<BOOL:${wxIS_MAC}>:AudacityApp.mm>
|
$<$<BOOL:${wxIS_MAC}>:AudacityApp.mm>
|
||||||
@ -110,8 +109,6 @@ list( APPEND SOURCES
|
|||||||
CellularPanel.cpp
|
CellularPanel.cpp
|
||||||
CellularPanel.h
|
CellularPanel.h
|
||||||
ClassicThemeAsCeeCode.h
|
ClassicThemeAsCeeCode.h
|
||||||
ClientData.h
|
|
||||||
ClientDataHelpers.h
|
|
||||||
Clipboard.cpp
|
Clipboard.cpp
|
||||||
Clipboard.h
|
Clipboard.h
|
||||||
CommonCommandFlags.cpp
|
CommonCommandFlags.cpp
|
||||||
@ -217,9 +214,6 @@ list( APPEND SOURCES
|
|||||||
ProjectWindowBase.cpp
|
ProjectWindowBase.cpp
|
||||||
ProjectWindowBase.h
|
ProjectWindowBase.h
|
||||||
RefreshCode.h
|
RefreshCode.h
|
||||||
Registrar.h
|
|
||||||
Registry.cpp
|
|
||||||
Registry.h
|
|
||||||
RingBuffer.cpp
|
RingBuffer.cpp
|
||||||
RingBuffer.h
|
RingBuffer.h
|
||||||
SampleBlock.cpp
|
SampleBlock.cpp
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "ComponentInterface.h"
|
#include "ComponentInterface.h"
|
||||||
#include "EffectAutomationParameters.h" // for command automation
|
#include "EffectAutomationParameters.h" // for command automation
|
||||||
|
|
||||||
#include "../Registrar.h"
|
#include "Registrar.h"
|
||||||
|
|
||||||
class ShuttleGui;
|
class ShuttleGui;
|
||||||
|
|
||||||
|
@ -14,14 +14,14 @@
|
|||||||
|
|
||||||
#include "Identifier.h"
|
#include "Identifier.h"
|
||||||
|
|
||||||
#include "../ClientData.h"
|
#include "ClientData.h"
|
||||||
#include "CommandFunctors.h"
|
#include "CommandFunctors.h"
|
||||||
#include "CommandFlag.h"
|
#include "CommandFlag.h"
|
||||||
|
|
||||||
#include "Keyboard.h"
|
#include "Keyboard.h"
|
||||||
|
|
||||||
#include "Prefs.h"
|
#include "Prefs.h"
|
||||||
#include "../Registry.h"
|
#include "Registry.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "../widgets/wxPanelWrapper.h" // to inherit
|
#include "../widgets/wxPanelWrapper.h" // to inherit
|
||||||
#include "FileNames.h" // for FileTypes
|
#include "FileNames.h" // for FileTypes
|
||||||
|
|
||||||
#include "../Registry.h"
|
#include "Registry.h"
|
||||||
|
|
||||||
class wxArrayString;
|
class wxArrayString;
|
||||||
class FileDialogWrapper;
|
class FileDialogWrapper;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "../widgets/wxPanelWrapper.h" // to inherit
|
#include "../widgets/wxPanelWrapper.h" // to inherit
|
||||||
#include "FileNames.h" // for FileType
|
#include "FileNames.h" // for FileType
|
||||||
|
|
||||||
#include "../Registry.h"
|
#include "Registry.h"
|
||||||
|
|
||||||
class wxArrayString;
|
class wxArrayString;
|
||||||
class wxListBox;
|
class wxListBox;
|
||||||
|
@ -30,7 +30,7 @@ MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs.
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include "../widgets/wxPanelWrapper.h" // to inherit
|
#include "../widgets/wxPanelWrapper.h" // to inherit
|
||||||
#include "ComponentInterface.h"
|
#include "ComponentInterface.h"
|
||||||
#include "../Registry.h"
|
#include "Registry.h"
|
||||||
|
|
||||||
/* A few constants for an attempt at semi-uniformity */
|
/* A few constants for an attempt at semi-uniformity */
|
||||||
#define PREFS_FONT_SIZE 8
|
#define PREFS_FONT_SIZE 8
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <wx/frame.h> // to inherit
|
#include <wx/frame.h> // to inherit
|
||||||
#include <wx/timer.h> // member variable
|
#include <wx/timer.h> // member variable
|
||||||
|
|
||||||
#include "../ClientData.h"
|
#include "ClientData.h"
|
||||||
#include "ToolDock.h"
|
#include "ToolDock.h"
|
||||||
|
|
||||||
#include "../commands/CommandFunctors.h"
|
#include "../commands/CommandFunctors.h"
|
||||||
|
@ -12,7 +12,7 @@ Paul Licameli split from class WaveTrack
|
|||||||
#define __AUDACITY_WAVE_TRACK_VIEW__
|
#define __AUDACITY_WAVE_TRACK_VIEW__
|
||||||
|
|
||||||
#include "../../../ui/CommonTrackView.h"
|
#include "../../../ui/CommonTrackView.h"
|
||||||
#include "../../../../ClientData.h"
|
#include "ClientData.h"
|
||||||
#include "SampleCount.h"
|
#include "SampleCount.h"
|
||||||
namespace WaveTrackViewConstants{ enum Display : int; }
|
namespace WaveTrackViewConstants{ enum Display : int; }
|
||||||
struct WaveTrackSubViewType;
|
struct WaveTrackSubViewType;
|
||||||
|
@ -11,7 +11,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#ifndef __AUDACITY_BACKGROUND_CELL__
|
#ifndef __AUDACITY_BACKGROUND_CELL__
|
||||||
#define __AUDACITY_BACKGROUND_CELL__
|
#define __AUDACITY_BACKGROUND_CELL__
|
||||||
|
|
||||||
#include "../../ClientData.h"
|
#include "ClientData.h"
|
||||||
#include "CommonTrackPanelCell.h"
|
#include "CommonTrackPanelCell.h"
|
||||||
|
|
||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
|
@ -12,7 +12,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#define __AUDACITY_EDIT_CURSOR_OVERLAY__
|
#define __AUDACITY_EDIT_CURSOR_OVERLAY__
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "../../ClientData.h" // to inherit
|
#include "ClientData.h" // to inherit
|
||||||
#include "../../widgets/Overlay.h" // to inherit
|
#include "../../widgets/Overlay.h" // to inherit
|
||||||
|
|
||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
|
@ -13,7 +13,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
|
|
||||||
#include <wx/event.h> // to inherit
|
#include <wx/event.h> // to inherit
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "../../ClientData.h"
|
#include "ClientData.h"
|
||||||
#include "../../widgets/Overlay.h" // to inherit
|
#include "../../widgets/Overlay.h" // to inherit
|
||||||
|
|
||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include "Scrubbing.h"
|
#include "Scrubbing.h"
|
||||||
#include "../../widgets/Overlay.h"
|
#include "../../widgets/Overlay.h"
|
||||||
#include "../../ClientData.h"
|
#include "ClientData.h"
|
||||||
#include "../../AdornedRulerPanel.h"
|
#include "../../AdornedRulerPanel.h"
|
||||||
#include "../../Project.h"
|
#include "../../Project.h"
|
||||||
#include "../../ProjectWindow.h"
|
#include "../../ProjectWindow.h"
|
||||||
|
@ -17,7 +17,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include <wx/longlong.h>
|
#include <wx/longlong.h>
|
||||||
|
|
||||||
#include "../../AudioIOBase.h" // for ScrubbingOptions
|
#include "../../AudioIOBase.h" // for ScrubbingOptions
|
||||||
#include "../../ClientData.h" // to inherit
|
#include "ClientData.h" // to inherit
|
||||||
#include "Prefs.h" // to inherit
|
#include "Prefs.h" // to inherit
|
||||||
#include "../../widgets/Overlay.h" // to inherit
|
#include "../../widgets/Overlay.h" // to inherit
|
||||||
#include "../../commands/CommandContext.h"
|
#include "../../commands/CommandContext.h"
|
||||||
|
@ -15,7 +15,7 @@ Paul Licameli
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../../AttachedVirtualFunction.h"
|
#include "AttachedVirtualFunction.h"
|
||||||
#include "../../UIHandle.h"
|
#include "../../UIHandle.h"
|
||||||
|
|
||||||
class SnapManager;
|
class SnapManager;
|
||||||
|
@ -28,7 +28,7 @@ public:
|
|||||||
virtual ~TrackControls() = 0;
|
virtual ~TrackControls() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "../../AttachedVirtualFunction.h"
|
#include "AttachedVirtualFunction.h"
|
||||||
|
|
||||||
struct DoGetControlsTag;
|
struct DoGetControlsTag;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include "TrackView.h"
|
#include "TrackView.h"
|
||||||
#include "../../Track.h"
|
#include "../../Track.h"
|
||||||
|
|
||||||
#include "../../ClientData.h"
|
#include "ClientData.h"
|
||||||
#include "../../Project.h"
|
#include "../../Project.h"
|
||||||
#include "../../xml/XMLTagHandler.h"
|
#include "../../xml/XMLTagHandler.h"
|
||||||
#include "../../xml/XMLWriter.h"
|
#include "../../xml/XMLWriter.h"
|
||||||
|
@ -103,7 +103,7 @@ private:
|
|||||||
int mHeight{ DefaultHeight };
|
int mHeight{ DefaultHeight };
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "../../AttachedVirtualFunction.h"
|
#include "AttachedVirtualFunction.h"
|
||||||
|
|
||||||
struct DoGetViewTag;
|
struct DoGetViewTag;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user