Pseudocode

Overview
Examples
Simple Interface Declarations
Derived Interfaces
Interface Templates
Grammar

Overview

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.

Examples

Example I: Simple interface declarations.

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
};

Example II: Derived interfaces.

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.

Example III: Interface templates.

Interfaces may be templates:

template<typename T>
interface IStack {
    bool empty() const;
    void push(const T&);
    void pop();
    T& top();
    const T& top() const;
};

Grammar

Coming soon.


[1]Support for volatile member functions is possible but would require twice as many macros for declaring functions.


Sha'arei Tefila, an Orthodox Shul (Synagogue) in Salt Lake City, Utah Chabad Lubavitch of Utah