Template Class Registry#

Nested Relationships#

Nested Types#

Class Documentation#

template<typename T, typename U = RegistryTraits<T>>
class Registry#

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.

Public Types

typedef U traits#
typedef U::entry entry#

Public Static Functions

static inline iterator begin()#
static inline iterator end()#
static inline iterator_range<iterator> entries()#
template<typename V>
class Add#

A static registration template. Use like such:

X(“fancy-gc”, “Newfangled garbage collector.”);

Use of this template requires that:

  1. The registered subclass has a default constructor.

The registry entry type has a constructor compatible with this signature:

entry(const char *Name, const char *ShortDesc, T *(*Ctor)());

If you have more elaborate requirements, then copy and modify.

Public Functions

inline Add(const char *Name, const char *Desc)#
class iterator#

Iterators for registry entries.

Public Functions

inline explicit iterator(const node *N)#
inline bool operator==(const iterator &That) const#
inline bool operator!=(const iterator &That) const#
inline iterator &operator++()#
inline const entry &operator*() const#
inline const entry *operator->() const#
class listener#

Abstract base class for registry listeners, which are informed when new entries are added to the registry. Simply subclass and instantiate:

class CollectorPrinter : public Registry<Collector>::listener {
protected:
  void registered(const Registry<Collector>::entry &e) {
    cerr << "collector now available: " << e->getName() << "\n";
  }

public:
  CollectorPrinter() { init(); }  // Print those already registered.
};

CollectorPrinter Printer;

Public Functions

inline listener()#
inline virtual ~listener()#

Protected Functions

virtual void registered(const entry&) = 0#

Called when an entry is added to the registry.

inline void init()#

Calls ‘registered’ for each pre-existing entry.

class node#

Node in linked list of entries.

Public Functions

inline node(const entry &V)#