ImfNamespace.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #ifndef INCLUDED_IMFNAMESPACE_H
  35. #define INCLUDED_IMFNAMESPACE_H
  36. //
  37. // The purpose of this file is to have all of the Imath symbols defined within
  38. // the OPENEXR_IMF_INTERNAL_NAMESPACE namespace rather than the standard Imath
  39. // namespace. Those symbols are made available to client code through the
  40. // OPENEXR_IMF_NAMESPACE in addition to the OPENEXR_IMF_INTERNAL_NAMESPACE.
  41. //
  42. // To ensure source code compatibility, the OPENEXR_IMF_NAMESPACE defaults to
  43. // Imath and then "using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;" brings all
  44. // of the declarations from the OPENEXR_IMF_INTERNAL_NAMESPACE into the
  45. // OPENEXR_IMF_NAMESPACE.
  46. // This means that client code can continue to use syntax like
  47. // Imf::Header, but at link time it will resolve to a
  48. // mangled symbol based on the OPENEXR_IMF_INTERNAL_NAMESPACE.
  49. //
  50. // As an example, if one needed to build against a newer version of Imath and
  51. // have it run alongside an older version in the same application, it is now
  52. // possible to use an internal namespace to prevent collisions between the
  53. // older versions of Imath symbols and the newer ones. To do this, the
  54. // following could be defined at build time:
  55. //
  56. // OPENEXR_IMF_INTERNAL_NAMESPACE = Imf_v2
  57. //
  58. // This means that declarations inside Imath headers look like this (after
  59. // the preprocessor has done its work):
  60. //
  61. // namespace Imf_v2 {
  62. // ...
  63. // class declarations
  64. // ...
  65. // }
  66. //
  67. // namespace Imf {
  68. // using namespace IMF_NAMESPACE_v2;
  69. // }
  70. //
  71. //
  72. // Open Source version of this file pulls in the OpenEXRConfig.h file
  73. // for the configure time options.
  74. //
  75. #include "OpenEXRConfig.h"
  76. #ifndef OPENEXR_IMF_NAMESPACE
  77. #define OPENEXR_IMF_NAMESPACE Imf
  78. #endif
  79. #ifndef OPENEXR_IMF_INTERNAL_NAMESPACE
  80. #define OPENEXR_IMF_INTERNAL_NAMESPACE OPENEXR_IMF_NAMESPACE
  81. #endif
  82. //
  83. // We need to be sure that we import the internal namespace into the public one.
  84. // To do this, we use the small bit of code below which initially defines
  85. // OPENEXR_IMF_INTERNAL_NAMESPACE (so it can be referenced) and then defines
  86. // OPENEXR_IMF_NAMESPACE and pulls the internal symbols into the public
  87. // namespace.
  88. //
  89. namespace OPENEXR_IMF_INTERNAL_NAMESPACE {}
  90. namespace OPENEXR_IMF_NAMESPACE {
  91. using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;
  92. }
  93. //
  94. // There are identical pairs of HEADER/SOURCE ENTER/EXIT macros so that
  95. // future extension to the namespace mechanism is possible without changing
  96. // project source code.
  97. //
  98. #define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER namespace OPENEXR_IMF_INTERNAL_NAMESPACE {
  99. #define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT }
  100. #define OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER namespace OPENEXR_IMF_INTERNAL_NAMESPACE {
  101. #define OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT }
  102. #endif /* INCLUDED_IMFNAMESPACE_H */