1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 
4 /** \file
5 
6    Defines macros to put symbols into namespaces if C++ compiler is
7    used. Everything is put into the namespace UG, dimension-dependent
8    functions into UG::D2 or UG::D3
9 
10    in a header-files use:
11 
12    #include "namespace.h"
13 
14     START_UG_NAMESPACE
15 
16     ...
17 
18     END_UG_NAMESPACE
19 
20    for stuff that is independent of the space dimension or
21 
22    #include "namespace.h"
23 
24     START_UGDIM_NAMESPACE
25 
26     ...
27 
28     END_UGDIM_NAMESPACE
29 
30    else.  In the implementation:
31 
32    #include "namespace.h"   // of course
33 
34     USING_UG_NAMESPACE       // for stuff from the namespace UG
35 
36    or
37     USING_UGDIM_NAMESPACE    // for stuff from UG::D3 resp. UG::D2
38 
39    Write
40 
41     int NS_PREFIX function(...) { ... };
42 
43    if function is declared in UG and
44 
45     int NS_DIM_PREFIX function(...) { ... };
46 
47    if it is declared in a namespace with dimension.
48 
49  */
50 
51 #ifndef UG_NAMESPACE_H
52 #define UG_NAMESPACE_H
53 
54 #define START_UG_NAMESPACE namespace UG {
55 #define END_UG_NAMESPACE }
56 #define END_UGDIM_NAMESPACE }}
57 #define NS_PREFIX UG::
58 #define USING_UG_NAMESPACE using namespace UG;
59 
60 #ifdef UG_DIM_3
61 #define START_UGDIM_NAMESPACE namespace UG { namespace D3 {
62 #define USING_UGDIM_NAMESPACE using namespace UG::D3;
63 #define USING_UG_NAMESPACES namespace UG {namespace D3 {} } using namespace UG; using namespace UG::D3;
64 #define NS_DIM_PREFIX UG::D3::
65 #else
66 #define START_UGDIM_NAMESPACE namespace UG { namespace D2 {
67 #define USING_UGDIM_NAMESPACE using namespace UG::D2;
68 #define USING_UG_NAMESPACES namespace UG {namespace D2 {} } using namespace UG; using namespace UG::D2;
69 #define NS_DIM_PREFIX UG::D2::
70 #endif
71 
72 /* check if the required symbols exist */
73 #if !defined(NS_PREFIX) || !defined(START_UG_NAMESPACE) || !defined(END_UG_NAMESPACE)
74 # error missing symbol!
75 #endif
76 
77 #endif
78