Blame README.namespacing

Packit 0d464f
------------------------------------------------
Packit 0d464f
 On the use of namespace in IlmBase and OpenEXR
Packit 0d464f
------------------------------------------------
Packit 0d464f
Packit 0d464f
v2.0 of the code base introduces user configurable namespaces for
Packit 0d464f
component libraries. This addition introduces the ability to deal with 
Packit 0d464f
multiple versions of these libraries loaded at runtime.
Packit 0d464f
An example case:
Packit 0d464f
    Application is built with OpenEXR v1.7, but the required plugin 
Packit 0d464f
    requires functionality from OpenEXR v2.0.
Packit 0d464f
    
Packit 0d464f
    By injecting the version number into the (mangled) symbols, via
Packit 0d464f
    the namespacing mechanism, and changing the soname, via the build
Packit 0d464f
    system, the developer can link his plugin against the v2.0 library
Packit 0d464f
    At run time the dynamic linker can load both the 1.7 and 2.0
Packit 0d464f
    versions of the library since the library soname are different and
Packit 0d464f
    the symbols are different.
Packit 0d464f
    
Packit 0d464f
Packit 0d464f
When building IlmBase or OpenEXR the following configure script options 
Packit 0d464f
are available:
Packit 0d464f
    --enable-namespaceversioning
Packit 0d464f
and
Packit 0d464f
    --enable-customusernamespace
Packit 0d464f
Packit 0d464f
Packit 0d464f
Packit 0d464f
-- Internal Library Namespace
Packit 0d464f
The option, --enable-namespaceversioning, controls the namespace that 
Packit 0d464f
is used in the library. Without an argument (see below) the library 
Packit 0d464f
will be built with a suffix made up of the major and minor versions.
Packit 0d464f
For example, for version 2.0.0, the internal library namespaces will be
Packit 0d464f
Imath_2_0, Iex_2_0, IlmThread_2_0 etc
Packit 0d464f
Packit 0d464f
For additional flexibility and control, this option can take an additional 
Packit 0d464f
argument in which case the internal library namespace will be suffixed 
Packit 0d464f
accordingly. 
Packit 0d464f
For example: 
Packit 0d464f
    ./configure --enable-namespaceversioning=ILM
Packit 0d464f
will result in the namespaces of the type Imath_ILM, Iex_ILM etc.
Packit 0d464f
Packit 0d464f
This can be useful for completely isolating your local build.
Packit 0d464f
Packit 0d464f
Code using the library should continue to use the namespace Imath, or for
Packit 0d464f
greater portability IMATH_NAMESPACE, to refer to objects in libImath. 
Packit 0d464f
In particular, the explicit use of the internal namespace is discouraged.
Packit 0d464f
This ensures that code will continue to compile with customised or future 
Packit 0d464f
versions of the library, which may have a different internal namespace.
Packit 0d464f
Packit 0d464f
Similarily, for other namespaces in the libraries: Iex, IlmThread and IlmImf.
Packit 0d464f
Packit 0d464f
Note that this scheme allows existing code to compile without modifications, 
Packit 0d464f
since the 'old' namespaces Imath, Iex, IlmThread and IlmImf continue to be 
Packit 0d464f
available, albeit in a slightly different form.
Packit 0d464f
This is achieved via the following, in the Imath case: 
Packit 0d464f
    namespace IMATH_INTERNAL_NAMESPACE {}
Packit 0d464f
    namespace IMATH_NAMESPACE 
Packit 0d464f
    {
Packit 0d464f
         using namespace IMATH_INTERNAL_NAMESPACE;
Packit 0d464f
    }
Packit 0d464f
This is included in all header files in the Imath library and similar ones
Packit 0d464f
are present for the libraries Iex, IlmThread and IlmImf.
Packit 0d464f
Packit 0d464f
The only exception to this is where user code has forward declarations of 
Packit 0d464f
objects in the Imf namespace, as these will forward declare symbols in an 
Packit 0d464f
incorrect namespace
Packit 0d464f
These forward declarations should be removed, and replaced with 
Packit 0d464f
    #include <ImfForward.h>, 
Packit 0d464f
which forward-declares all types correctly.
Packit 0d464f
Packit 0d464f
Packit 0d464f
Packit 0d464f
-- Public/User Library Namespace
Packit 0d464f
The option, --enable-customusernamespace, can override the namespace into 
Packit 0d464f
which we will 'export' the internal namespace. This takes an argument 
Packit 0d464f
that sets the name of the custom user namespace.
Packit 0d464f
In the example above, IMATH_NAMESPACE could be resolved into something other
Packit 0d464f
than Imath, say Imath_MySpecialNamespace.
Packit 0d464f
Packit 0d464f
In nearly all cases, this will not be used as per the above discussion
Packit 0d464f
regarding code compatibility.
Packit 0d464f
Its presence is to provide a mechanism for not prohibiting the case when 
Packit 0d464f
the application must pass objects from two different versions of the library.