23.05.2014 Views

Athena Developer Guide

Athena Developer Guide

Athena Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Athena</strong><br />

Chapter 18 Framework packages, interfaces and libraries Version/Issue: 2.0.0<br />

• Derived from IInterface. We follow the convention that all interfaces should be derived<br />

from a basic interface IInterface. This interface defined 3 methods: addRef(), release()<br />

and queryInterface(). This methods allow the framework to manage the reference counting of<br />

the framework components and the possibility to obtain a different interface of a component<br />

using any interface (see later).<br />

• Pure Abstract Methods. All the methods should be pure abstract (virtual ReturnType<br />

method(...) = 0;) With the exception of the static method interfaceID() (see<br />

later) and some inline templated methods to facilitate the use of the interface by the end-user.<br />

• Interface ID. Each interface should have a unique identification (see later) used by the query<br />

interface mechanism.<br />

18.3.1 Interface ID<br />

We needed to introduce an interface ID for identifying interfaces for the queryInterface functionality.<br />

The interface ID is made of a numerical identifier that needs to be allocated off-line, and a major and<br />

minor version numbers. The version number is used to decide if the interface the service provider is<br />

returning is compatible with the interface the client is expecting. The rules for deciding if the interface<br />

request is compatible are:<br />

• The interface identifier is the same<br />

• The major version is the same<br />

• The minor version of the client is less than or equal to the one of the service provider. This<br />

allows the service provider to add functionality (incrementing minor version number) keeping<br />

old clients still compatible.<br />

The interface ID is defined in the same header file as the rest of the interface. Care should be taken of<br />

globally allocating the interface identifier, and of modifying the version whenever a change of the<br />

interface is required, according to the rules. Of course changes to interfaces should be minimized.<br />

static const InterfaceID IID_Ixxx(2 /*id*/, 1 /*major*/, 0 /*minor*/);<br />

class Ixxx : public IInterface {<br />

. . .<br />

static const InterfaceID& interfaceID() { return IID_Ixxx; }<br />

};<br />

The static method Ixxx::interfaceID() is useful for the implementation of templated methods<br />

and classes using an interface as template parameter. The construct T::interfaceID() returns the<br />

interface ID of interface T.<br />

page 161

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!