C++11 Mapping for Local Interfaces

On this page:

Mapped C++ Class

A Slice local interface is mapped to a C++ abstract base class with the same name, for example:

Slice
module Ice
{
    local interface Communicator
    {
        ...
    }
}

is mapped to the C++ class Communicator:

C++
namespace Ice
{
    class Communicator
    {
        ...
    };
}

The delegate metadata allows you to map a local interface with a single operation to a std::function. For example:

Slice
module Ice
{
    ["delegate"] local interface ValueFactory
    {
        Value create(string type);
    }
}

is mapped to a function in C++:

C++
namespace Ice
{
    using ValueFactory = std::function<std::shared_ptr<Ice::Value>(const std::string&)>;
}

The signature of this function is described on C++11 mapping for operations on local types.

LocalObject in C++

All Slice local interfaces implicitly derive from LocalObject, which is mapped to nothing at all in C++11, as shown in the example above.

Mapping for Local Interface Inheritance in C++

Inheritance of local Slice interfaces is mapped to public virtual inheritance in C++. For example:

Slice
module M
{
    local interface A {}
    local interface B extends A {}
    local interface C extends A {}
    local interface D extends B, C {} 
} 

is mapped to:

C++
namespace M
{
    class A { ... };
    class B : public virtual A { ... };
    class C : public virtual A { ... };
    class D : public virtual B, public virtual C { ... };
}