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