uc/cmn/dllinterface.h File Reference


Defines

#define UC_DLL_CALL
#define UC_DLL_INTERFACE_DECLARE(IFace)
#define UC_DLL_INTERFACE_IMPL(IFace)
#define UC_DLL_INTERFACE_IMPL2(IFaceA, IFaceB)
#define UC_DLL_INTERFACE_IMPL_BASE(IFace)
#define UC_DLL_INTERFACE_IMPL_TOP

Detailed Description

Set of helper macros to declare and define classes that cross DLL boundaries. Inspired by http://aegisknight.org/cppinterface.html article.

Attention:
Rules for classes declared with UC_DLL_INTERFACE_DECLARE:
  • These classes should be completely abstract, i.e. every method should be pure virtual or inline;
  • Don't use standard C++ library;
  • Don't use virtual destructors;
  • Don't use overloaded methods;
  • Use __stdcall calling convention for every pure virtual method (see UC_DLL_CALL);
  • Don't return struct/class instances from pure virtual methods; size of return type should be less or equal to sizeof(int).

Rules for classes derived from classes declared with UC_DLL_INTERFACE_DECLARE:
  • Base class overridden methods should not throw exceptions;
  • Class should define virtual destructor if it can be inherited.

Define Documentation

#define UC_DLL_CALL

Every pure virtual method of a class declared with UC_DLL_INTERFACE_DECLARE should have this calling convention.

#define UC_DLL_INTERFACE_DECLARE ( IFace   ) 

Value:

protected:                                              \
        virtual void UC_DLL_CALL                            \
        destroy##IFace() = 0;                               \
    public:                                                 \
        void operator delete(void* p)                       \
        {                                                   \
            if(p)                                           \
            {                                               \
                static_cast<IFace*>(p)->destroy##IFace();   \
            }                                               \
        }                                                   \
    private:
Every class supposed to pass DLL boundaries should have one occurrence of this macro in its declaration.
See also:
UC_DLL_INTERFACE_IMPL
Parameters:
IFace class name

#define UC_DLL_INTERFACE_IMPL_BASE ( IFace   ) 

Value:

protected:                                              \
        virtual void UC_DLL_CALL                            \
        destroy##IFace()                                    \
        {                                                   \
            delete this;                                    \
        }                                                   \
    private:
Every class derived from class/classes declared with UC_DLL_INTERFACE_DECLARE should implicitly/explicitly have as many occurrences of UC_DLL_INTERFACE_IMPL_BASE in its declaration as many classes declared with UC_DLL_INTERFACE_DECLARE it derives.
See also:
UC_DLL_INTERFACE_DECLARE

UC_DLL_INTERFACE_IMPL

Parameters:
IFace parent class name

#define UC_DLL_INTERFACE_IMPL_TOP

Value:

public:                                                 \
        void operator delete(void* p)                       \
        {                                                   \
            ::operator delete(p);                           \
        }                                                   \
    private:
Every class derived from class/classes declared with UC_DLL_INTERFACE_DECLARE should implicitly/explicitly have one occurrence of UC_DLL_INTERFACE_IMPL_TOP in its declaration.
See also:
UC_DLL_INTERFACE_DECLARE

#define UC_DLL_INTERFACE_IMPL ( IFace   ) 

#define UC_DLL_INTERFACE_IMPL2 ( IFaceA,
IFaceB   ) 


Generated on Tue Nov 18 21:08:22 2008 for Ferry by doxygen 1.5.7.1
http://sourceforge.net