Boost logo

Boost :

From: christopher diggins (cdiggins_at_[hidden])
Date: 2004-12-30 16:05:18

On the subject of GUI object hierarchies, I wanted to bring to everyone's
attention the Boost Interfaces Library (BIL) currently being developed by
Jonathan Turkanis which could be an excellent tool for building a flexible
and efficient GUI library. There is a brief introduction to the library on
the Boost wiki ( )

The BIL library, provides a mechanism for non-intrusive structural
subtyping. In other words any object can be used polymorphically if it
provides function signatures which match those of the interface type. The
advantages are that it eliminates the overhead of virtual tables in the
objects. Also dynamic function dispatch only occurs when it is needed (i.e.
through an interface reference). Most importantly the BIL removes the
requirement of inheritance for polymorphism.

The code for declaring the interfaces would look like this:

  BOOST_IDL_CONST_FN0(GetText, string)
  BOOST_IDL_CONST_FN0(GetAlignment, align_T)

  BOOST_IDL_FN0(GetLabel, ILabel)
  BOOST_IDL_FN0(GetDims, dim_struct)

Using the interfaces would be done by simply declaring classes which
implement the interfaces implicitly as below:

class CenteredLabel {
    CenteredLabel(string s) : text(s) { };
    string GetText() { return text; }
    string GetAlignment() { retun enumAlignHCenterVCenter; }
    string text;

class StandardOkButton {
    OkButton() : label("OK") { }
    dim_struct GetDims() { return dim_struct(100,50); }
    ILabel GetLabel() { return label; }
    CenteredLabel label;

Is the value of such as approach apparent or are more detailed examples

Christopher Diggins

Boost list run by bdawes at, gregod at, cpdaniel at, john at