Blame IlmImf/ImfNamespace.h

Packit 0d464f
///////////////////////////////////////////////////////////////////////////
Packit 0d464f
//
Packit 0d464f
// Copyright (c) 2012, Industrial Light & Magic, a division of Lucas
Packit 0d464f
// Digital Ltd. LLC
Packit 0d464f
//
Packit 0d464f
// All rights reserved.
Packit 0d464f
//
Packit 0d464f
// Redistribution and use in source and binary forms, with or without
Packit 0d464f
// modification, are permitted provided that the following conditions are
Packit 0d464f
// met:
Packit 0d464f
// *       Redistributions of source code must retain the above copyright
Packit 0d464f
// notice, this list of conditions and the following disclaimer.
Packit 0d464f
// *       Redistributions in binary form must reproduce the above
Packit 0d464f
// copyright notice, this list of conditions and the following disclaimer
Packit 0d464f
// in the documentation and/or other materials provided with the
Packit 0d464f
// distribution.
Packit 0d464f
// *       Neither the name of Industrial Light & Magic nor the names of
Packit 0d464f
// its contributors may be used to endorse or promote products derived
Packit 0d464f
// from this software without specific prior written permission.
Packit 0d464f
//
Packit 0d464f
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 0d464f
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 0d464f
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 0d464f
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit 0d464f
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit 0d464f
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit 0d464f
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit 0d464f
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit 0d464f
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 0d464f
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 0d464f
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 0d464f
//
Packit 0d464f
///////////////////////////////////////////////////////////////////////////
Packit 0d464f
Packit 0d464f
#ifndef INCLUDED_IMFNAMESPACE_H
Packit 0d464f
#define INCLUDED_IMFNAMESPACE_H
Packit 0d464f
Packit 0d464f
//
Packit 0d464f
// The purpose of this file is to have all of the Imath symbols defined within 
Packit 0d464f
// the OPENEXR_IMF_INTERNAL_NAMESPACE namespace rather than the standard Imath
Packit 0d464f
// namespace. Those symbols are made available to client code through the 
Packit 0d464f
// OPENEXR_IMF_NAMESPACE in addition to the OPENEXR_IMF_INTERNAL_NAMESPACE.
Packit 0d464f
//
Packit 0d464f
// To ensure source code compatibility, the OPENEXR_IMF_NAMESPACE defaults to
Packit 0d464f
// Imath and then "using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;" brings all
Packit 0d464f
// of the declarations from the OPENEXR_IMF_INTERNAL_NAMESPACE into the
Packit 0d464f
// OPENEXR_IMF_NAMESPACE.
Packit 0d464f
// This means that client code can continue to use syntax like
Packit 0d464f
// Imf::Header, but at link time it will resolve to a
Packit 0d464f
// mangled symbol based on the OPENEXR_IMF_INTERNAL_NAMESPACE.
Packit 0d464f
//
Packit 0d464f
// As an example, if one needed to build against a newer version of Imath and
Packit 0d464f
// have it run alongside an older version in the same application, it is now
Packit 0d464f
// possible to use an internal namespace to prevent collisions between the
Packit 0d464f
// older versions of Imath symbols and the newer ones.  To do this, the
Packit 0d464f
// following could be defined at build time:
Packit 0d464f
//
Packit 0d464f
// OPENEXR_IMF_INTERNAL_NAMESPACE = Imf_v2
Packit 0d464f
//
Packit 0d464f
// This means that declarations inside Imath headers look like this (after
Packit 0d464f
// the preprocessor has done its work):
Packit 0d464f
//
Packit 0d464f
// namespace Imf_v2 {
Packit 0d464f
//     ...
Packit 0d464f
//     class declarations
Packit 0d464f
//     ...
Packit 0d464f
// }
Packit 0d464f
//
Packit 0d464f
// namespace Imf {
Packit 0d464f
//     using namespace IMF_NAMESPACE_v2;
Packit 0d464f
// }
Packit 0d464f
//
Packit 0d464f
Packit 0d464f
//
Packit 0d464f
// Open Source version of this file pulls in the OpenEXRConfig.h file
Packit 0d464f
// for the configure time options.
Packit 0d464f
//
Packit 0d464f
#include "OpenEXRConfig.h"
Packit 0d464f
Packit 0d464f
Packit 0d464f
#ifndef OPENEXR_IMF_NAMESPACE
Packit 0d464f
#define OPENEXR_IMF_NAMESPACE Imf
Packit 0d464f
#endif
Packit 0d464f
Packit 0d464f
#ifndef OPENEXR_IMF_INTERNAL_NAMESPACE
Packit 0d464f
#define OPENEXR_IMF_INTERNAL_NAMESPACE OPENEXR_IMF_NAMESPACE
Packit 0d464f
#endif
Packit 0d464f
Packit 0d464f
//
Packit 0d464f
// We need to be sure that we import the internal namespace into the public one.
Packit 0d464f
// To do this, we use the small bit of code below which initially defines
Packit 0d464f
// OPENEXR_IMF_INTERNAL_NAMESPACE (so it can be referenced) and then defines
Packit 0d464f
// OPENEXR_IMF_NAMESPACE and pulls the internal symbols into the public
Packit 0d464f
// namespace.
Packit 0d464f
//
Packit 0d464f
Packit 0d464f
namespace OPENEXR_IMF_INTERNAL_NAMESPACE {}
Packit 0d464f
namespace OPENEXR_IMF_NAMESPACE {
Packit 0d464f
     using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;
Packit 0d464f
}
Packit 0d464f
Packit 0d464f
//
Packit 0d464f
// There are identical pairs of HEADER/SOURCE ENTER/EXIT macros so that
Packit 0d464f
// future extension to the namespace mechanism is possible without changing
Packit 0d464f
// project source code.
Packit 0d464f
//
Packit 0d464f
Packit 0d464f
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER namespace OPENEXR_IMF_INTERNAL_NAMESPACE {
Packit 0d464f
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT }
Packit 0d464f
Packit 0d464f
#define OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER namespace OPENEXR_IMF_INTERNAL_NAMESPACE {
Packit 0d464f
#define OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT }
Packit 0d464f
Packit 0d464f
Packit 0d464f
#endif /* INCLUDED_IMFNAMESPACE_H */