HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IlmThreadNamespace.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_ILMTHREADNAMESPACE_H
7 #define INCLUDED_ILMTHREADNAMESPACE_H
8 
9 //
10 // The purpose of this file is to make it possible to specify an
11 // ILMTHREAD_INTERNAL_NAMESPACE as a preprocessor definition and have all of
12 // the IlmThread symbols defined within that namespace rather than the
13 // standard IlmThread namespace. Those symbols are made available to client
14 // code through the ILMTHREAD_NAMESPACE in addition to the
15 // ILMTHREAD_INTERNAL_NAMESPACE.
16 //
17 // To ensure source code compatibility, the ILMTHREAD_NAMESPACE defaults to
18 // IlmThread and then "using namespace ILMTHREAD_INTERNAL_NAMESPACE;" brings
19 // all of the declarations from the ILMTHREAD_INTERNAL_NAMESPACE into the
20 // ILMTHREAD_NAMESPACE. This means that client code can continue to use
21 // syntax like IlmThread::Thread, but at link time it will resolve to a
22 // mangled symbol based on the ILMTHREAD_INTERNAL_NAMESPACE.
23 //
24 // As an example, if one needed to build against a newer version of IlmThread
25 // and have it run alongside an older version in the same application, it is
26 // now possible to use an internal namespace to prevent collisions between
27 // the older versions of IlmThread symbols and the newer ones. To do this,
28 // the following could be defined at build time:
29 //
30 // ILMTHREAD_INTERNAL_NAMESPACE = IlmThread_v2
31 //
32 // This means that declarations inside IlmThread headers look like this
33 // (after the preprocessor has done its work):
34 //
35 // namespace IlmThread_v2 {
36 // ...
37 // class declarations
38 // ...
39 // }
40 //
41 // namespace IlmThread {
42 // using namespace IlmThread_v2;
43 // }
44 //
45 
46 //
47 // Open Source version of this file pulls in the IlmThreadConfig.h file
48 // for the configure time options.
49 //
50 #include "IlmThreadConfig.h"
51 
52 #ifndef ILMTHREAD_NAMESPACE
53 # define ILMTHREAD_NAMESPACE IlmThread
54 #endif
55 
56 #ifndef ILMTHREAD_INTERNAL_NAMESPACE
57 # define ILMTHREAD_INTERNAL_NAMESPACE ILMTHREAD_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 // ILMTHREAD_INTERNAL_NAMESPACE (so it can be referenced) and then defines
64 // ILMTHREAD_NAMESPACE and pulls the internal symbols into the public
65 // namespace.
66 //
67 
69 {}
71 {
72 using namespace ILMTHREAD_INTERNAL_NAMESPACE;
73 }
74 
75 //
76 // There are identical pairs of HEADER/SOURCE ENTER/EXIT macros so that
77 // future extension to the namespace mechanism is possible without changing
78 // project source code.
79 //
80 
81 #define ILMTHREAD_INTERNAL_NAMESPACE_HEADER_ENTER \
82  namespace ILMTHREAD_INTERNAL_NAMESPACE \
83  {
84 #define ILMTHREAD_INTERNAL_NAMESPACE_HEADER_EXIT }
85 
86 #define ILMTHREAD_INTERNAL_NAMESPACE_SOURCE_ENTER \
87  namespace ILMTHREAD_INTERNAL_NAMESPACE \
88  {
89 #define ILMTHREAD_INTERNAL_NAMESPACE_SOURCE_EXIT }
90 
91 #endif // INCLUDED_ILMTHREADNAMESPACE_H
#define ILMTHREAD_INTERNAL_NAMESPACE
#define ILMTHREAD_NAMESPACE