VISH  0.2
Public Types | Public Member Functions | Static Public Member Functions
MemCore::interface_cast Class Reference

Interface cast: Given an Intercube, retrive the an interface object which is stored there. More...

#include </home/werner/origo/vish/memcore/Interface.hpp>

List of all members.

Public Types

Public Member Functions

Static Public Member Functions


Detailed Description

Interface cast: Given an Intercube, retrive the an interface object which is stored there.

Example:

struct  myInterface : Interface<int> 
{
        int i;
};


int InterfaceExample()
{
Intercube Alpha; 

        Alpha.addInterface( new myInterface() ); 

RefPtr<myInterface> m = Alpha.getInterface( typeid(int) ); 

RefPtr<myInterface> n = interface_cast<myInterface>( Alpha ); 

        return 0;
}
Note:
interface_cast<> is implemented via an temporary C++ object. Make sure that the lifetime of this object is shorted than the Intercube object for which it is used, otherwise an invalid reference is used. This should be quite safe if never an object of type interface_cast<> is created explicitly.

Member Typedef Documentation

typedef InterfaceType::InterfaceDomain_t MemCore::interface_cast::InterfaceDomain_t

The domain type, i.e.

a possible base class of the given interface type, which is used to look up a certain interface. The returned interface may be an implementation of the InterfaceDomain_t.


Member Function Documentation

InterfaceType& MemCore::interface_cast::operator() ( ) const [inline]

Provide an interface object for the requested type, returning an existing one or creating a new one.

                   struct X : Interface<X> {};

                   Intercube I;

                        X&z = interface_case<X>(I)();
Warning:
The Intercube object may be modified hereby!
template<class InitType >
InterfaceType& MemCore::interface_cast::operator() ( const InitType &  initValue) const [inline]

Provide an interface object for the requested type, returning an existing one or creating a new one with the given parameter as constructor argument.

                   struct X : Interface<X> { X(int) {} };

                   Intercube I;

                   RefPtr<X> z = interface_case<X>(I)(42);
Warning:
The Intercube object may be modified hereby!

The documentation for this class was generated from the following file: