Jive reference manual
List of all members | Protected Member Functions
jem::Interface Class Reference

Provides support for creating Java-like interfaces. More...

#include <jem/base/Interface.h>

Inherited by jem::Clonable, jem::gl::ColoredMarker, jem::gl::Compound, jem::gl::Pivotable, jem::gl::RedrawRoot, jem::gl::Transformable, jem::io::DataInput, jem::io::DataOutput, jem::io::Serializable, jem::io::TextInput, jem::io::TextOutput, jem::io::WordCompleter, jem::mp::TaskFactory, jem::numeric::UserFunc::ArgList, jem::numeric::UserFunc::NameSpace, jem::util::Enumerable, jem::xutil::SnoopDictionary::Filter, jive::algebra::DiagMatrixExtension, jive::algebra::DirectMatrixExtension, jive::algebra::MPMatrixExtension, jive::algebra::MultiMatmulExtension, jive::algebra::SparseMatrixExtension, jive::fem::VirtualBoundary, jive::fem::VirtualElement, jive::fem::VirtualIBoundary, jive::geom::BezierExtension, jive::geom::Grad2Extension, jive::mp::ScatterCodec, jive::solver::LocalRestrictor, and jive::util::EventSource.

Protected Member Functions

virtual ~Interface ()
 Empty destructor. More...
 

Detailed Description

The Interface class mimicks the interface data type provided by the Java programming language. You define an interface by defining a class that:

Here is an example:

class Executable : public Interface
{
public:
virtual void run() = 0;
protected:
virtual ~Executable ();
};

An interface is implemented by defining a class that inherits the interface and the Object class, and implements all methods defined by the interface. Inheriting the Object class is not strictly necessary, but ensures that the class implementing the interface is compatible with many data structures and algorithms provided by Jem.

Here is an example of a class implementing the interface defined above:

class SimpleProgram : public Object, public Executable
{
public:
virtual void run ();
...
};

There is nothing magic about the Interface class; you are free to define an interface that does not inherit the Interface class. However, by inheriting the Interface class you clearly indicate that a class is to be used as an interface.

Note
If the classes implementing an interface are all derived from the Collectable class, it is good practice to declare the destructor of the interface as a protected member. This ensures that a collectable object implementing the interface can not be deleted prematurely by means of a delete expression.

Constructor & Destructor Documentation

virtual jem::Interface::~Interface ( )
protectedvirtual

The destructor of the Interface class does nothing. It is only declared to ensure the destructor of derived classes is virtual.