Audacity 3.2.0
Classes | Macros
AttachedVirtualFunction.h File Reference

Utility for non-intrusive definition of a new method on a base class. More...

#include <functional>
#include <mutex>
#include <type_traits>
#include <utility>
#include "InconsistencyException.h"
Include dependency graph for AttachedVirtualFunction.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  AttachedVirtualFunction< Tag, Return, This, Arguments >
 Class template generates single-dispatch, open method registry tables. More...
 
struct  AttachedVirtualFunction< Tag, Return, This, Arguments >::Override< Subclass, Overridden >
 For defining overrides of the method. More...
 
struct  AttachedVirtualFunction< Tag, Return, This, Arguments >::Entry
 Member of registry of implementations of the method. More...
 

Macros

#define DECLARE_EXPORTED_ATTACHED_VIRTUAL(DECLSPEC, Name)
 Typically follow the using declaration of a new AttachedVirtualFunction with this macro. More...
 
#define DEFINE_ATTACHED_VIRTUAL(Name)
 Used in the companion .cpp file to the .h using the above macro; followed by a function body. More...
 
#define DEFINE_ATTACHED_VIRTUAL_OVERRIDE(Name)
 Used to define overriding function; followed by a function body. More...
 

Detailed Description

Utility for non-intrusive definition of a new method on a base class.


Audacity: A Digital Audio Editor

Paul Licameli

Definition in file AttachedVirtualFunction.h.

Macro Definition Documentation

◆ DECLARE_EXPORTED_ATTACHED_VIRTUAL

#define DECLARE_EXPORTED_ATTACHED_VIRTUAL (   DECLSPEC,
  Name 
)
Value:
template<> DECLSPEC Name::AttachedVirtualFunction(); \
template<> auto DECLSPEC Name::GetRegistry() -> Registry &; \
template<> auto DECLSPEC Name::Implementation() -> Function

Typically follow the using declaration of a new AttachedVirtualFunction with this macro.

Definition at line 281 of file AttachedVirtualFunction.h.

◆ DEFINE_ATTACHED_VIRTUAL

#define DEFINE_ATTACHED_VIRTUAL (   Name)
Value:
template<> Name::AttachedVirtualFunction() \
{ \
static std::once_flag flag; \
std::call_once( flag, []{ Register<Object>( Implementation() ); } ); \
} \
template<> auto Name::GetRegistry() -> Registry & \
{ \
static Registry registry; \
return registry; \
} \
static Name register ## Name ; \
template<> auto Name::Implementation() -> Function
static std::once_flag flag

Used in the companion .cpp file to the .h using the above macro; followed by a function body.

Definition at line 287 of file AttachedVirtualFunction.h.

◆ DEFINE_ATTACHED_VIRTUAL_OVERRIDE

#define DEFINE_ATTACHED_VIRTUAL_OVERRIDE (   Name)
Value:
static Name register ## Name ; \
template<> template<> auto Name::Implementation() -> Function \

Used to define overriding function; followed by a function body.

Definition at line 302 of file AttachedVirtualFunction.h.