[Home]BoostMetaclass

BOOST WIKI | RecentChanges | Preferences | Page List | Links List

Boost Metaclass Library

The overall objective of the Boost Metaclass Library is to provide type reflection within C++. Many object oriented languages support this (including SmallTalk? and Java). Metaclasses can be used to obtain constructors, attribute, and methods of a arbitrary type typically by using a run-time key.

Library Synopsis

template <class Type, typename Key> class metaclass { public:

  // ctor adding/getting

  template <typename Sig>
  void add_ctor();

  template <typename Sig>
  function<Sig> get_ctor();

  // method adding/getting

  template <typename Sig, typename Func>
  void add_method(const Key &key, Func func);

  template <typename Sig>
  function<Sig> get_method(const Key &key);

  template <typename Sig>
  function<Sig> get_method(Type *obj, const Key &key);

  template <typename Sig>
  function<Sig> get_method(Type &obj, const Key &key);

  // attribute adding/getting

  template <typename Attr>
  void add_attr(const Key &key, Attr typename Type::*attr);

  template <typename Attr>
  Attr &get_attr(Type *obj, const Key &key);

  template <typename Attr>
  Attr &get_attr(Type &obj, const Key &key);

  template <typename Attr>
  function<Attr &(Type *)> get_attr(const Key &key);

  // superclass info

  template <class Sub>
  void add_sub(const Key &key, const metaclass<Sub> &Sub);

  metaclass get_sub(const Key &key);
};

Example Usage


BOOST WIKI | RecentChanges | Preferences | Page List | Links List
Edit text of this page | View other revisions
Last edited December 18, 2004 12:34 pm (diff)
Search:
Disclaimer: This site not officially maintained by Boost Developers