Re: [Libmesh-devel] LibMesh namespace?

On Mon, 21 Jun 2010, Roy Stogner wrote:
> No way. With "libMesh::Mesh" we can use the namespace features and
> probably get away with a few lines of code in every file (deep breath
> in, Derek, deep breath out...); with "libMesh_Mesh" there really
> wouldn't be a way to avoid a 20K line patch.
Okay, let's see if my current patch passes review:
It's over 3000 lines, but all but a handful of lines are either
whitespace, braces, "namespace libMesh {", "}"
I've added "using namespace libMesh;" to the example files. That way
future apps based on them will survive when (either as a near-term
option or a long-term default) we stop importing the namespace by
default.
There's a "using namespace libMesh;" in the library itself, which is
enough that nearly all code works unchanged.
There are at least a couple exceptions, which require ugly workarounds
if you want to be compatible with both pre-patch and post-patch
library versions:
// forward declarations of libMesh classes:
#include "libmesh_base.h"
#ifdef LIBMESH_USE_SEPARATE_NAMESPACE
namespace libMesh {
class Point;
class Elem;
}
#else
class Point;
class Elem;
#endif
// template specializations of libMesh classes:
#ifdef LIBMESH_USE_SEPARATE_NAMESPACE
libMesh::FactoryImp<HeatTransfer, Physics> heat_transfer_factory ("Heat Transfer");
#else
FactoryImp<HeatTransfer, Physics> heat_transfer_factory ("Heat Transfer");
#endif
Comments? This isn't as bad as Derek was fearing, but neither is it
the "everything works without changes" situation I'd hoped for.
---
Roy