14 #ifndef LLVM_SUPPORT_REGISTRY_H
15 #define LLVM_SUPPORT_REGISTRY_H
27 const char *Name, *Desc;
28 std::unique_ptr<T> (*Ctor)();
32 : Name(N), Desc(D), Ctor(
C)
35 const char *
getName()
const {
return Name; }
36 const char *
getDesc()
const {
return Desc; }
60 template <
typename T,
typename U = RegistryTraits<T> >
64 typedef typename U::entry
entry;
73 static void Announce(
const entry &E) {
74 for (
listener *Cur = ListenerHead; Cur; Cur = Cur->Next)
79 static node *Head, *Tail;
82 static listener *ListenerHead, *ListenerTail;
200 template <
typename V>
205 static std::unique_ptr<T> CtorFn() {
return make_unique<V>(); }
209 : Entry(Name, Desc, CtorFn), Node(Entry) {}
219 template <
typename T,
typename U>
220 typename Registry<T,U>::node *Registry<T,U>::Head;
222 template <
typename T,
typename U>
223 typename Registry<T,U>::node *Registry<T,U>::Tail;
225 template <
typename T,
typename U>
226 typename Registry<T,U>::listener *Registry<T,U>::ListenerHead;
228 template <
typename T,
typename U>
229 typename Registry<T,U>::listener *Registry<T,U>::ListenerTail;
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
A global registry used in conjunction with static constructors to make pluggable components (like tar...
A simple registry entry which provides only a name, description, and no-argument constructor.
const entry & operator*() const
virtual void registered(const entry &)=0
Called when an entry is added to the registry.
Node in linked list of entries.
SimpleRegistryEntry< T > entry
Add(const char *Name, const char *Desc)
const char * getName() const
bool operator!=(const iterator &That) const
static iterator_range< iterator > entries()
const char * getDesc() const
bool operator==(const iterator &That) const
void init()
Calls 'registered' for each pre-existing entry.
static const char * nameof(const entry &Entry)
nameof/descof - Accessors for name and description of entries. These are
A range adaptor for a pair of iterators.
Abstract base class for registry listeners, which are informed when new entries are added to the regi...
SimpleRegistryEntry(const char *N, const char *D, std::unique_ptr< T >(*C)())
Iterators for registry entries.
Traits for registry entries.
const entry * operator->() const
friend void Registry::Announce(const entry &E)
static const char * descof(const entry &Entry)
std::unique_ptr< T > instantiate() const
A static registration template.