Skip to content
Snippets Groups Projects
Commit 3bfd75b0 authored by Adrian Burri's avatar Adrian Burri
Browse files

Helper template for HasStream interface

[[Imported from SVN: r2743]]
parent dbb9e7c9
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,8 @@
#ifndef DUNE_INTERFACES_HH
#define DUNE_INTERFACES_HH
#include "typetraits.hh"
namespace Dune {
//! An interface class for cloneable objects
......@@ -19,6 +21,29 @@ namespace Dune {
//! Tagging interface to indicate that Grid provides typedef ObjectStreamType
struct HasObjectStream {};
//! Helper template (implicit specialisation if GridImp exports an object
//! stream
template <bool hasStream, class GridImp, class DefaultImp>
struct GridObjectStreamOrDefaultHelper {
typedef typename GridImp::ObjectStreamType ObjectStreamType;
};
//! Helper template (explicit specialisation if GridImp doesn't export an
//! object stream -> DefaultImplementation is exported)
template <class GridImp, class DefaultImp>
struct GridObjectStreamOrDefaultHelper {
typedef DefaultImp ObjectStreamType;
};
//! Template to choose right Object stream type for a given class
template <class GridImp, class DefaultImp>
struct GridObjectStreamOrDefault {
GridObjectStreamOrDefaultHelper<
Conversion<GridImp, HasObjectStream::exists>,
GridImp,
DefaultImp>::ObjectStreamType ObjectStreamType;
};
} // end namespace Dune
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment