Boost logo

Boost :

From: christopher diggins (cdiggins_at_[hidden])
Date: 2004-12-31 11:09:14


----- Original Message -----
From: "Reece Dunn" <msclrhd_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, December 31, 2004 4:26 AM
Subject: [boost] Re: Object Hierarchies using Interface Types with the BIL

> christopher diggins wrote:
>> 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 (
>> http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Boost.Interfaces )
>>
>> The code for declaring the interfaces would look like this:
>>
>> BOOST_IDL_BEGIN(ILabel)
>> BOOST_IDL_CONST_FN0(GetText, string)
>> BOOST_IDL_CONST_FN0(GetAlignment, align_T)
>> BOOST_IDL_END(ILabel)
>
> What I am trying to get working is:
>
> 15: BOOST_IDL_BEGIN(IUIObject)
> 16: BOOST_IDL_FN4(move, void, g::metric, g::metric, g::metric,
> g::metric)
> 17: BOOST_IDL_FN2(move, void, g::metric, g::metric)
> 18: inline void move( g::point p )
> 19: {
> 20: move( p.x, p.y );
> 21: }
> 22: BOOST_IDL_END(IUIObject)
>
> with the latest CVS of Boost, but with msvc-8.0, I get:

> Any suggestions? Is there a version of the BIL that works with the CVS
> version (or 1.33) of Boost? And is the above valid, since this is the kind
> of thing I want?

The obvious problem with your code is that the BIL interface is not intended
to have any function implementation inside of it. It is in this sense more
like a Java interface or a pure abstract base class. So if you want a move
functions, I suggest moving them out in a separate class (which I call an
extension)

template<typename T>
struct IUIObjectWrapper : public T {
  IUIObjectWrapper() : T() { }
  inline void move(g::point p) {
    T::move(p.x, p.y);
  }
}

typedef IUIObjectWrapper<IUIObject> IUIObjectExtension;

This approach actually corrects what I percieve to be a huge flaw with many
object libraries, which is the coupling of core functionality and derivable
functionality.

Also note that a new version of the BIL library is due out in a few days.

Christopher Diggins
http://www.cdiggins.com
http://www.heron-language.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk