1 | /////////////////////////////////////////////////////////////////////////// |
2 | // |
3 | // Copyright (c) 2012, Industrial Light & Magic, a division of Lucas |
4 | // Digital Ltd. LLC |
5 | // |
6 | // All rights reserved. |
7 | // |
8 | // Redistribution and use in source and binary forms, with or without |
9 | // modification, are permitted provided that the following conditions are |
10 | // met: |
11 | // * Redistributions of source code must retain the above copyright |
12 | // notice, this list of conditions and the following disclaimer. |
13 | // * Redistributions in binary form must reproduce the above |
14 | // copyright notice, this list of conditions and the following disclaimer |
15 | // in the documentation and/or other materials provided with the |
16 | // distribution. |
17 | // * Neither the name of Industrial Light & Magic nor the names of |
18 | // its contributors may be used to endorse or promote products derived |
19 | // from this software without specific prior written permission. |
20 | // |
21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
22 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
23 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
24 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
25 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
26 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
27 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
28 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
29 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
30 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
31 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
32 | // |
33 | /////////////////////////////////////////////////////////////////////////// |
34 | |
35 | #ifndef INCLUDED_IMATHNAMESPACE_H |
36 | #define INCLUDED_IMATHNAMESPACE_H |
37 | |
38 | // |
39 | // The purpose of this file is to make it possible to specify an |
40 | // IMATH_INTERNAL_NAMESPACE as a preprocessor definition and have all of the |
41 | // Imath symbols defined within that namespace rather than the standard |
42 | // Imath namespace. Those symbols are made available to client code through |
43 | // the IMATH_NAMESPACE in addition to the IMATH_INTERNAL_NAMESPACE. |
44 | // |
45 | // To ensure source code compatibility, the IMATH_NAMESPACE defaults to Imath |
46 | // and then "using namespace IMATH_INTERNAL_NAMESPACE;" brings all of the |
47 | // declarations from the IMATH_INTERNAL_NAMESPACE into the IMATH_NAMESPACE. |
48 | // This means that client code can continue to use syntax like Imath::V3f, |
49 | // but at link time it will resolve to a mangled symbol based on the |
50 | // IMATH_INTERNAL_NAMESPACE. |
51 | // |
52 | // As an example, if one needed to build against a newer version of Imath and |
53 | // have it run alongside an older version in the same application, it is now |
54 | // possible to use an internal namespace to prevent collisions between the |
55 | // older versions of Imath symbols and the newer ones. To do this, the |
56 | // following could be defined at build time: |
57 | // |
58 | // IMATH_INTERNAL_NAMESPACE = Imath_v2 |
59 | // |
60 | // This means that declarations inside Imath headers look like this (after |
61 | // the preprocessor has done its work): |
62 | // |
63 | // namespace Imath_v2 { |
64 | // ... |
65 | // class declarations |
66 | // ... |
67 | // } |
68 | // |
69 | // namespace Imath { |
70 | // using namespace Imath_v2; |
71 | // } |
72 | // |
73 | |
74 | // |
75 | // Open Source version of this file pulls in the IlmBaseConfig.h file |
76 | // for the configure time options. |
77 | // |
78 | #include "IlmBaseConfig.h" |
79 | |
80 | |
81 | #ifndef IMATH_NAMESPACE |
82 | #define IMATH_NAMESPACE Imath |
83 | #endif |
84 | |
85 | #ifndef IMATH_INTERNAL_NAMESPACE |
86 | #define IMATH_INTERNAL_NAMESPACE IMATH_NAMESPACE |
87 | #endif |
88 | |
89 | // |
90 | // We need to be sure that we import the internal namespace into the public one. |
91 | // To do this, we use the small bit of code below which initially defines |
92 | // IMATH_INTERNAL_NAMESPACE (so it can be referenced) and then defines |
93 | // IMATH_NAMESPACE and pulls the internal symbols into the public |
94 | // namespace. |
95 | // |
96 | |
97 | namespace IMATH_INTERNAL_NAMESPACE {} |
98 | namespace IMATH_NAMESPACE { |
99 | using namespace IMATH_INTERNAL_NAMESPACE; |
100 | } |
101 | |
102 | // |
103 | // There are identical pairs of HEADER/SOURCE ENTER/EXIT macros so that |
104 | // future extension to the namespace mechanism is possible without changing |
105 | // project source code. |
106 | // |
107 | |
108 | #define namespace IMATH_INTERNAL_NAMESPACE { |
109 | #define } |
110 | |
111 | #define IMATH_INTERNAL_NAMESPACE_SOURCE_ENTER namespace IMATH_INTERNAL_NAMESPACE { |
112 | #define IMATH_INTERNAL_NAMESPACE_SOURCE_EXIT } |
113 | |
114 | |
115 | #endif /* INCLUDED_IMATHNAMESPACE_H */ |
116 | |