LLVM 23.0.0git
llvm::Registry< T, CtorParamTypes > Class Template Reference

A global registry used in conjunction with static constructors to make pluggable components (like targets or garbage collectors) "just work" when linked with an executable. More...

#include "llvm/Support/Registry.h"

Inheritance diagram for llvm::Registry< T, CtorParamTypes >:
[legend]

Classes

class  Add
 A static registration template. More...
class  iterator
 Iterators for registry entries. More...
class  node
 Node in linked list of entries. More...

Public Types

using type = T
using entry = SimpleRegistryEntry<T, CtorParamTypes...>

Static Public Member Functions

static void add_node (node *N)
 Add a node to the Registry: this is the interface between the plugin and the executable.
static iterator begin ()
static iterator end ()
static iterator_range< iteratorentries ()

Static Public Attributes

static constexpr bool HasCtorParamTypes = sizeof...(CtorParamTypes) != 0

Friends

class node

Detailed Description

template<typename T, typename... CtorParamTypes>
class llvm::Registry< T, CtorParamTypes >

A global registry used in conjunction with static constructors to make pluggable components (like targets or garbage collectors) "just work" when linked with an executable.

To provide a Registry interface, follow these steps:

  1. Define your plugin base interface. The interface must have a virtual destructor and the appropriate dllexport/dllimport/visibility annotation.
    namespace your_ns {
      class YOURLIB_ABI SomethingPluginBase {
        virtual ~SomethingPluginBase() = default;
        virtual void TheInterface() = 0;
      };
    }
    
  1. Declare an alias to your Registry for convenience.
    namespace your_ns {
      using YourRegistry = llvm::Registry<SomethingPluginBase>;
    }
    
  1. Declare the specialization of the Registry with LLVM_DECLARE_REGISTRY in the global namespace. The declaration must be placed before any use of the YourRegistry.
    LLVM_DECLARE_REGISTRY(your_ns::YourRegistry)
    
  1. In a .cpp file, define the specialization with LLVM_DEFINE_REGISTRY in the global namespace.
    LLVM_DEFINE_REGISTRY(your_ns::YourRegistry)
    

Definition at line 116 of file Registry.h.

Member Typedef Documentation

◆ entry

template<typename T, typename... CtorParamTypes>
using llvm::Registry< T, CtorParamTypes >::entry = SimpleRegistryEntry<T, CtorParamTypes...>

Definition at line 123 of file Registry.h.

◆ type

template<typename T, typename... CtorParamTypes>
using llvm::Registry< T, CtorParamTypes >::type = T

Definition at line 122 of file Registry.h.

Member Function Documentation

◆ add_node()

template<typename T, typename... CtorParamTypes>
void llvm::Registry< T, CtorParamTypes >::add_node ( node * N)
inlinestatic

Add a node to the Registry: this is the interface between the plugin and the executable.

Definition at line 151 of file Registry.h.

Referenced by llvm::Registry< T, CtorParamTypes >::Add< V >::Add().

◆ begin()

template<typename T, typename... CtorParamTypes>
iterator llvm::Registry< T, CtorParamTypes >::begin ( )
inlinestatic

Definition at line 178 of file Registry.h.

Referenced by llvm::Registry< GCMetadataPrinter >::entries().

◆ end()

template<typename T, typename... CtorParamTypes>
iterator llvm::Registry< T, CtorParamTypes >::end ( )
inlinestatic

Definition at line 181 of file Registry.h.

Referenced by llvm::Registry< GCMetadataPrinter >::entries().

◆ entries()

template<typename T, typename... CtorParamTypes>
iterator_range< iterator > llvm::Registry< T, CtorParamTypes >::entries ( )
inlinestatic

Definition at line 183 of file Registry.h.

◆ node

template<typename T, typename... CtorParamTypes>
friend class node
friend

Definition at line 132 of file Registry.h.

Member Data Documentation

◆ HasCtorParamTypes

template<typename T, typename... CtorParamTypes>
bool llvm::Registry< T, CtorParamTypes >::HasCtorParamTypes = sizeof...(CtorParamTypes) != 0
staticconstexpr

Definition at line 124 of file Registry.h.


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