Blame README.namespacing

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