HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImfNamespace.h
Go to the documentation of this file.
1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright (c) Contributors to the OpenEXR Project.
4 //
5 
6 #ifndef INCLUDED_IMFNAMESPACE_H
7 #define INCLUDED_IMFNAMESPACE_H
8 
9 //
10 // The purpose of this file is to have all of the Imath symbols defined within
11 // the OPENEXR_IMF_INTERNAL_NAMESPACE namespace rather than the standard Imath
12 // namespace. Those symbols are made available to client code through the
13 // OPENEXR_IMF_NAMESPACE in addition to the OPENEXR_IMF_INTERNAL_NAMESPACE.
14 //
15 // To ensure source code compatibility, the OPENEXR_IMF_NAMESPACE defaults to
16 // Imath and then "using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;" brings all
17 // of the declarations from the OPENEXR_IMF_INTERNAL_NAMESPACE into the
18 // OPENEXR_IMF_NAMESPACE.
19 // This means that client code can continue to use syntax like
20 // Imf::Header, but at link time it will resolve to a
21 // mangled symbol based on the OPENEXR_IMF_INTERNAL_NAMESPACE.
22 //
23 // As an example, if one needed to build against a newer version of Imath and
24 // have it run alongside an older version in the same application, it is now
25 // possible to use an internal namespace to prevent collisions between the
26 // older versions of Imath symbols and the newer ones. To do this, the
27 // following could be defined at build time:
28 //
29 // OPENEXR_IMF_INTERNAL_NAMESPACE = Imf_v2
30 //
31 // This means that declarations inside Imath headers look like this (after
32 // the preprocessor has done its work):
33 //
34 // namespace Imf_v2 {
35 // ...
36 // class declarations
37 // ...
38 // }
39 //
40 // namespace Imf {
41 // using namespace IMF_NAMESPACE_v2;
42 // }
43 //
44 
45 //
46 // Open Source version of this file pulls in the OpenEXRConfig.h file
47 // for the configure time options.
48 //
49 #include "OpenEXRConfig.h"
50 
51 
52 #ifndef OPENEXR_IMF_NAMESPACE
53 #define OPENEXR_IMF_NAMESPACE Imf
54 #endif
55 
56 #ifndef OPENEXR_IMF_INTERNAL_NAMESPACE
57 #define OPENEXR_IMF_INTERNAL_NAMESPACE OPENEXR_IMF_NAMESPACE
58 #endif
59 
60 //
61 // We need to be sure that we import the internal namespace into the public one.
62 // To do this, we use the small bit of code below which initially defines
63 // OPENEXR_IMF_INTERNAL_NAMESPACE (so it can be referenced) and then defines
64 // OPENEXR_IMF_NAMESPACE and pulls the internal symbols into the public
65 // namespace.
66 //
67 
70  using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;
71 }
72 
73 //
74 // There are identical pairs of HEADER/SOURCE ENTER/EXIT macros so that
75 // future extension to the namespace mechanism is possible without changing
76 // project source code.
77 //
78 
79 #define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER namespace OPENEXR_IMF_INTERNAL_NAMESPACE {
80 #define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT }
81 
82 #define OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER namespace OPENEXR_IMF_INTERNAL_NAMESPACE {
83 #define OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT }
84 
85 
86 #endif /* INCLUDED_IMFNAMESPACE_H */
#define OPENEXR_IMF_INTERNAL_NAMESPACE
Definition: OpenEXRConfig.h:29
#define OPENEXR_IMF_NAMESPACE
Definition: OpenEXRConfig.h:36