The macro based Interface Definition Language (IDL) can be more difficult to read than ordinary C++ class definitions. Therefore, we occassionally describe interfaces using pseudocode which is closer to C++ class definitions.
An interface which is not a template and which does not derive from any other interface can be written as follows:
interface IPoint { long x() const; long y() const; void x(long); void y(long); };
Note that overloading is permitted, and that member functions may be declared const. They may not be templates, however, nor may they be declared static, virtual or volatile:[1]
interface IBad { template<typename T> void foo(const T&); // Error virtual void foo(); // Error void foo() volatile; // Error };
Interfaces may be declared to derived from other interfaces, just as classes may be declared to derived from other classes:
interface ICircle : IPoint { long diameter() const; void diameter(long); }
Multiple inheritance is allowed. The order in which base interfaces are specified is significant. See BOOST_IDL_EXTENDS.
Interfaces may be templates:
template<typename T> interface IStack { bool empty() const; void push(const T&); void pop(); T& top(); const T& top() const; };
Coming soon.
[1]Support for volatile member functions is possible but would require twice as many macros for declaring functions.
Revised 13 Jan, 2005
© Copyright Jonathan Turkanis, 2005. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Sha'arei Tefila, an Orthodox Shul (Synagogue) in Salt Lake City, Utah Chabad Lubavitch of Utah